25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

115 satır
4.3 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"} sx={{ mb: 1 }}>
  62. <Grid item xs={9} s={6} md={4} lg={4} sx={{ ml: 3, mr: 3 }}>
  63. <Autocomplete
  64. disablePortal
  65. id="year-combo"
  66. value={selectedYear}
  67. // defaultValue={selectedYear}
  68. options={comboList}
  69. // disabled={checkCountry}
  70. getOptionLabel={(option) =>
  71. option != null && typeof option === "object" && option.label != null
  72. ? String(option.label)
  73. : ""
  74. }
  75. onChange={(event, newValue) => {
  76. setSelectedYear(newValue);
  77. }}
  78. sx={{
  79. '& .MuiInputBase-root': { alignItems: 'center' },
  80. '& .MuiAutocomplete-endAdornment': { top: '50%', transform: 'translateY(-50%)' },
  81. '& .MuiOutlinedInput-root': { height: 40 }
  82. }}
  83. renderInput={(params) => <TextField {...params} placeholder={""}/>}
  84. />
  85. </Grid>
  86. <ThemeProvider theme={PNSPS_BUTTON_THEME}>
  87. <Grid item sx={{ mr: 3 }}>
  88. <Button
  89. variant="contained"
  90. type="submit"
  91. disabled={waitDownload}
  92. >
  93. Export
  94. </Button>
  95. </Grid>
  96. </ThemeProvider>
  97. </Grid>
  98. </Grid>
  99. </form>
  100. </MainCard>
  101. );
  102. };
  103. export default SearchGazetteIssueForm;