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 startPoint = `${data.start_point.lat},${data.start_point.lng}`;
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("activity_date", data.activity_date);
|
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("info_id", data.info_id);
|
||||||
formData.append("axis_type_id", data.axis_type_id);
|
formData.append("axis_type_id", data.axis_type_id);
|
||||||
formData.append("recognize_picture", data.recognize_picture);
|
formData.append("recognize_picture", data.recognize_picture);
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { Box, Chip, Divider, Grid, Stack, Typography } from "@mui/material";
|
import HourSelect from "@/core/components/HourSelect";
|
||||||
import InsertDriveFileIcon from "@mui/icons-material/InsertDriveFile";
|
|
||||||
import ImageUpload from "./ImageUpload";
|
|
||||||
import { Controller, useWatch } from "react-hook-form";
|
|
||||||
import MapInfoOneMarker from "@/core/components/MapInfoOneMarker";
|
import MapInfoOneMarker from "@/core/components/MapInfoOneMarker";
|
||||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||||
import MuiTimePicker from "@/core/components/MuiTimePicker";
|
|
||||||
import SelectBox from "@/core/components/SelectBox";
|
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 GetSubItemInfo = ({ itemsList, control, setValue, errors }) => {
|
||||||
const StartPoint = useWatch({ control, name: "start_point" });
|
const StartPoint = useWatch({ control, name: "start_point" });
|
||||||
@@ -84,14 +84,11 @@ const GetSubItemInfo = ({ itemsList, control, setValue, errors }) => {
|
|||||||
control={control}
|
control={control}
|
||||||
render={({ field, fieldState: { error } }) => {
|
render={({ field, fieldState: { error } }) => {
|
||||||
return (
|
return (
|
||||||
<MuiTimePicker
|
<HourSelect
|
||||||
name="activity_time"
|
|
||||||
error={error}
|
|
||||||
value={field.value}
|
value={field.value}
|
||||||
placeholder={"زمان فعالیت را وارد کنید"}
|
label="ساعت فعالیت"
|
||||||
label={"زمان فعالیت"}
|
error={error}
|
||||||
setFieldValue={(name, value) => field.onChange(value || null)}
|
onChange={field.onChange}
|
||||||
helperText={error ? error.message : null}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import { Button, DialogActions, DialogContent, Stack } from "@mui/material";
|
import HourSelect from "@/core/components/HourSelect";
|
||||||
import { Controller, useForm } from "react-hook-form";
|
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||||
import { yupResolver } from "@hookform/resolvers/yup";
|
|
||||||
import StyledForm from "@/core/components/StyledForm";
|
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 { mixed, object, string } from "yup";
|
||||||
import ImageUpload from "./ImageUpload";
|
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 StepThreeContent = ({ setOpen, mutate, rowId }) => {
|
||||||
const requestServer = useRequest({ notificationSuccess: true });
|
const requestServer = useRequest({ notificationSuccess: true });
|
||||||
@@ -33,7 +32,7 @@ const StepThreeContent = ({ setOpen, mutate, rowId }) => {
|
|||||||
});
|
});
|
||||||
const onSubmit = async (data) => {
|
const onSubmit = async (data) => {
|
||||||
const formData = new FormData();
|
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);
|
formData.append("action_picture", data.action_picture);
|
||||||
await requestServer(`${THIRD_STEP_STORE}/${rowId}`, "post", {
|
await requestServer(`${THIRD_STEP_STORE}/${rowId}`, "post", {
|
||||||
data: formData,
|
data: formData,
|
||||||
@@ -48,43 +47,44 @@ const StepThreeContent = ({ setOpen, mutate, rowId }) => {
|
|||||||
return (
|
return (
|
||||||
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
||||||
<DialogContent dividers>
|
<DialogContent dividers>
|
||||||
<Stack spacing={2}>
|
<Stack>
|
||||||
<Stack direction={"row"} spacing={2} justifyContent={"space-between"}>
|
<Grid container spacing={2}>
|
||||||
<Controller
|
<Grid item xs={12} sm={6}>
|
||||||
control={control}
|
<Controller
|
||||||
render={({ field, fieldState: { error } }) => {
|
control={control}
|
||||||
return (
|
render={({ field, fieldState: { error } }) => {
|
||||||
<MuiDatePicker
|
return (
|
||||||
name="action_date"
|
<MuiDatePicker
|
||||||
error={error}
|
name="action_date"
|
||||||
value={field.value}
|
error={error}
|
||||||
placeholder={"تاریخ اقدام را وارد کنید"}
|
value={field.value}
|
||||||
label={"تاریخ اقدام"}
|
placeholder={"تاریخ اقدام را وارد کنید"}
|
||||||
setFieldValue={(name, value) => field.onChange(value || [])}
|
label={"تاریخ اقدام"}
|
||||||
helperText={error ? error.message : null}
|
setFieldValue={(name, value) => field.onChange(value || [])}
|
||||||
/>
|
helperText={error ? error.message : null}
|
||||||
);
|
/>
|
||||||
}}
|
);
|
||||||
name={"action_date"}
|
}}
|
||||||
/>
|
name={"action_date"}
|
||||||
<Controller
|
/>
|
||||||
control={control}
|
</Grid>
|
||||||
render={({ field, fieldState: { error } }) => {
|
<Grid item xs={12} sm={6}>
|
||||||
return (
|
<Controller
|
||||||
<MuiTimePicker
|
control={control}
|
||||||
name="action_time"
|
render={({ field, fieldState: { error } }) => {
|
||||||
error={error}
|
return (
|
||||||
value={field.value}
|
<HourSelect
|
||||||
placeholder={"زمان اقدام را وارد کنید"}
|
value={field.value}
|
||||||
label={"زمان اقدام"}
|
label="ساعت اقدام"
|
||||||
setFieldValue={(name, value) => field.onChange(value || null)}
|
error={error}
|
||||||
helperText={error ? error.message : null}
|
onChange={field.onChange}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
name={"action_time"}
|
name={"action_time"}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Grid>
|
||||||
|
</Grid>
|
||||||
<Controller
|
<Controller
|
||||||
name="action_picture"
|
name="action_picture"
|
||||||
control={control}
|
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 SpeedIcon from "@mui/icons-material/Speed";
|
||||||
import EngineeringIcon from "@mui/icons-material/Engineering";
|
import EngineeringIcon from "@mui/icons-material/Engineering";
|
||||||
import ReportIcon from "@mui/icons-material/Report";
|
import ReportIcon from "@mui/icons-material/Report";
|
||||||
|
import AssessmentIcon from "@mui/icons-material/Assessment";
|
||||||
import AssignmentLateIcon from "@mui/icons-material/AssignmentLate";
|
import AssignmentLateIcon from "@mui/icons-material/AssignmentLate";
|
||||||
import LockPersonIcon from "@mui/icons-material/LockPerson";
|
import LockPersonIcon from "@mui/icons-material/LockPerson";
|
||||||
import LineAxisIcon from "@mui/icons-material/LineAxis";
|
import LineAxisIcon from "@mui/icons-material/LineAxis";
|
||||||
@@ -291,6 +292,26 @@ export const pageMenu = [
|
|||||||
{ key: "safetyAndPrivacy.step_two", color: "error" },
|
{ key: "safetyAndPrivacy.step_two", color: "error" },
|
||||||
],
|
],
|
||||||
Subitems: [
|
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",
|
id: "safetyAndPrivacyManagmentOparation",
|
||||||
label: "عملیات",
|
label: "عملیات",
|
||||||
@@ -302,23 +323,12 @@ export const pageMenu = [
|
|||||||
{ key: "safetyAndPrivacy.step_two", color: "error" },
|
{ key: "safetyAndPrivacy.step_two", color: "error" },
|
||||||
],
|
],
|
||||||
Subitems: [
|
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",
|
id: "safetyAndPrivacyManagmentOparationCartable",
|
||||||
label: "کارتابل",
|
label: "کارتابل",
|
||||||
type: "page",
|
type: "page",
|
||||||
route: process.env.NEXT_PUBLIC_API_URL + "/v2/safety_and_privacy/operator/cartable",
|
route: "/dashboard/road-safety/operator",
|
||||||
permissions: [
|
permissions: ["show-safety-and-privacy-operator-cartable-edarate-shahri"],
|
||||||
"show-safety-and-privacy-operator-cartable",
|
|
||||||
"show-safety-and-privacy-operator-cartable-province",
|
|
||||||
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -326,26 +336,24 @@ export const pageMenu = [
|
|||||||
id: "safetyAndPrivacyManagmentMap",
|
id: "safetyAndPrivacyManagmentMap",
|
||||||
label: "پراکندگی بر روی نقشه",
|
label: "پراکندگی بر روی نقشه",
|
||||||
type: "page",
|
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" }} />,
|
icon: <MapIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||||
permissions: [
|
permissions: [
|
||||||
"show-safety-and-privacy-operator-cartable",
|
"show-safety-and-privacy-operator-cartable",
|
||||||
"show-safety-and-privacy-operator-cartable-province",
|
"show-safety-and-privacy-operator-cartable-province",
|
||||||
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
||||||
"add-safety-and-privacy",
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "safetyAndPrivacyManagmentReport",
|
id: "safetyAndPrivacyManagmentReport",
|
||||||
label: "گزارش ها",
|
label: "گزارش ها",
|
||||||
type: "page",
|
type: "page",
|
||||||
route: process.env.NEXT_PUBLIC_API_URL + "/v2/safety_and_privacy/report",
|
route: "/dashboard/road-safety/reports",
|
||||||
icon: <ReportIcon sx={{ width: "inherit", height: "inherit" }} />,
|
icon: <AssessmentIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||||
permissions: [
|
permissions: [
|
||||||
"show-safety-and-privacy-operator-cartable",
|
"show-safety-and-privacy-operator-cartable",
|
||||||
"show-safety-and-privacy-operator-cartable-province",
|
"show-safety-and-privacy-operator-cartable-province",
|
||||||
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
||||||
"add-safety-and-privacy",
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user