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.
 
 

131 satır
4.2 KiB

  1. // material-ui
  2. import {
  3. Button,
  4. CardContent,
  5. Grid, TextField,
  6. Typography
  7. } from '@mui/material';
  8. import MainCard from "../../components/MainCard";
  9. import {useForm} from "react-hook-form";
  10. import { useState} from "react";
  11. import * as React from "react";
  12. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  13. const OrganizationSearchForm = ({applySearch}) => {
  14. const [type, setType] = useState([]);
  15. const { reset, register, handleSubmit } = useForm()
  16. const onSubmit = (data) => {
  17. let typeArray = [];
  18. for(let i =0; i < type.length; i++){
  19. typeArray.push(type[i].label);
  20. }
  21. const temp = {
  22. brNo: data.brNo,
  23. enCompanyName: data.enCompanyName,
  24. chCompanyName: data.chCompanyName,
  25. };
  26. applySearch(temp);
  27. };
  28. function resetForm(){
  29. setType([]);
  30. reset();
  31. }
  32. return (
  33. <MainCard xs={12} md={12} lg={12}
  34. border={false}
  35. content={false}>
  36. <form onSubmit={handleSubmit(onSubmit)}>
  37. {/*row 1*/}
  38. <CardContent sx={{ px: 2.5, pt: 3 }}>
  39. <Grid item justifyContent="space-between" alignItems="center">
  40. <Typography variant="h4">Search Form</Typography>
  41. </Grid>
  42. </CardContent>
  43. {/*row 2*/}
  44. <Grid container alignItems={"center"}>
  45. <Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>
  46. <TextField
  47. fullWidth
  48. {...register("brNo")}
  49. id='brNo'
  50. label="BR No."
  51. InputLabelProps={{
  52. shrink: true
  53. }}
  54. />
  55. </Grid>
  56. <Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>
  57. <TextField
  58. fullWidth
  59. {...register("enCompanyName")}
  60. id="enCompanyName"
  61. label="Name (English)"
  62. InputLabelProps={{
  63. shrink: true
  64. }}
  65. />
  66. </Grid>
  67. <Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>
  68. <TextField
  69. fullWidth
  70. {...register("chCompanyName")}
  71. id="chCompanyName"
  72. label="Name (Chinese)"
  73. InputLabelProps={{
  74. shrink: true
  75. }}
  76. />
  77. </Grid>
  78. </Grid>
  79. {/*last row*/}
  80. <Grid container maxWidth justifyContent="flex-end">
  81. <Grid item sx={{ml:3, mr:3, mb:3, mt:3}}>
  82. <Button
  83. size="large"
  84. variant="contained"
  85. onClick={resetForm}
  86. sx={{
  87. textTransform: 'capitalize',
  88. alignItems: 'end'
  89. }}>
  90. <Typography variant="h5">Clear</Typography>
  91. </Button>
  92. </Grid>
  93. <Grid item sx={{ml:3, mr:3, mb:3, mt:3}}>
  94. <Button
  95. size="large"
  96. variant="contained"
  97. type="submit"
  98. sx={{
  99. textTransform: 'capitalize',
  100. alignItems: 'end'
  101. }}>
  102. <Typography variant="h5">Submit</Typography>
  103. </Button>
  104. </Grid>
  105. </Grid>
  106. </form>
  107. </MainCard>
  108. );
  109. };
  110. export default OrganizationSearchForm;