Add: add colhouse fields to waiting bars
This commit is contained in:
@@ -977,6 +977,30 @@ export const CityNewKillRequest = ({
|
|||||||
<Typography>اطلاعات کشتار</Typography>
|
<Typography>اطلاعات کشتار</Typography>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<Grid
|
||||||
|
container
|
||||||
|
gap={SPACING.TINY}
|
||||||
|
justifyContent="start"
|
||||||
|
alignItems="center"
|
||||||
|
sx={{
|
||||||
|
border: "1px solid black",
|
||||||
|
borderRadius: 1,
|
||||||
|
p: 1.5,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
color={(prop) => prop.palette.grey["A700"]}
|
||||||
|
variant="caption"
|
||||||
|
>
|
||||||
|
سن (روز):
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="button">
|
||||||
|
{hatchingSelected?.age != null && hatchingSelected?.age !== ""
|
||||||
|
? Number(hatchingSelected.age).toLocaleString()
|
||||||
|
: "-"}
|
||||||
|
</Typography>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
{/* <Grid>
|
{/* <Grid>
|
||||||
<NumberInput
|
<NumberInput
|
||||||
allowLeadingZeros
|
allowLeadingZeros
|
||||||
@@ -2027,7 +2051,6 @@ export const CityNewKillRequest = ({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
disabled={freezing}
|
|
||||||
/>
|
/>
|
||||||
{!data?.approved &&
|
{!data?.approved &&
|
||||||
formik.values.avicultureSellType !== "goverment" && (
|
formik.values.avicultureSellType !== "goverment" && (
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import ResponsiveTable from "../../../../components/responsive-table/ResponsiveT
|
|||||||
import {
|
import {
|
||||||
LOADING_END,
|
LOADING_END,
|
||||||
LOADING_START,
|
LOADING_START,
|
||||||
OPEN_MODAL
|
OPEN_MODAL,
|
||||||
} from "../../../../lib/redux/slices/appSlice";
|
} from "../../../../lib/redux/slices/appSlice";
|
||||||
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
|
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
|
||||||
import { formatJustDate } from "../../../../utils/formatTime";
|
import { formatJustDate } from "../../../../utils/formatTime";
|
||||||
@@ -30,7 +30,7 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({
|
|||||||
withDate,
|
withDate,
|
||||||
selectedDate1,
|
selectedDate1,
|
||||||
selectedDate2,
|
selectedDate2,
|
||||||
searchValue
|
searchValue,
|
||||||
}) => {
|
}) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [openNotif] = useContext(AppContext);
|
const [openNotif] = useContext(AppContext);
|
||||||
@@ -43,7 +43,7 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({
|
|||||||
slaughterGetProfile({
|
slaughterGetProfile({
|
||||||
role_key: checkPathStartsWith("slaughter")
|
role_key: checkPathStartsWith("slaughter")
|
||||||
? selectedSubUser?.key || ""
|
? selectedSubUser?.key || ""
|
||||||
: ""
|
: "",
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}, [selectedSubUser?.key]);
|
}, [selectedSubUser?.key]);
|
||||||
@@ -93,7 +93,7 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({
|
|||||||
fetchSlaughterBroadcastAndProducts({
|
fetchSlaughterBroadcastAndProducts({
|
||||||
role_key: checkPathStartsWith("slaughter")
|
role_key: checkPathStartsWith("slaughter")
|
||||||
? selectedSubUser?.key || ""
|
? selectedSubUser?.key || ""
|
||||||
: ""
|
: "",
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -106,11 +106,11 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({
|
|||||||
selectedDate1,
|
selectedDate1,
|
||||||
selectedDate2,
|
selectedDate2,
|
||||||
searchValue,
|
searchValue,
|
||||||
selectedSubUser?.key
|
selectedSubUser?.key,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (refreshTrigger != null && refreshTrigger > 0) {
|
if (refreshTrigger !== null && refreshTrigger > 0) {
|
||||||
setPage(1);
|
setPage(1);
|
||||||
fetchApiData(1);
|
fetchApiData(1);
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({
|
|||||||
item={item}
|
item={item}
|
||||||
updateTable={updateTable}
|
updateTable={updateTable}
|
||||||
/>
|
/>
|
||||||
)
|
),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
@@ -169,7 +169,7 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({
|
|||||||
تایید / رد
|
تایید / رد
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</>
|
</>,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: "فایل اکسل در حال دانلود می باشد، این علمیات ممکن است زمان بر باشد لطفا صبر کنید.",
|
msg: "فایل اکسل در حال دانلود می باشد، این علمیات ممکن است زمان بر باشد لطفا صبر کنید.",
|
||||||
severity: "success"
|
severity: "success",
|
||||||
});
|
});
|
||||||
const link = `${
|
const link = `${
|
||||||
axios.defaults.baseURL
|
axios.defaults.baseURL
|
||||||
@@ -238,7 +238,7 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({
|
|||||||
"وزن لاشه (کیلوگرم)",
|
"وزن لاشه (کیلوگرم)",
|
||||||
"درصد افت",
|
"درصد افت",
|
||||||
"بارنامه",
|
"بارنامه",
|
||||||
"عملیات"
|
"عملیات",
|
||||||
]}
|
]}
|
||||||
handlePageChange={handlePageChange}
|
handlePageChange={handlePageChange}
|
||||||
totalRows={totalRows}
|
totalRows={totalRows}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
MenuItem,
|
MenuItem,
|
||||||
Select,
|
Select,
|
||||||
TextField,
|
TextField,
|
||||||
Tooltip
|
Tooltip,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { DatePicker } from "@mui/x-date-pickers";
|
import { DatePicker } from "@mui/x-date-pickers";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
@@ -18,7 +18,7 @@ import axios from "axios";
|
|||||||
import {
|
import {
|
||||||
LOADING_END,
|
LOADING_END,
|
||||||
LOADING_START,
|
LOADING_START,
|
||||||
OPEN_MODAL
|
OPEN_MODAL,
|
||||||
} from "../../../../lib/redux/slices/appSlice";
|
} from "../../../../lib/redux/slices/appSlice";
|
||||||
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
|
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
|
||||||
import ResponsiveTable from "../../../../components/responsive-table/ResponsiveTable";
|
import ResponsiveTable from "../../../../components/responsive-table/ResponsiveTable";
|
||||||
@@ -34,7 +34,7 @@ export const SlaughterInventoryInProvinceBars = ({
|
|||||||
useExternalFilters = false,
|
useExternalFilters = false,
|
||||||
filterValues = {},
|
filterValues = {},
|
||||||
onAfterUpdate,
|
onAfterUpdate,
|
||||||
refreshTrigger
|
refreshTrigger,
|
||||||
}) => {
|
}) => {
|
||||||
const [selectedDate1, setSelectedDate1] = useState(
|
const [selectedDate1, setSelectedDate1] = useState(
|
||||||
moment(new Date()).format("YYYY-MM-DD")
|
moment(new Date()).format("YYYY-MM-DD")
|
||||||
@@ -65,14 +65,14 @@ export const SlaughterInventoryInProvinceBars = ({
|
|||||||
selectedDate2: filterValues.selectedDate2 ?? selectedDate2,
|
selectedDate2: filterValues.selectedDate2 ?? selectedDate2,
|
||||||
withDate: filterValues.withDate ?? withDate,
|
withDate: filterValues.withDate ?? withDate,
|
||||||
textValue: filterValues.textValue ?? textValue,
|
textValue: filterValues.textValue ?? textValue,
|
||||||
quota: filterValues.quota ?? quota
|
quota: filterValues.quota ?? quota,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
selectedDate1,
|
selectedDate1,
|
||||||
selectedDate2,
|
selectedDate2,
|
||||||
withDate,
|
withDate,
|
||||||
textValue,
|
textValue,
|
||||||
quota
|
quota,
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchApiData = useCallback(
|
const fetchApiData = useCallback(
|
||||||
@@ -106,7 +106,9 @@ export const SlaughterInventoryInProvinceBars = ({
|
|||||||
perPage,
|
perPage,
|
||||||
type,
|
type,
|
||||||
dispatch,
|
dispatch,
|
||||||
selectedSubUser?.key
|
selectedSubUser?.key,
|
||||||
|
setData,
|
||||||
|
setTotalRows,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -151,7 +153,11 @@ export const SlaughterInventoryInProvinceBars = ({
|
|||||||
item?.killhouseUser?.name
|
item?.killhouseUser?.name
|
||||||
} (${item?.killhouseUser?.killHouseOperator?.user?.mobile})`,
|
} (${item?.killhouseUser?.killHouseOperator?.user?.mobile})`,
|
||||||
item?.poultryRequest?.poultryReqOrderCode,
|
item?.poultryRequest?.poultryReqOrderCode,
|
||||||
item?.freezing ? "انجماد" : item?.export ? "صادرات" : "عادی",
|
item?.poultryRequest?.freezing
|
||||||
|
? "انجماد"
|
||||||
|
: item?.poultryRequest?.export
|
||||||
|
? "صادرات"
|
||||||
|
: "عادی",
|
||||||
item?.killer
|
item?.killer
|
||||||
? `${item?.killer?.name} (${item?.killer?.killHouseOperator?.user?.mobile})`
|
? `${item?.killer?.name} (${item?.killer?.killHouseOperator?.user?.mobile})`
|
||||||
: "-",
|
: "-",
|
||||||
@@ -187,14 +193,14 @@ export const SlaughterInventoryInProvinceBars = ({
|
|||||||
updateTable={updateTable}
|
updateTable={updateTable}
|
||||||
item={item}
|
item={item}
|
||||||
/>
|
/>
|
||||||
)
|
),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SettingsIcon fontSize="small" />
|
<SettingsIcon fontSize="small" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -241,7 +247,7 @@ export const SlaughterInventoryInProvinceBars = ({
|
|||||||
padding: "10px",
|
padding: "10px",
|
||||||
borderRadius: "15px",
|
borderRadius: "15px",
|
||||||
borderColor: "gray",
|
borderColor: "gray",
|
||||||
justifyContent: "left"
|
justifyContent: "left",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{type === "notentered" && (
|
{type === "notentered" && (
|
||||||
@@ -356,7 +362,7 @@ export const SlaughterInventoryInProvinceBars = ({
|
|||||||
"درصد افت در لحظه",
|
"درصد افت در لحظه",
|
||||||
"درصد افت ورود به انبار",
|
"درصد افت ورود به انبار",
|
||||||
"تاریخ ورود به انبار",
|
"تاریخ ورود به انبار",
|
||||||
"عملیات"
|
"عملیات",
|
||||||
]}
|
]}
|
||||||
handlePageChange={handlePageChange}
|
handlePageChange={handlePageChange}
|
||||||
totalRows={totalRows}
|
totalRows={totalRows}
|
||||||
|
|||||||
@@ -6,8 +6,11 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
FormControl,
|
FormControl,
|
||||||
FormControlLabel,
|
FormControlLabel,
|
||||||
|
InputLabel,
|
||||||
|
MenuItem,
|
||||||
Radio,
|
Radio,
|
||||||
RadioGroup,
|
RadioGroup,
|
||||||
|
Select,
|
||||||
TextField,
|
TextField,
|
||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
@@ -19,6 +22,7 @@ import { AppContext } from "../../../../contexts/AppContext";
|
|||||||
import { provincePolicyGetDropLimitService } from "../../../province/services/province-policy-drop-limit";
|
import { provincePolicyGetDropLimitService } from "../../../province/services/province-policy-drop-limit";
|
||||||
import { fetchSlaughterBroadcastAndProducts } from "../../services/handle-fetch-slaughter-products";
|
import { fetchSlaughterBroadcastAndProducts } from "../../services/handle-fetch-slaughter-products";
|
||||||
import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";
|
import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";
|
||||||
|
import { liveStockGetInventoryData } from "../../../live-stock-support/services/live-stock-get-inventory-data";
|
||||||
|
|
||||||
export const SlaughterSubmitRealInventory = ({ item, updateTable }) => {
|
export const SlaughterSubmitRealInventory = ({ item, updateTable }) => {
|
||||||
const [value, setValue] = useState("weight");
|
const [value, setValue] = useState("weight");
|
||||||
@@ -33,6 +37,7 @@ export const SlaughterSubmitRealInventory = ({ item, updateTable }) => {
|
|||||||
const [inputWarehouse, setInputWarehouse] = useState(
|
const [inputWarehouse, setInputWarehouse] = useState(
|
||||||
item?.killer ? "killer" : "self"
|
item?.killer ? "killer" : "self"
|
||||||
);
|
);
|
||||||
|
const [coldHouses, setColdHouses] = useState([]);
|
||||||
|
|
||||||
const handleChangeInputWarehouse = (event) => {
|
const handleChangeInputWarehouse = (event) => {
|
||||||
setInputWarehouse(event.target.value);
|
setInputWarehouse(event.target.value);
|
||||||
@@ -52,6 +57,15 @@ export const SlaughterSubmitRealInventory = ({ item, updateTable }) => {
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (item?.poultryRequest?.freezing || item?.freezing) {
|
||||||
|
dispatch(liveStockGetInventoryData()).then((r) => {
|
||||||
|
const list = r.payload?.data ?? [];
|
||||||
|
setColdHouses(Array.isArray(list) ? list : list?.results ?? []);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [item?.poultryRequest?.freezing, item?.freezing, dispatch]);
|
||||||
|
|
||||||
const formik = useFormik({
|
const formik = useFormik({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
realNumber: item?.acceptedRealQuantity ? item?.acceptedRealQuantity : "",
|
realNumber: item?.acceptedRealQuantity ? item?.acceptedRealQuantity : "",
|
||||||
@@ -90,6 +104,52 @@ export const SlaughterSubmitRealInventory = ({ item, updateTable }) => {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const maxWeightForColdHouse =
|
||||||
|
value === "weight"
|
||||||
|
? formik.values.realWeight
|
||||||
|
? parseFloat(formik.values.realWeight)
|
||||||
|
: 0
|
||||||
|
: parseFloat(loss) || 0;
|
||||||
|
|
||||||
|
const formik3 = useFormik({
|
||||||
|
initialValues: {
|
||||||
|
coldHouseKey: "",
|
||||||
|
coldHouseTransferWeight: "",
|
||||||
|
},
|
||||||
|
validate: (values) => {
|
||||||
|
const errors = {};
|
||||||
|
if (!item?.poultryRequest?.freezing && !item?.freezing) return errors;
|
||||||
|
const w = values.coldHouseTransferWeight;
|
||||||
|
const hasFreezingWeight =
|
||||||
|
w !== "" && w !== undefined && w !== null && String(w).trim() !== "";
|
||||||
|
if (hasFreezingWeight) {
|
||||||
|
if (!values.coldHouseKey) {
|
||||||
|
errors.coldHouseKey =
|
||||||
|
"با وارد کردن وزن انتقالی، انتخاب سردخانه اجباری است!";
|
||||||
|
}
|
||||||
|
const num = Number(w);
|
||||||
|
if (Number.isNaN(num)) {
|
||||||
|
errors.coldHouseTransferWeight = "لطفا فیلد را به درستی وارد کنید!";
|
||||||
|
} else if (num < 0) {
|
||||||
|
errors.coldHouseTransferWeight = "مقدار نمیتواند منفی باشد";
|
||||||
|
} else if (num > maxWeightForColdHouse) {
|
||||||
|
errors.coldHouseTransferWeight =
|
||||||
|
"وزن انتقالی نباید بیشتر از وزن لاشه باشد!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return errors;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (
|
||||||
|
(item?.poultryRequest?.freezing || item?.freezing) &&
|
||||||
|
formik3.values.coldHouseTransferWeight
|
||||||
|
) {
|
||||||
|
formik3.validateForm();
|
||||||
|
}
|
||||||
|
}, [maxWeightForColdHouse]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (value === "weight") {
|
if (value === "weight") {
|
||||||
if (item?.acceptedRealWeight && formik.values.realWeight) {
|
if (item?.acceptedRealWeight && formik.values.realWeight) {
|
||||||
@@ -119,11 +179,20 @@ export const SlaughterSubmitRealInventory = ({ item, updateTable }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const isFormValid = () => {
|
const isFormValid = () => {
|
||||||
|
let base = false;
|
||||||
if (value === "weight") {
|
if (value === "weight") {
|
||||||
return formik.isValid && isLossInRange();
|
base = formik.isValid && isLossInRange();
|
||||||
} else {
|
} else {
|
||||||
return formik2.isValid;
|
base = formik2.isValid;
|
||||||
}
|
}
|
||||||
|
if (item?.poultryRequest?.freezing || item?.freezing) {
|
||||||
|
const hasFreezingWeight =
|
||||||
|
formik3.values.coldHouseTransferWeight !== "" &&
|
||||||
|
formik3.values.coldHouseTransferWeight !== null &&
|
||||||
|
String(formik3.values.coldHouseTransferWeight).trim() !== "";
|
||||||
|
return base && (!hasFreezingWeight || formik3.isValid);
|
||||||
|
}
|
||||||
|
return base;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
@@ -146,12 +215,19 @@ export const SlaughterSubmitRealInventory = ({ item, updateTable }) => {
|
|||||||
kill_house_request_key: item?.key,
|
kill_house_request_key: item?.key,
|
||||||
};
|
};
|
||||||
|
|
||||||
dispatch(
|
const submitPayload = {
|
||||||
killhouseSubmitRealInventoryService({
|
...payload,
|
||||||
...payload,
|
...(item?.killer ? { input_warehouse: inputWarehouse } : {}),
|
||||||
...(item?.killer ? { input_warehouse: inputWarehouse } : {}),
|
...((item?.poultryRequest?.freezing || item?.freezing) &&
|
||||||
})
|
formik3.values.coldHouseTransferWeight
|
||||||
).then((r) => {
|
? {
|
||||||
|
cold_house_key: formik3.values.coldHouseKey,
|
||||||
|
freezing_weight: parseFloat(formik3.values.coldHouseTransferWeight),
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
};
|
||||||
|
|
||||||
|
dispatch(killhouseSubmitRealInventoryService(submitPayload)).then((r) => {
|
||||||
if (r.payload.error) {
|
if (r.payload.error) {
|
||||||
openNotif({
|
openNotif({
|
||||||
vertical: "top",
|
vertical: "top",
|
||||||
@@ -381,6 +457,69 @@ export const SlaughterSubmitRealInventory = ({ item, updateTable }) => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</Grid>
|
</Grid>
|
||||||
|
{(item?.poultryRequest?.freezing || item?.freezing) && (
|
||||||
|
<Grid xs={12} container gap={2} alignItems="center" flexWrap="wrap">
|
||||||
|
<TextField
|
||||||
|
fullWidth
|
||||||
|
id="coldHouseTransferWeight"
|
||||||
|
size="small"
|
||||||
|
label="وزن انتقالی به سردخانه (کیلوگرم)"
|
||||||
|
variant="outlined"
|
||||||
|
value={formik3.values.coldHouseTransferWeight}
|
||||||
|
error={
|
||||||
|
formik3.touched.coldHouseTransferWeight
|
||||||
|
? Boolean(formik3.errors.coldHouseTransferWeight)
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
onChange={formik3.handleChange}
|
||||||
|
onBlur={formik3.handleBlur}
|
||||||
|
helperText={
|
||||||
|
formik3.touched.coldHouseTransferWeight &&
|
||||||
|
Boolean(formik3.errors.coldHouseTransferWeight)
|
||||||
|
? formik3.errors.coldHouseTransferWeight
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<FormControl fullWidth size="small">
|
||||||
|
<InputLabel id="cold-house-select-label">
|
||||||
|
انتخاب سردخانه
|
||||||
|
</InputLabel>
|
||||||
|
<Select
|
||||||
|
labelId="cold-house-select-label"
|
||||||
|
id="coldHouseKey"
|
||||||
|
name="coldHouseKey"
|
||||||
|
value={formik3.values.coldHouseKey}
|
||||||
|
label="انتخاب سردخانه"
|
||||||
|
onChange={formik3.handleChange}
|
||||||
|
onBlur={formik3.handleBlur}
|
||||||
|
error={
|
||||||
|
formik3.touched.coldHouseKey
|
||||||
|
? Boolean(formik3.errors.coldHouseKey)
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<MenuItem value="">
|
||||||
|
<em>انتخاب کنید</em>
|
||||||
|
</MenuItem>
|
||||||
|
{coldHouses?.map((ch, i) => (
|
||||||
|
<MenuItem key={ch?.key ?? i} value={ch?.key}>
|
||||||
|
سردخانه {ch?.name}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
{formik3.touched.coldHouseKey &&
|
||||||
|
formik3.errors.coldHouseKey && (
|
||||||
|
<Typography
|
||||||
|
variant="caption"
|
||||||
|
color="error"
|
||||||
|
sx={{ mt: 0.5, display: "block" }}
|
||||||
|
>
|
||||||
|
{formik3.errors.coldHouseKey}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
</FormControl>
|
||||||
|
</Grid>
|
||||||
|
)}
|
||||||
<Grid>
|
<Grid>
|
||||||
<Button
|
<Button
|
||||||
disabled={!isFormValid()}
|
disabled={!isFormValid()}
|
||||||
|
|||||||
@@ -433,6 +433,7 @@ export const AdminAddBuyerForm = ({
|
|||||||
value={formik.values.nationalId}
|
value={formik.values.nationalId}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
onBlur={formik.handleBlur}
|
onBlur={formik.handleBlur}
|
||||||
|
error={formik.errors.nationalId}
|
||||||
helperText={formik.touched.nationalId && formik.errors.nationalId}
|
helperText={formik.touched.nationalId && formik.errors.nationalId}
|
||||||
/>
|
/>
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
@@ -561,11 +562,7 @@ export const AdminAddBuyerForm = ({
|
|||||||
<TextField {...params} label="استان را انتخاب کنید" />
|
<TextField {...params} label="استان را انتخاب کنید" />
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{!notFound && (
|
|
||||||
<Typography variant="caption" color="error">
|
|
||||||
استان: {formik.values.province}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
{cityData && formik.values.province && (
|
{cityData && formik.values.province && (
|
||||||
<>
|
<>
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
@@ -592,12 +589,6 @@ export const AdminAddBuyerForm = ({
|
|||||||
<TextField {...params} label="شهر را انتخاب کنید" />
|
<TextField {...params} label="شهر را انتخاب کنید" />
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{!notFound && (
|
|
||||||
<Typography variant="caption" color="error">
|
|
||||||
شهر: {formik.values.city}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -6,19 +6,19 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
IconButton,
|
IconButton,
|
||||||
TextField,
|
TextField,
|
||||||
Typography
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import SearchIcon from "@mui/icons-material/Search";
|
import SearchIcon from "@mui/icons-material/Search";
|
||||||
import { Yup } from "../../../../lib/yup/yup";
|
import { Yup } from "../../../../lib/yup/yup";
|
||||||
import {
|
import {
|
||||||
slaughterGetCitiesService,
|
slaughterGetCitiesService,
|
||||||
slaughterGetProvinceService
|
slaughterGetProvinceService,
|
||||||
} from "../../../slaughter-house/services/slaughter-get-provinces";
|
} from "../../../slaughter-house/services/slaughter-get-provinces";
|
||||||
import { Grid } from "../../../../components/grid/Grid";
|
import { Grid } from "../../../../components/grid/Grid";
|
||||||
import { SPACING } from "../../../../data/spacing";
|
import { SPACING } from "../../../../data/spacing";
|
||||||
import {
|
import {
|
||||||
stewardSellOutGetBuyers,
|
stewardSellOutGetBuyers,
|
||||||
stewatdSubmitBuyerDataService
|
stewatdSubmitBuyerDataService,
|
||||||
} from "../../../guild/services/steward-sell-out-get-buyers";
|
} from "../../../guild/services/steward-sell-out-get-buyers";
|
||||||
import { DRAWER, LOADING_END } from "../../../../lib/redux/slices/appSlice";
|
import { DRAWER, LOADING_END } from "../../../../lib/redux/slices/appSlice";
|
||||||
import { slaughterEditBuyerDataService } from "../../../slaughter-house/services/slaughter-house-submit-buyer";
|
import { slaughterEditBuyerDataService } from "../../../slaughter-house/services/slaughter-house-submit-buyer";
|
||||||
@@ -29,7 +29,7 @@ import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";
|
|||||||
export const StewardSellOutOfProvinceAddBuyer = ({
|
export const StewardSellOutOfProvinceAddBuyer = ({
|
||||||
updateTable,
|
updateTable,
|
||||||
isEdit,
|
isEdit,
|
||||||
data
|
data,
|
||||||
}) => {
|
}) => {
|
||||||
const [openNotif] = useContext(AppContext);
|
const [openNotif] = useContext(AppContext);
|
||||||
const [userData, setUserData] = useState(null);
|
const [userData, setUserData] = useState(null);
|
||||||
@@ -48,7 +48,7 @@ export const StewardSellOutOfProvinceAddBuyer = ({
|
|||||||
lastName: "",
|
lastName: "",
|
||||||
unitName: "",
|
unitName: "",
|
||||||
province: "",
|
province: "",
|
||||||
city: ""
|
city: "",
|
||||||
},
|
},
|
||||||
validationSchema: Yup.object({
|
validationSchema: Yup.object({
|
||||||
mobile: Yup.string()
|
mobile: Yup.string()
|
||||||
@@ -70,22 +70,22 @@ export const StewardSellOutOfProvinceAddBuyer = ({
|
|||||||
.typeError("لطفا فیلد را به درستی وارد کنید!"),
|
.typeError("لطفا فیلد را به درستی وارد کنید!"),
|
||||||
city: Yup.string()
|
city: Yup.string()
|
||||||
.required("این فیلد اجباری است!")
|
.required("این فیلد اجباری است!")
|
||||||
.typeError("لطفا فیلد را به درستی وارد کنید!")
|
.typeError("لطفا فیلد را به درستی وارد کنید!"),
|
||||||
})
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const formik2 = useFormik({
|
const formik2 = useFormik({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
userInfoCheck: ""
|
userInfoCheck: "",
|
||||||
},
|
},
|
||||||
validationSchema: Yup.object({
|
validationSchema: Yup.object({
|
||||||
userInfoCheck: Yup.string()
|
userInfoCheck: Yup.string()
|
||||||
.required("این فیلد اجباری است!")
|
.required("این فیلد اجباری است!")
|
||||||
.min(11, "شماره موبایل باید 11 رقم باشد")
|
.min(11, "شماره موبایل باید 11 رقم باشد")
|
||||||
.max(11, "شماره موبایل باید 11 رقم باشد")
|
.max(11, "شماره موبایل باید 11 رقم باشد")
|
||||||
.matches(/^09\d{9}$/, "شماره موبایل باید با 09 شروع شود و 11 رقم باشد")
|
.matches(/^09\d{9}$/, "شماره موبایل باید با 09 شروع شود و 11 رقم باشد"),
|
||||||
}),
|
}),
|
||||||
validateOnMount: true
|
validateOnMount: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -100,7 +100,7 @@ export const StewardSellOutOfProvinceAddBuyer = ({
|
|||||||
lastName: userData.lastName || "",
|
lastName: userData.lastName || "",
|
||||||
unitName: userData.unitName || "",
|
unitName: userData.unitName || "",
|
||||||
province: userData.province || "",
|
province: userData.province || "",
|
||||||
city: userData.city || ""
|
city: userData.city || "",
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
formik.validateForm();
|
formik.validateForm();
|
||||||
@@ -116,7 +116,7 @@ export const StewardSellOutOfProvinceAddBuyer = ({
|
|||||||
lastName: data.lastName || "",
|
lastName: data.lastName || "",
|
||||||
unitName: data.unitName || "",
|
unitName: data.unitName || "",
|
||||||
province: data.province || "",
|
province: data.province || "",
|
||||||
city: data.city || ""
|
city: data.city || "",
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
formik.validateForm();
|
formik.validateForm();
|
||||||
@@ -194,7 +194,7 @@ export const StewardSellOutOfProvinceAddBuyer = ({
|
|||||||
mobile: formik2.values.userInfoCheck,
|
mobile: formik2.values.userInfoCheck,
|
||||||
role_key: checkPathStartsWith("steward")
|
role_key: checkPathStartsWith("steward")
|
||||||
? selectedSubUser?.key || ""
|
? selectedSubUser?.key || ""
|
||||||
: ""
|
: "",
|
||||||
})
|
})
|
||||||
).then((r) => {
|
).then((r) => {
|
||||||
dispatch(LOADING_END());
|
dispatch(LOADING_END());
|
||||||
@@ -205,7 +205,7 @@ export const StewardSellOutOfProvinceAddBuyer = ({
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: "خریدار یافت نشد، یک خریدار جدید ثبت کنید!",
|
msg: "خریدار یافت نشد، یک خریدار جدید ثبت کنید!",
|
||||||
severity: "error"
|
severity: "error",
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const responseData = r.payload?.data;
|
const responseData = r.payload?.data;
|
||||||
@@ -351,7 +351,7 @@ export const StewardSellOutOfProvinceAddBuyer = ({
|
|||||||
last_name: formik.values.lastName,
|
last_name: formik.values.lastName,
|
||||||
unit_name: formik.values.unitName,
|
unit_name: formik.values.unitName,
|
||||||
city: formik.values.city,
|
city: formik.values.city,
|
||||||
province: formik.values.province
|
province: formik.values.province,
|
||||||
})
|
})
|
||||||
).then((r) => {
|
).then((r) => {
|
||||||
updateTable();
|
updateTable();
|
||||||
@@ -360,7 +360,7 @@ export const StewardSellOutOfProvinceAddBuyer = ({
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: r.payload.error,
|
msg: r.payload.error,
|
||||||
severity: "error"
|
severity: "error",
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
dispatch(
|
dispatch(
|
||||||
@@ -371,7 +371,7 @@ export const StewardSellOutOfProvinceAddBuyer = ({
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: "عملیات با موفقیت انجام شد.",
|
msg: "عملیات با موفقیت انجام شد.",
|
||||||
severity: "success"
|
severity: "success",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -384,7 +384,7 @@ export const StewardSellOutOfProvinceAddBuyer = ({
|
|||||||
last_name: formik.values.lastName,
|
last_name: formik.values.lastName,
|
||||||
unit_name: formik.values.unitName,
|
unit_name: formik.values.unitName,
|
||||||
city: formik.values.city,
|
city: formik.values.city,
|
||||||
province: formik.values.province
|
province: formik.values.province,
|
||||||
})
|
})
|
||||||
).then((r) => {
|
).then((r) => {
|
||||||
updateTable();
|
updateTable();
|
||||||
@@ -393,7 +393,7 @@ export const StewardSellOutOfProvinceAddBuyer = ({
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: r.payload.error,
|
msg: r.payload.error,
|
||||||
severity: "error"
|
severity: "error",
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
dispatch(
|
dispatch(
|
||||||
@@ -404,7 +404,7 @@ export const StewardSellOutOfProvinceAddBuyer = ({
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: "عملیات با موفقیت انجام شد.",
|
msg: "عملیات با موفقیت انجام شد.",
|
||||||
severity: "success"
|
severity: "success",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user