import { Box, Button, DialogActions, DialogContent, Tab, Tabs } from "@mui/material"; import { useForm } from "react-hook-form"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; import InsertDriveFileIcon from "@mui/icons-material/InsertDriveFile"; import FileCopyIcon from "@mui/icons-material/FileCopy"; import ExitToAppIcon from "@mui/icons-material/ExitToApp"; import KeyboardDoubleArrowRightIcon from "@mui/icons-material/KeyboardDoubleArrowRight"; import BeenhereIcon from "@mui/icons-material/Beenhere"; import StyledForm from "@/core/components/StyledForm"; import React, { useState } from "react"; import SearchItemInfo from "./SearchItemInfo"; import moment from "jalali-moment"; import GetItemInfo from "./RowActions/GetItemInfo"; function TabPanel(props) { const { children, value, index } = props; return ( ); } const defaultValues = { start_date: moment(new Date()).format("YYYY-MM-DD"), end_date: moment(new Date()).format("YYYY-MM-DD"), item_id: "", road_patrol_id: "", }; const defaultFilter = [ { value: `${defaultValues.item_id}`, datatype: "text", id: "item_id", fn: "equals" }, { value: `${defaultValues.road_patrol_id}`, datatype: "text", id: "road_patrol_id", fn: "equals" }, { value: `${defaultValues.start_date}`, datatype: "date", id: "roadPatrol.start_time", fn: "equals" }, { value: `${defaultValues.end_date}`, datatype: "date", id: "roadPatrol.end_time", fn: "equals" }, ]; const GashtCreateContent = ({ mutate, setOpen, tabState, setTabState }) => { const [itemInfo, setItemInfo] = useState(null); const [submitCompleteForm, setSubmitCompleteForm] = useState(false); const [specialFilter, setSpecialFilter] = useState(defaultFilter); const validationSchema = yup .object() .shape({ start_date: yup.string().nullable(), end_date: yup.string().nullable(), item_id: yup.string().nullable(), road_patrol_id: yup.string().nullable(), }) .test("at-least-one", "وارد کردن مقدار ضروریست!!!", (values) => { return (!!values.start_date && !!values.end_date) || !!values.item_id || !!values.road_patrol_id; }); const handleChangeTab = (event, newValue) => { setTabState(newValue); }; const handleClose = () => { setOpen(false); }; const handlePrev = () => { if (tabState === 0) { handleClose(); } else { setTabState(tabState - 1); } }; const { control, getValues, watch, register, handleSubmit, setValue, formState: { errors, isSubmitting }, } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "onBlur", }); const onSearchSubmit = async (data) => { setSpecialFilter([ { value: `${data.item_id}`, datatype: "text", id: "item_id", fn: "equals" }, { value: `${data.road_patrol_id}`, datatype: "text", id: "road_patrol_id", fn: "equals" }, { value: `${data.start_date}`, datatype: "date", id: "roadPatrol.start_time", fn: "equals" }, { value: `${data.end_date}`, datatype: "date", id: "roadPatrol.end_time", fn: "equals" }, ]); }; return ( <> } label="انتخاب مورد مشاهده شده" /> } label="اطلاعات مورد اقدام شده" /> {tabState === 1 && ( )} ); }; export default GashtCreateContent;