選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

134 行
5.2 KiB

  1. // material-ui
  2. import {
  3. Button,
  4. Grid,
  5. TextField,
  6. Autocomplete,
  7. Typography
  8. } from '@mui/material';
  9. import MainCard from "components/MainCard";
  10. import { useForm } from "react-hook-form";
  11. import * as React from "react";
  12. // import * as DateUtils from "utils/DateUtils";
  13. import {PNSPS_BUTTON_THEME} from "themes/buttonConst";
  14. import {ThemeProvider} from "@emotion/react";
  15. // import * as ComboData from "utils/ComboData";
  16. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  17. const SearchGazetteIssueForm = ({ applyExport, comboData, waitDownload}) => {
  18. const [selectedYear, setSelectedYear] = React.useState([]);
  19. // const [defaultYear, setDefaultYear] = React.useState(searchCriteria.year);
  20. const [comboList, setComboList] = React.useState([]);
  21. // const [onReady, setOnReady] = React.useState(false);
  22. const {
  23. // register,
  24. handleSubmit } = useForm()
  25. const onSubmit = () => {
  26. console.log(selectedYear)
  27. if (selectedYear !=null && Object.keys(selectedYear).length>0){
  28. console.log("okkkkkkkkkkkkkkkk")
  29. const temp = {
  30. year: selectedYear.label,
  31. };
  32. applyExport(temp);
  33. }
  34. };
  35. React.useEffect(() => {
  36. if (comboData && comboData.length > 0) {
  37. // console.log(comboData)
  38. // const labelValue = comboData.find(obj => obj.label === searchCriteria.year);
  39. // console.log(labelValue)
  40. // if(selectedYear.length == 0){
  41. // setSelectedYear(comboData[0])
  42. // }
  43. setComboList(comboData)
  44. // setSelectedYear(searchCriteria.dateFrom)
  45. }
  46. }, [comboData]);
  47. return (
  48. <MainCard xs={12} md={12} lg={12}
  49. border={false}
  50. content={false}
  51. >
  52. <form onSubmit={handleSubmit(onSubmit)} >
  53. <Grid container sx={{ backgroundColor: '#ffffff', ml: 2, mt: 1}} width="98%">
  54. {/*row 1*/}
  55. <Grid item justifyContent="space-between" alignItems="center" sx={{mt:1,ml:3,mb:1}}>
  56. <Typography variant="h5" >
  57. Export Preliminary Gazette Issue From Holiday Year
  58. </Typography>
  59. </Grid>
  60. {/*row 2*/}
  61. <Grid container display="flex" alignItems={"center"}>
  62. <Grid item xs={9} s={6} md={4} lg={4} sx={{ ml: 3, mr: 3, mb: 3 }}>
  63. <Autocomplete
  64. disablePortal
  65. id="year-combo"
  66. value={selectedYear}
  67. // defaultValue={selectedYear}
  68. options={comboList}
  69. // disabled={checkCountry}
  70. getOptionLabel={(option) => option.label ? option.label : ""}
  71. onChange={(event, newValue) => {
  72. setSelectedYear(newValue);
  73. }}
  74. sx={{
  75. "& .MuiInputBase-root": { height: "41px" },
  76. "#year-combo": { padding: "0px 0px 0px 0px" },
  77. "& .MuiAutocomplete-endAdornment": { top: "auto" },
  78. }}
  79. renderInput={(params) => <TextField {...params} placeholder={""}/>}
  80. />
  81. </Grid>
  82. <Grid item xs={9} s={6} md={4} lg={4} sx={{ ml: 3, mr: 3, mb: 3 }}>
  83. {/* <TextField
  84. fullWidth
  85. InputLabelProps={{
  86. shrink: true
  87. }}
  88. {...register("dateTo")}
  89. InputProps={{ inputProps: { min: minDate } }}
  90. onChange={(newValue) => {
  91. setMaxDate(DateUtils.dateValue(newValue));
  92. }}
  93. id="dateTo"
  94. type="date"
  95. label="To"
  96. defaultValue={searchCriteria.dateTo}
  97. /> */}
  98. </Grid>
  99. {/* <Grid item xs={9} s={6} md={4} lg={3}>
  100. </Grid> */}
  101. </Grid>
  102. <Grid container justifyContent="center" direction="row" alignItems="center" spacing={3}>
  103. <ThemeProvider theme={PNSPS_BUTTON_THEME}>
  104. <Grid item sx={{ ml: 3, mb: 3, }} >
  105. <Button
  106. variant="contained"
  107. type="submit"
  108. size="large"
  109. disabled={waitDownload}
  110. >
  111. Export
  112. </Button>
  113. </Grid>
  114. </ThemeProvider>
  115. </Grid>
  116. </Grid>
  117. </form>
  118. </MainCard>
  119. );
  120. };
  121. export default SearchGazetteIssueForm;