formatting
This commit is contained in:
@@ -83,7 +83,7 @@ const CreateFormContent = ({ setOpen, mutate }) => {
|
||||
const startPoint = `${data.start_point.lat},${data.start_point.lng}`;
|
||||
const formData = new FormData();
|
||||
formData.append("activity_date", data.activity_date);
|
||||
formData.append("activity_time", format(new Date(data.activity_time), "HH:mm"));
|
||||
formData.append("activity_time", `${data.activity_time.toString().padStart(2, "0")}:00`);
|
||||
formData.append("info_id", data.info_id);
|
||||
formData.append("axis_type_id", data.axis_type_id);
|
||||
formData.append("recognize_picture", data.recognize_picture);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Box, Chip, Divider, Grid, Stack, Typography } from "@mui/material";
|
||||
import InsertDriveFileIcon from "@mui/icons-material/InsertDriveFile";
|
||||
import ImageUpload from "./ImageUpload";
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import HourSelect from "@/core/components/HourSelect";
|
||||
import MapInfoOneMarker from "@/core/components/MapInfoOneMarker";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import MuiTimePicker from "@/core/components/MuiTimePicker";
|
||||
import SelectBox from "@/core/components/SelectBox";
|
||||
import InsertDriveFileIcon from "@mui/icons-material/InsertDriveFile";
|
||||
import { Box, Chip, Divider, Grid, Stack, Typography } from "@mui/material";
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import ImageUpload from "./ImageUpload";
|
||||
|
||||
const GetSubItemInfo = ({ itemsList, control, setValue, errors }) => {
|
||||
const StartPoint = useWatch({ control, name: "start_point" });
|
||||
@@ -84,14 +84,11 @@ const GetSubItemInfo = ({ itemsList, control, setValue, errors }) => {
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<MuiTimePicker
|
||||
name="activity_time"
|
||||
error={error}
|
||||
<HourSelect
|
||||
value={field.value}
|
||||
placeholder={"زمان فعالیت را وارد کنید"}
|
||||
label={"زمان فعالیت"}
|
||||
setFieldValue={(name, value) => field.onChange(value || null)}
|
||||
helperText={error ? error.message : null}
|
||||
label="ساعت فعالیت"
|
||||
error={error}
|
||||
onChange={field.onChange}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { Button, DialogActions, DialogContent, Stack } from "@mui/material";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import HourSelect from "@/core/components/HourSelect";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import { THIRD_STEP_STORE } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { Button, DialogActions, DialogContent, Grid, Stack } from "@mui/material";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { mixed, object, string } from "yup";
|
||||
import ImageUpload from "./ImageUpload";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { THIRD_STEP_STORE } from "@/core/utils/routes";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import MuiTimePicker from "@/core/components/MuiTimePicker";
|
||||
import { format } from "date-fns";
|
||||
|
||||
const StepThreeContent = ({ setOpen, mutate, rowId }) => {
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
@@ -33,7 +32,7 @@ const StepThreeContent = ({ setOpen, mutate, rowId }) => {
|
||||
});
|
||||
const onSubmit = async (data) => {
|
||||
const formData = new FormData();
|
||||
formData.append("action_date", `${data.action_date} ${format(new Date(data.action_time), "HH:mm")}`);
|
||||
formData.append("action_date", `${data.action_date} ${data.action_time.toString().padStart(2, "0")}:00`);
|
||||
formData.append("action_picture", data.action_picture);
|
||||
await requestServer(`${THIRD_STEP_STORE}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
@@ -48,43 +47,44 @@ const StepThreeContent = ({ setOpen, mutate, rowId }) => {
|
||||
return (
|
||||
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
||||
<DialogContent dividers>
|
||||
<Stack spacing={2}>
|
||||
<Stack direction={"row"} spacing={2} justifyContent={"space-between"}>
|
||||
<Controller
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<MuiDatePicker
|
||||
name="action_date"
|
||||
error={error}
|
||||
value={field.value}
|
||||
placeholder={"تاریخ اقدام را وارد کنید"}
|
||||
label={"تاریخ اقدام"}
|
||||
setFieldValue={(name, value) => field.onChange(value || [])}
|
||||
helperText={error ? error.message : null}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
name={"action_date"}
|
||||
/>
|
||||
<Controller
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<MuiTimePicker
|
||||
name="action_time"
|
||||
error={error}
|
||||
value={field.value}
|
||||
placeholder={"زمان اقدام را وارد کنید"}
|
||||
label={"زمان اقدام"}
|
||||
setFieldValue={(name, value) => field.onChange(value || null)}
|
||||
helperText={error ? error.message : null}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
name={"action_time"}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<Controller
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<MuiDatePicker
|
||||
name="action_date"
|
||||
error={error}
|
||||
value={field.value}
|
||||
placeholder={"تاریخ اقدام را وارد کنید"}
|
||||
label={"تاریخ اقدام"}
|
||||
setFieldValue={(name, value) => field.onChange(value || [])}
|
||||
helperText={error ? error.message : null}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
name={"action_date"}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<Controller
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<HourSelect
|
||||
value={field.value}
|
||||
label="ساعت اقدام"
|
||||
error={error}
|
||||
onChange={field.onChange}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
name={"action_time"}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Controller
|
||||
name="action_picture"
|
||||
control={control}
|
||||
|
||||
26
src/core/components/HourSelect.jsx
Normal file
26
src/core/components/HourSelect.jsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { FormControl, FormHelperText, InputLabel, MenuItem, Select } from "@mui/material";
|
||||
|
||||
const HourSelect = ({ label, error, name, value, onChange }) => {
|
||||
return (
|
||||
<FormControl fullWidth size="small" error={!!error}>
|
||||
<InputLabel>{label}</InputLabel>
|
||||
<Select
|
||||
label={label}
|
||||
name={name}
|
||||
size="small"
|
||||
value={value}
|
||||
onChange={(e) => {
|
||||
onChange(e.target.value);
|
||||
}}
|
||||
>
|
||||
{Array.from({ length: 24 }, (_, i) => (
|
||||
<MenuItem key={i} value={i}>
|
||||
{`${i.toString().padStart(2, "0")}:00`}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
<FormHelperText>{error?.message}</FormHelperText>
|
||||
</FormControl>
|
||||
);
|
||||
};
|
||||
export default HourSelect;
|
||||
@@ -16,6 +16,7 @@ import MapIcon from "@mui/icons-material/Map";
|
||||
import SpeedIcon from "@mui/icons-material/Speed";
|
||||
import EngineeringIcon from "@mui/icons-material/Engineering";
|
||||
import ReportIcon from "@mui/icons-material/Report";
|
||||
import AssessmentIcon from "@mui/icons-material/Assessment";
|
||||
import AssignmentLateIcon from "@mui/icons-material/AssignmentLate";
|
||||
import LockPersonIcon from "@mui/icons-material/LockPerson";
|
||||
import LineAxisIcon from "@mui/icons-material/LineAxis";
|
||||
@@ -291,6 +292,26 @@ export const pageMenu = [
|
||||
{ key: "safetyAndPrivacy.step_two", color: "error" },
|
||||
],
|
||||
Subitems: [
|
||||
{
|
||||
id: "safetyAndPrivacyManagmentSupervisor",
|
||||
label: "ارزیابی",
|
||||
type: "menu",
|
||||
icon: <SpeedIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
hasSubitems: true,
|
||||
badges: [{ key: "safetyAndPrivacy.supervise_cnt" }],
|
||||
Subitems: [
|
||||
{
|
||||
id: "safetyAndPrivacyManagmentSupervisorCartable",
|
||||
label: "کارتابل",
|
||||
type: "page",
|
||||
route: "/dashboard/road-safety/supervisor",
|
||||
permissions: [
|
||||
"show-safety-and-privacy-operator-cartable",
|
||||
"show-safety-and-privacy-operator-cartable-province",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "safetyAndPrivacyManagmentOparation",
|
||||
label: "عملیات",
|
||||
@@ -302,23 +323,12 @@ export const pageMenu = [
|
||||
{ key: "safetyAndPrivacy.step_two", color: "error" },
|
||||
],
|
||||
Subitems: [
|
||||
{
|
||||
id: "safetyAndPrivacyManagmentOparationCreate",
|
||||
label: "ثبت فعالیت",
|
||||
type: "page",
|
||||
route: process.env.NEXT_PUBLIC_API_URL + "/v2/safety_and_privacy/operator/first_step",
|
||||
permissions: ["add-safety-and-privacy"],
|
||||
},
|
||||
{
|
||||
id: "safetyAndPrivacyManagmentOparationCartable",
|
||||
label: "کارتابل",
|
||||
type: "page",
|
||||
route: process.env.NEXT_PUBLIC_API_URL + "/v2/safety_and_privacy/operator/cartable",
|
||||
permissions: [
|
||||
"show-safety-and-privacy-operator-cartable",
|
||||
"show-safety-and-privacy-operator-cartable-province",
|
||||
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
||||
],
|
||||
route: "/dashboard/road-safety/operator",
|
||||
permissions: ["show-safety-and-privacy-operator-cartable-edarate-shahri"],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -326,26 +336,24 @@ export const pageMenu = [
|
||||
id: "safetyAndPrivacyManagmentMap",
|
||||
label: "پراکندگی بر روی نقشه",
|
||||
type: "page",
|
||||
route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=safety_and_privacy",
|
||||
route: "/dashboard/road-safety/reports/map",
|
||||
icon: <MapIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
permissions: [
|
||||
"show-safety-and-privacy-operator-cartable",
|
||||
"show-safety-and-privacy-operator-cartable-province",
|
||||
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
||||
"add-safety-and-privacy",
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "safetyAndPrivacyManagmentReport",
|
||||
label: "گزارش ها",
|
||||
type: "page",
|
||||
route: process.env.NEXT_PUBLIC_API_URL + "/v2/safety_and_privacy/report",
|
||||
icon: <ReportIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
route: "/dashboard/road-safety/reports",
|
||||
icon: <AssessmentIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
permissions: [
|
||||
"show-safety-and-privacy-operator-cartable",
|
||||
"show-safety-and-privacy-operator-cartable-province",
|
||||
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
||||
"add-safety-and-privacy",
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -541,4 +549,4 @@ export const pageMenu = [
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user