|
- // material-ui
- import {
- Button,
- CardContent,
- Grid, TextField,
- Typography,
- Checkbox, FormControlLabel,
- } from '@mui/material';
- import MainCard from "../../../components/MainCard";
- import { useForm } from "react-hook-form";
-
- import { useState } from "react";
- import * as React from "react";
-
- import * as UrlUtils from "../../../utils/ApiPathConst";
- import * as HttpUtils from "../../../utils/HttpUtils";
- // ==============================|| DASHBOARD - DEFAULT ||============================== //
-
-
- const OrganizationSearchForm = ({ applySearch }) => {
-
- const [type, setType] = useState([]);
-
- const { reset, register, handleSubmit } = useForm()
- const onSubmit = (data) => {
-
- let typeArray = [];
-
- for (let i = 0; i < type.length; i++) {
- typeArray.push(type[i].label);
- }
-
- const temp = {
- brNo: data.brNo,
- enCompanyName: data.enCompanyName,
- chCompanyName: data.chCompanyName,
- searchCreditor: data.searchCreditor
- };
- applySearch(temp);
- };
-
- function resetForm() {
- setType([]);
- reset();
- }
-
- const doExport=()=>{
- HttpUtils.fileDownload({
- url: UrlUtils.GET_ORG_EXPORT
- });
- }
-
- return (
- <MainCard xs={12} md={12} lg={12}
- border={false}
- content={false}>
-
- <form onSubmit={handleSubmit(onSubmit)}>
- {/*row 1*/}
- <CardContent sx={{ px: 2.5, pt: 3 }}>
- <Grid item justifyContent="space-between" alignItems="center">
- <Typography variant="h4">Search Form</Typography>
- </Grid>
- </CardContent>
-
- {/*row 2*/}
- <Grid container alignItems={"center"}>
- <Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <TextField
- fullWidth
- {...register("brNo")}
- id='brNo'
- label="BR No."
- InputLabelProps={{
- shrink: true
- }}
- />
- </Grid>
-
- <Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <TextField
- fullWidth
- {...register("enCompanyName")}
- id="enCompanyName"
- label="Name (English)"
- InputLabelProps={{
- shrink: true
- }}
- />
- </Grid>
-
- <Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <TextField
- fullWidth
- {...register("chCompanyName")}
- id="chCompanyName"
- label="Name (Chinese)"
- InputLabelProps={{
- shrink: true
- }}
- />
- </Grid>
-
- <Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3}}>
- <FormControlLabel
- {...register("searchCreditor")}
- control={<Checkbox/>}
- label="Search Creditor Only"
- id="searchCreditor"
- />
- </Grid>
-
- </Grid>
-
-
- {/*last row*/}
- <Grid container maxWidth justifyContent="flex-end">
-
- <Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}>
- <Button
- size="large"
- variant="contained"
- onClick={doExport}
- sx={{
- textTransform: 'capitalize',
- alignItems: 'end'
- }}>
- <Typography variant="h5">Export</Typography>
- </Button>
- </Grid>
-
- <Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}>
- <Button
- size="large"
- variant="contained"
- onClick={resetForm}
- sx={{
- textTransform: 'capitalize',
- alignItems: 'end'
- }}>
- <Typography variant="h5">Clear</Typography>
- </Button>
- </Grid>
-
- <Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}>
- <Button
- size="large"
- variant="contained"
- type="submit"
- sx={{
- textTransform: 'capitalize',
- alignItems: 'end'
- }}>
- <Typography variant="h5">Submit</Typography>
- </Button>
- </Grid>
-
-
- </Grid>
- </form>
- </MainCard>
- );
- };
-
- export default OrganizationSearchForm;
|