confirm machinary tanafos and sakht period
This commit is contained in:
@@ -358,10 +358,18 @@
|
||||
"description": "توضیحات خود را وارد نمائید",
|
||||
"choose_file": "انتخاب فایل",
|
||||
"approved_amount": "مبلغ تصویب شده",
|
||||
"sakht_amount": "دوره ساخت",
|
||||
"tanafos_amount": "دوره تنفس",
|
||||
"approved_amount_error": "وارد کردن مبلغ تصویب شده الزامیست",
|
||||
"sakht_amount_error": "وارد کردن دوره ساخت الزامیست",
|
||||
"tanafos_amount_error": "وارد کردن دوره تنفس الزامیست",
|
||||
"approved_amount_positive": "مبلغ تصویب شده باید مثبت باشد",
|
||||
"approved_amount_number": "مبلغ تصویب شده باید عدد باشد",
|
||||
"sakht_amount_number": "دوره ساخت باید عدد باشد",
|
||||
"tanafos_amount_number": "دوره تنفس باید عدد باشد",
|
||||
"toman": "میلیون تومان",
|
||||
"tanafos_amount_month": "ماه",
|
||||
"sakht_amount_day": "روز",
|
||||
"proposed_amount_error": "وارد کردن مقدار پیشنهادی الزامیست",
|
||||
"proposed_amount": "مبلغ پیشنهادی",
|
||||
"proposed_amount_positive": "مقدار پیشنهادی باید مثبت باشد",
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
DialogContent,
|
||||
FormHelperText,
|
||||
Grid,
|
||||
InputAdornment,
|
||||
LinearProgress,
|
||||
Stack,
|
||||
TextField,
|
||||
@@ -14,10 +15,7 @@ import {
|
||||
} from "@mui/material"
|
||||
import {useFormik} from "formik";
|
||||
import {useTranslations} from "next-intl";
|
||||
import {
|
||||
CONFIRM_MACHINARY_OFFICE,
|
||||
CONFIRM_MACHINARY_OFFICE_DETAILS
|
||||
} from "@/core/data/apiRoutes";
|
||||
import {CONFIRM_MACHINARY_OFFICE, CONFIRM_MACHINARY_OFFICE_DETAILS} from "@/core/data/apiRoutes";
|
||||
import {useEffect, useState} from "react";
|
||||
import PriceField from "@/core/components/PriceField";
|
||||
import * as Yup from "yup";
|
||||
@@ -28,13 +26,13 @@ const vehicle_amount = {
|
||||
"اتوبوس": 7000,
|
||||
"مینی بوس": 2000,
|
||||
}
|
||||
const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type , handleSizeChangeClick}) => {
|
||||
const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type, handleSizeChangeClick}) => {
|
||||
const t = useTranslations();
|
||||
const [selectedImage, setSelectedImage] = useState("");
|
||||
const [fileType, setfileType] = useState(null);
|
||||
const [fileName, setfileName] = useState(null);
|
||||
const [showAddIcon, setShowAddIcon] = useState(true);
|
||||
const requestServer = useRequest({auth: true , notification: false})
|
||||
const requestServer = useRequest({auth: true, notification: false})
|
||||
const {update_notification} = useNotification()
|
||||
const [accordionStates, setAccordionStates] = useState([]);
|
||||
const [hasImageShown, setHasImageShown] = useState(false);
|
||||
@@ -46,7 +44,7 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type , han
|
||||
useEffect(() => {
|
||||
requestServer(`${CONFIRM_MACHINARY_OFFICE_DETAILS}/${rowId}`, 'get')
|
||||
.then((response) => {
|
||||
const booleanData = Array.from({ length: response.data.data.attachment_files.length }, () => false);
|
||||
const booleanData = Array.from({length: response.data.data.attachment_files.length}, () => false);
|
||||
setAccordionStates(booleanData);
|
||||
setDetailsData(response.data)
|
||||
})
|
||||
@@ -60,13 +58,11 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type , han
|
||||
const newAccordionStates = accordionStates.map((state, i) => i === index ? !state : false);
|
||||
setAccordionStates(newAccordionStates);
|
||||
|
||||
if (!newAccordionStates[index])
|
||||
{
|
||||
if (!newAccordionStates[index]) {
|
||||
handleSizeChangeClick('sm');
|
||||
setHasImageShown(false);
|
||||
setIsSkeleton(false)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
handleSizeChangeClick('xl');
|
||||
setHasImageShown(true);
|
||||
setImageLink(detailsList.data.attachment_files[index])
|
||||
@@ -75,14 +71,24 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type , han
|
||||
};
|
||||
|
||||
const validationSchema = Yup.object().shape({
|
||||
proposed_amount: Yup.mixed().test(
|
||||
"is-number",
|
||||
`${t("ConfirmDialog.proposed_amount_number")}`,
|
||||
(value) => !isNaN(value)
|
||||
).test("max-amount", `${t("MachinaryOffice.max_amount", {value: parseInt(vehicle_amount[vehicle_type]).toLocaleString('en')})}`,
|
||||
(value) => value <= vehicle_amount[vehicle_type])
|
||||
proposed_amount: Yup.mixed()
|
||||
.test(
|
||||
"is-number",
|
||||
`${t("ConfirmDialog.proposed_amount_number")}`,
|
||||
(value) => !isNaN(value)
|
||||
)
|
||||
.test("max-amount", `${t("MachinaryOffice.max_amount", {value: parseInt(vehicle_amount[vehicle_type]).toLocaleString('en')})}`,
|
||||
(value) => value <= vehicle_amount[vehicle_type])
|
||||
.test("positive", `${t("ConfirmDialog.proposed_amount_positive")}`, (value) => value >= 0)
|
||||
.required(t("ConfirmDialog.proposed_amount_error")),
|
||||
sakht_amount: Yup.mixed()
|
||||
.test("is-number", `${t("ConfirmDialog.sakht_amount_number")}`,
|
||||
(value) => !isNaN(value))
|
||||
.required(t("ConfirmDialog.sakht_amount_error")),
|
||||
tanafos_amount: Yup.mixed()
|
||||
.test("is-number", `${t("ConfirmDialog.tanafos_amount_number")}`,
|
||||
(value) => !isNaN(value))
|
||||
.required(t("ConfirmDialog.tanafos_amount_error")),
|
||||
confirm_img: Yup.mixed()
|
||||
.required(t("MachinaryOffice.upload_file_required"))
|
||||
.test('fileSize', `${t("MachinaryOffice.upload_file_unit")}`, (value) => {
|
||||
@@ -98,11 +104,15 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type , han
|
||||
initialValues: {
|
||||
description: "",
|
||||
proposed_amount: "",
|
||||
sakht_amount: "",
|
||||
tanafos_amount: "",
|
||||
confirm_img: null
|
||||
}, validationSchema,
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
formData.append("proposed_amount", values.proposed_amount);
|
||||
formData.append("sakht_amount", values.sakht_amount);
|
||||
formData.append("tanafos_amount", values.tanafos_amount);
|
||||
if (values.description != "") formData.append("expert_description", values.description);
|
||||
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
|
||||
requestServer(`${CONFIRM_MACHINARY_OFFICE}/${rowId}`, 'post', {
|
||||
@@ -166,7 +176,7 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type , han
|
||||
<DialogContent>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={hasImageShown ? 6 : 12}>
|
||||
{loading ? <LinearProgress /> : renderCustomAccordions()}
|
||||
{loading ? <LinearProgress/> : renderCustomAccordions()}
|
||||
<Stack spacing={2}>
|
||||
<Stack>
|
||||
<TextField
|
||||
@@ -208,6 +218,54 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type , han
|
||||
fullWidth
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="sakht_amount"
|
||||
label={t("ConfirmDialog.sakht_amount")}
|
||||
type={'number'}
|
||||
value={formik.values.sakht_amount}
|
||||
onChange={formik.handleChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{mt: 1}}
|
||||
onBlur={formik.handleBlur("sakht_amount")}
|
||||
error={
|
||||
formik.touched.sakht_amount &&
|
||||
Boolean(formik.errors.sakht_amount)
|
||||
}
|
||||
helperText={
|
||||
formik.touched.sakht_amount && formik.errors.sakht_amount
|
||||
}
|
||||
InputProps={{
|
||||
endAdornment: <InputAdornment
|
||||
position="end">{t("ConfirmDialog.sakht_amount_day")}</InputAdornment>,
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="tanafos_amount"
|
||||
label={t("ConfirmDialog.tanafos_amount")}
|
||||
type={'number'}
|
||||
value={formik.values.tanafos_amount}
|
||||
onChange={formik.handleChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{mt: 1}}
|
||||
onBlur={formik.handleBlur("tanafos_amount")}
|
||||
error={
|
||||
formik.touched.tanafos_amount &&
|
||||
Boolean(formik.errors.tanafos_amount)
|
||||
}
|
||||
helperText={
|
||||
formik.touched.tanafos_amount && formik.errors.tanafos_amount
|
||||
}
|
||||
InputProps={{
|
||||
endAdornment: <InputAdornment
|
||||
position="end">{t("ConfirmDialog.tanafos_amount_month")}</InputAdornment>,
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Typography>{t("MachinaryOffice.upload_file")}</Typography>
|
||||
<UploadSystem
|
||||
@@ -237,8 +295,13 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type , han
|
||||
</Stack>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Stack sx={{ display: hasImageShown ? 'flex' : 'none', alignItems: 'center', gap: 0.5 , justifyContent:'center'}}>
|
||||
<ImageContent imageLink={imageLink} isSkeleton={isSkeleton} setIsSkeleton={setIsSkeleton}/>
|
||||
<Stack sx={{
|
||||
display: hasImageShown ? 'flex' : 'none',
|
||||
alignItems: 'center',
|
||||
gap: 0.5,
|
||||
justifyContent: 'center'
|
||||
}}>
|
||||
<ImageContent imageLink={imageLink} isSkeleton={isSkeleton} setIsSkeleton={setIsSkeleton}/>
|
||||
</Stack>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
@@ -33,9 +33,15 @@ const Confirm = ({rowId, mutate, vehicle_type}) => {
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog fullWidth open={openConfirmDialog}
|
||||
PaperProps={{sx: {transition: 'all .3s' , boxShadow: 'rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px'}}} maxWidth={dialogSize}>
|
||||
PaperProps={{
|
||||
sx: {
|
||||
transition: 'all .3s',
|
||||
boxShadow: 'rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px'
|
||||
}
|
||||
}} maxWidth={dialogSize}>
|
||||
<DialogTitle>{t("MachinaryOffice.confirm")}</DialogTitle>
|
||||
<ConfirmContent mutate={mutate} rowId={rowId} setOpenConfirmDialog={setOpenConfirmDialog} handleSizeChangeClick={handleSizeChangeClick}
|
||||
<ConfirmContent mutate={mutate} rowId={rowId} setOpenConfirmDialog={setOpenConfirmDialog}
|
||||
handleSizeChangeClick={handleSizeChangeClick}
|
||||
vehicle_type={vehicle_type}/>
|
||||
</Dialog>
|
||||
</>
|
||||
|
||||
@@ -155,9 +155,14 @@ function DashboardMachinaryOfficeComponent() {
|
||||
],
|
||||
[]
|
||||
);
|
||||
const data = [{
|
||||
id: 1,
|
||||
vehicle_type: "مینی بوس"
|
||||
}]
|
||||
return (
|
||||
<Box sx={{px: 3}}>
|
||||
<DataTable
|
||||
data={data}
|
||||
tableUrl={GET_MACHINARY_OFFICE}
|
||||
columns={columns}
|
||||
selectableRow={false}
|
||||
|
||||
@@ -21,6 +21,7 @@ import PriceField from "@/core/components/PriceField";
|
||||
import * as Yup from "yup";
|
||||
import CustomAccordion from "@/core/components/CustomAccordion";
|
||||
import ImageContent from "@/core/components/ImageContent";
|
||||
import NumberShowBox from "@/core/components/NumberShowBox";
|
||||
|
||||
const vehicle_amount = {
|
||||
"اتوبوس": 7000,
|
||||
@@ -182,7 +183,11 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand
|
||||
<Grid item xs={hasImageShown ? 6 : 12}>
|
||||
{loading ? <LinearProgress/> :
|
||||
<>
|
||||
{numberShowBox()}
|
||||
<NumberShowBox
|
||||
showNumber={(detailsList?.data?.proposed_amount) / 10}
|
||||
headerTitle={t("ConfirmDialog.proposed_amount")}
|
||||
unitTitle={t("ConfirmDialog.unit")}
|
||||
/>
|
||||
{renderCustomAccordions()}
|
||||
</>
|
||||
}
|
||||
|
||||
@@ -175,9 +175,14 @@ function DashboardPassengerOfficeComponent() {
|
||||
],
|
||||
[]
|
||||
);
|
||||
const data = [{
|
||||
id: 1,
|
||||
vehicle_type: "مینی بوس"
|
||||
}]
|
||||
return (
|
||||
<Box sx={{px: 3}}>
|
||||
<DataTable
|
||||
data={data}
|
||||
tableUrl={GET_PASSENGER_BOSS}
|
||||
columns={columns}
|
||||
selectableRow={false}
|
||||
|
||||
20
src/core/components/NumberShowBox.jsx
Normal file
20
src/core/components/NumberShowBox.jsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import {Box, Typography} from "@mui/material";
|
||||
|
||||
const NumberShowBox = ({showNumber, headerTitle, unitTitle}) => {
|
||||
console.log({showNumber})
|
||||
return (
|
||||
<>
|
||||
<Box sx={{border: '1px solid #ccc', p: 2, mb: 2, borderRadius: '8px'}}>
|
||||
<Typography
|
||||
sx={{color: "primary.main", fontWeight: 500}}>{headerTitle}</Typography>
|
||||
<Typography pt={1}>
|
||||
{isNaN(showNumber)
|
||||
? ""
|
||||
: (showNumber).toLocaleString()}{" "}
|
||||
{unitTitle}
|
||||
</Typography>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default NumberShowBox
|
||||
Reference in New Issue
Block a user