fix: create guilds fix some
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
|||||||
Dialog,
|
Dialog,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
DialogActions,
|
DialogActions
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { Add as AddIcon } from "@mui/icons-material";
|
import { Add as AddIcon } from "@mui/icons-material";
|
||||||
import { Grid } from "../../../../components/grid/Grid";
|
import { Grid } from "../../../../components/grid/Grid";
|
||||||
@@ -22,8 +22,10 @@ import { provinceGetFieldOfWorks } from "../../services/ProvinceGetFieldOfWorks"
|
|||||||
import { provinceGetTypeActivity } from "../../services/provinceGetTypeActivity";
|
import { provinceGetTypeActivity } from "../../services/provinceGetTypeActivity";
|
||||||
import { provinceGetRegisterCodeStateService } from "../../services/province-get-register-code-state";
|
import { provinceGetRegisterCodeStateService } from "../../services/province-get-register-code-state";
|
||||||
import { mainGetGuildsForUpdateOrCreateService } from "../../services/main-get-guilds-for-update-or-create";
|
import { mainGetGuildsForUpdateOrCreateService } from "../../services/main-get-guilds-for-update-or-create";
|
||||||
import { cityGetProvinces } from "../../../city/services/CityGetProvinces";
|
import {
|
||||||
import { cityGetCity } from "../../../city/services/city-get-city";
|
slaughterGetProvinceService,
|
||||||
|
slaughterGetCitiesService
|
||||||
|
} from "../../../slaughter-house/services/slaughter-get-provinces";
|
||||||
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
|
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
|
||||||
import { PersonalInfoSection } from "./components/PersonalInfoSection";
|
import { PersonalInfoSection } from "./components/PersonalInfoSection";
|
||||||
import { InquiryForm } from "./components/InquiryForm";
|
import { InquiryForm } from "./components/InquiryForm";
|
||||||
@@ -34,7 +36,7 @@ import { GuildInfoAccordionItem } from "./components/GuildInfoAccordionItem";
|
|||||||
import { getValidationSchema, getInitialValues } from "./utils/formUtils";
|
import { getValidationSchema, getInitialValues } from "./utils/formUtils";
|
||||||
import {
|
import {
|
||||||
mapResponseDataToFormFields,
|
mapResponseDataToFormFields,
|
||||||
prepareSubmitData,
|
prepareSubmitData
|
||||||
} from "./utils/dataMapping";
|
} from "./utils/dataMapping";
|
||||||
import { handleSubmitSuccess, handleSubmitError } from "./utils/submitHandlers";
|
import { handleSubmitSuccess, handleSubmitError } from "./utils/submitHandlers";
|
||||||
|
|
||||||
@@ -121,7 +123,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
is_alive: values?.is_alive,
|
is_alive: values?.is_alive,
|
||||||
birth_date: values?.birth_date,
|
birth_date: values?.birth_date,
|
||||||
father_name: values?.father_name,
|
father_name: values?.father_name,
|
||||||
mobile: values?.mobile,
|
mobile: values?.mobile
|
||||||
};
|
};
|
||||||
return prepareSubmitData(
|
return prepareSubmitData(
|
||||||
combinedValues,
|
combinedValues,
|
||||||
@@ -146,7 +148,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -165,7 +167,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
setTypeActivities(r.payload.data || []);
|
setTypeActivities(r.payload.data || []);
|
||||||
});
|
});
|
||||||
// Fetch provinces for province/city selection
|
// Fetch provinces for province/city selection
|
||||||
dispatch(cityGetProvinces()).then((r) => {
|
dispatch(slaughterGetProvinceService()).then((r) => {
|
||||||
if (r?.payload?.data) {
|
if (r?.payload?.data) {
|
||||||
setProvinces(r.payload.data);
|
setProvinces(r.payload.data);
|
||||||
}
|
}
|
||||||
@@ -178,13 +180,13 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
const guildsForFormik = guildsList.map((guildItem) => {
|
const guildsForFormik = guildsList.map((guildItem) => {
|
||||||
const combinedGuild = {
|
const combinedGuild = {
|
||||||
...guildItem,
|
...guildItem,
|
||||||
user: guild?.user || {},
|
user: guild?.user || {}
|
||||||
};
|
};
|
||||||
const initialValues = getInitialValues(combinedGuild);
|
const initialValues = getInitialValues(combinedGuild);
|
||||||
return {
|
return {
|
||||||
steward: initialValues.steward || false,
|
steward: initialValues.steward || false,
|
||||||
guild: initialValues.guild || false,
|
guild: initialValues.guild || false,
|
||||||
license_number: initialValues.license_number ?? "",
|
license_number: initialValues.license_number ?? ""
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
formik.setFieldValue("guilds", guildsForFormik, false).then(() => {
|
formik.setFieldValue("guilds", guildsForFormik, false).then(() => {
|
||||||
@@ -208,10 +210,13 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
}
|
}
|
||||||
}, [provinces, formik.values.state, formik.values.province]);
|
}, [provinces, formik.values.state, formik.values.province]);
|
||||||
|
|
||||||
// Fetch cities when province is selected
|
// Fetch cities when province is selected (slaughter API uses province name)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (formik.values.province) {
|
if (formik.values.province) {
|
||||||
dispatch(cityGetCity(formik.values.province)).then((r) => {
|
const provinceName =
|
||||||
|
provinces.find((p) => p.key === formik.values.province)?.name ||
|
||||||
|
formik.values.province;
|
||||||
|
dispatch(slaughterGetCitiesService(provinceName)).then((r) => {
|
||||||
if (r?.payload?.data) {
|
if (r?.payload?.data) {
|
||||||
setProvinceCities(r.payload.data);
|
setProvinceCities(r.payload.data);
|
||||||
}
|
}
|
||||||
@@ -219,7 +224,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
} else {
|
} else {
|
||||||
setProvinceCities([]);
|
setProvinceCities([]);
|
||||||
}
|
}
|
||||||
}, [formik.values.province, dispatch]);
|
}, [formik.values.province, provinces, dispatch]);
|
||||||
|
|
||||||
// Set city ID from person_city name when provinceCities are loaded
|
// Set city ID from person_city name when provinceCities are loaded
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -262,7 +267,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
const initialGuildValues = guildsData.map((guildItem) => {
|
const initialGuildValues = guildsData.map((guildItem) => {
|
||||||
const combinedGuild = {
|
const combinedGuild = {
|
||||||
...guildItem,
|
...guildItem,
|
||||||
user: responseData.user || {},
|
user: responseData.user || {}
|
||||||
};
|
};
|
||||||
return getInitialValues(combinedGuild);
|
return getInitialValues(combinedGuild);
|
||||||
});
|
});
|
||||||
@@ -272,7 +277,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
const guildsForFormik = initialGuildValues.map((g) => ({
|
const guildsForFormik = initialGuildValues.map((g) => ({
|
||||||
steward: g.steward ?? false,
|
steward: g.steward ?? false,
|
||||||
guild: g.guild ?? false,
|
guild: g.guild ?? false,
|
||||||
license_number: g.license_number ?? "",
|
license_number: g.license_number ?? ""
|
||||||
}));
|
}));
|
||||||
formik.setFieldValue("guilds", guildsForFormik, true).then(() => {
|
formik.setFieldValue("guilds", guildsForFormik, true).then(() => {
|
||||||
formik.validateField("guilds");
|
formik.validateField("guilds");
|
||||||
@@ -302,7 +307,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: "لطفا کد ملی را وارد کنید",
|
msg: "لطفا کد ملی را وارد کنید",
|
||||||
severity: "error",
|
severity: "error"
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -312,7 +317,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: "لطفا کد ملی 10 رقمی معتبر وارد کنید",
|
msg: "لطفا کد ملی 10 رقمی معتبر وارد کنید",
|
||||||
severity: "error",
|
severity: "error"
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -320,7 +325,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
mainGetGuildsForUpdateOrCreateService({
|
mainGetGuildsForUpdateOrCreateService({
|
||||||
national_code: inquiryNationalCode,
|
national_code: inquiryNationalCode,
|
||||||
update: false,
|
update: false
|
||||||
})
|
})
|
||||||
).then((r) => {
|
).then((r) => {
|
||||||
if (r.payload.error) {
|
if (r.payload.error) {
|
||||||
@@ -333,7 +338,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: r.payload.error,
|
msg: r.payload.error,
|
||||||
severity: "error",
|
severity: "error"
|
||||||
});
|
});
|
||||||
if (!isAdmin) {
|
if (!isAdmin) {
|
||||||
return;
|
return;
|
||||||
@@ -357,7 +362,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: successMsg,
|
msg: successMsg,
|
||||||
severity: "success",
|
severity: "success"
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setHasInquiry(false);
|
setHasInquiry(false);
|
||||||
@@ -373,7 +378,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
openNotif,
|
openNotif,
|
||||||
mapResponseToFormFields,
|
mapResponseToFormFields,
|
||||||
isAdmin,
|
isAdmin,
|
||||||
formik,
|
formik
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const handleUpdateFromExternal = useCallback(() => {
|
const handleUpdateFromExternal = useCallback(() => {
|
||||||
@@ -382,7 +387,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: "لطفا کد ملی 10 رقمی معتبر وارد کنید",
|
msg: "لطفا کد ملی 10 رقمی معتبر وارد کنید",
|
||||||
severity: "error",
|
severity: "error"
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -390,7 +395,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
mainGetGuildsForUpdateOrCreateService({
|
mainGetGuildsForUpdateOrCreateService({
|
||||||
national_code: formik.values.national_id,
|
national_code: formik.values.national_id,
|
||||||
update: true,
|
update: true
|
||||||
})
|
})
|
||||||
).then((r) => {
|
).then((r) => {
|
||||||
if (r.payload.error) {
|
if (r.payload.error) {
|
||||||
@@ -399,7 +404,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: r.payload.error,
|
msg: r.payload.error,
|
||||||
severity: "error",
|
severity: "error"
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -407,7 +412,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
if (r.payload.data) {
|
if (r.payload.data) {
|
||||||
const updateResponse = {
|
const updateResponse = {
|
||||||
...r.payload.data,
|
...r.payload.data,
|
||||||
dbRegister: false,
|
dbRegister: false
|
||||||
};
|
};
|
||||||
mapResponseToFormFields(updateResponse);
|
mapResponseToFormFields(updateResponse);
|
||||||
setHasInquiry(true);
|
setHasInquiry(true);
|
||||||
@@ -416,7 +421,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: "اطلاعات از سامانه خارجی بروزرسانی شد",
|
msg: "اطلاعات از سامانه خارجی بروزرسانی شد",
|
||||||
severity: "success",
|
severity: "success"
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setHasInquiry(false);
|
setHasInquiry(false);
|
||||||
@@ -492,14 +497,14 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: r.payload.error,
|
msg: r.payload.error,
|
||||||
severity: "error",
|
severity: "error"
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
openNotif({
|
openNotif({
|
||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: "صنف با موفقیت حذف شد",
|
msg: "صنف با موفقیت حذف شد",
|
||||||
severity: "success",
|
severity: "success"
|
||||||
});
|
});
|
||||||
// Remove from list after successful deletion
|
// Remove from list after successful deletion
|
||||||
if (guildsList.length > 1) {
|
if (guildsList.length > 1) {
|
||||||
@@ -551,7 +556,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
}
|
}
|
||||||
newValues[index] = {
|
newValues[index] = {
|
||||||
...newValues[index],
|
...newValues[index],
|
||||||
[fieldName]: value,
|
[fieldName]: value
|
||||||
};
|
};
|
||||||
return newValues;
|
return newValues;
|
||||||
});
|
});
|
||||||
@@ -569,7 +574,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
}
|
}
|
||||||
updatedGuilds[index] = {
|
updatedGuilds[index] = {
|
||||||
...updatedGuilds[index],
|
...updatedGuilds[index],
|
||||||
[fieldName]: value,
|
[fieldName]: value
|
||||||
};
|
};
|
||||||
formik.setFieldValue("guilds", updatedGuilds, true).then(() => {
|
formik.setFieldValue("guilds", updatedGuilds, true).then(() => {
|
||||||
formik.validateField("guilds");
|
formik.validateField("guilds");
|
||||||
@@ -610,8 +615,8 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
: {
|
: {
|
||||||
xs: "96vw",
|
xs: "96vw",
|
||||||
md: "90vw",
|
md: "90vw",
|
||||||
nlg: "1280px",
|
nlg: "1280px"
|
||||||
},
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{shouldShowUpdateButton && (
|
{shouldShowUpdateButton && (
|
||||||
@@ -718,6 +723,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
<FormActions
|
<FormActions
|
||||||
formik={formik}
|
formik={formik}
|
||||||
onClose={() => dispatch(CLOSE_MODAL())}
|
onClose={() => dispatch(CLOSE_MODAL())}
|
||||||
|
guildsCount={guildsList.length}
|
||||||
showCloseButton={
|
showCloseButton={
|
||||||
!guild &&
|
!guild &&
|
||||||
hasInquiry === true &&
|
hasInquiry === true &&
|
||||||
@@ -728,7 +734,7 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
formData={guildsList.map((guildItem, index) => {
|
formData={guildsList.map((guildItem, index) => {
|
||||||
const guildValues = guildsFormValues[index];
|
const guildValues = guildsFormValues[index];
|
||||||
const combinedValues = {
|
const combinedValues = {
|
||||||
...guildValues, // Guild-specific info (overrides if same keys exist)
|
...guildValues // Guild-specific info (overrides if same keys exist)
|
||||||
};
|
};
|
||||||
return prepareSubmitData(
|
return prepareSubmitData(
|
||||||
combinedValues,
|
combinedValues,
|
||||||
|
|||||||
@@ -2,12 +2,75 @@ import React from "react";
|
|||||||
import { Button, Typography, Checkbox, FormControlLabel } from "@mui/material";
|
import { Button, Typography, Checkbox, FormControlLabel } from "@mui/material";
|
||||||
import { Grid } from "../../../../../components/grid/Grid";
|
import { Grid } from "../../../../../components/grid/Grid";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the appropriate error message from formik.errors.guilds.
|
||||||
|
* guilds can be: string (array-level) | array of guild error objects
|
||||||
|
*/
|
||||||
|
const getGuildsErrorMessage = (guildsError) => {
|
||||||
|
if (!guildsError) return null;
|
||||||
|
if (typeof guildsError === "string") return guildsError;
|
||||||
|
if (Array.isArray(guildsError)) {
|
||||||
|
for (let i = 0; i < guildsError.length; i++) {
|
||||||
|
const guildError = guildsError[i];
|
||||||
|
if (!guildError) continue;
|
||||||
|
if (typeof guildError === "string") return guildError;
|
||||||
|
if (typeof guildError === "object") {
|
||||||
|
const firstValue = Object.values(guildError)[0];
|
||||||
|
if (typeof firstValue === "string") return firstValue;
|
||||||
|
if (typeof firstValue === "object" && firstValue?.message)
|
||||||
|
return firstValue.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const MIN_GUILDS_ERROR = "حداقل یک واحد صنفی باید وجود داشته باشد";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects all blocking error messages to show under submit button.
|
||||||
|
* Suppresses "حداقل یک واحد صنفی..." when we have guild data (race condition:
|
||||||
|
* formik.values.guilds may lag behind guildsList after inquiry).
|
||||||
|
*/
|
||||||
|
const getBlockingErrors = (
|
||||||
|
formik,
|
||||||
|
isKillHouse,
|
||||||
|
isAreaActivityValid,
|
||||||
|
guildsCount = 0
|
||||||
|
) => {
|
||||||
|
const errors = [];
|
||||||
|
|
||||||
|
if (formik.errors.isAccepted) {
|
||||||
|
errors.push(formik.errors.isAccepted);
|
||||||
|
}
|
||||||
|
if (formik.errors.national_id) {
|
||||||
|
errors.push(formik.errors.national_id);
|
||||||
|
}
|
||||||
|
if (formik.errors.mobile) {
|
||||||
|
errors.push(formik.errors.mobile);
|
||||||
|
}
|
||||||
|
if (isKillHouse && !isAreaActivityValid) {
|
||||||
|
errors.push('رسته واحد صنفی باید شامل کلمه "مرغ" باشد');
|
||||||
|
}
|
||||||
|
const guildsMsg = getGuildsErrorMessage(formik.errors.guilds);
|
||||||
|
if (guildsMsg) {
|
||||||
|
if (guildsMsg === MIN_GUILDS_ERROR && guildsCount > 0) {
|
||||||
|
// User has guilds from inquiry/edit - suppress stale "no guilds" error
|
||||||
|
} else {
|
||||||
|
errors.push(guildsMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors;
|
||||||
|
};
|
||||||
|
|
||||||
export const FormActions = ({
|
export const FormActions = ({
|
||||||
formik,
|
formik,
|
||||||
onClose,
|
onClose,
|
||||||
showCloseButton,
|
showCloseButton,
|
||||||
isKillHouse,
|
isKillHouse,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
|
guildsCount = 0
|
||||||
}) => {
|
}) => {
|
||||||
if (showCloseButton) {
|
if (showCloseButton) {
|
||||||
return (
|
return (
|
||||||
@@ -23,9 +86,21 @@ export const FormActions = ({
|
|||||||
? formik.values.area_activity && formik.values.area_activity.includes("مرغ")
|
? formik.values.area_activity && formik.values.area_activity.includes("مرغ")
|
||||||
: true;
|
: true;
|
||||||
|
|
||||||
// Check if guilds validation has errors
|
const guildsErrorRaw = formik.errors.guilds;
|
||||||
const hasGuildsError = formik.errors.guilds;
|
const isStaleMinGuildsError =
|
||||||
const hasGuilds = formik.values.guilds && formik.values.guilds.length > 0;
|
guildsCount > 0 &&
|
||||||
|
typeof guildsErrorRaw === "string" &&
|
||||||
|
guildsErrorRaw === MIN_GUILDS_ERROR;
|
||||||
|
const hasGuildsError = guildsErrorRaw && !isStaleMinGuildsError;
|
||||||
|
const hasGuilds =
|
||||||
|
(formik.values.guilds && formik.values.guilds.length > 0) ||
|
||||||
|
guildsCount > 0;
|
||||||
|
const blockingErrors = getBlockingErrors(
|
||||||
|
formik,
|
||||||
|
isKillHouse,
|
||||||
|
isAreaActivityValid,
|
||||||
|
guildsCount
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -59,24 +134,18 @@ export const FormActions = ({
|
|||||||
>
|
>
|
||||||
ثبت
|
ثبت
|
||||||
</Button>
|
</Button>
|
||||||
{isKillHouse && !isAreaActivityValid && (
|
{blockingErrors.length > 0 && (
|
||||||
<Typography
|
<Typography
|
||||||
|
component="div"
|
||||||
variant="caption"
|
variant="caption"
|
||||||
color="error"
|
color="error"
|
||||||
sx={{ mt: 1, display: "block" }}
|
sx={{ mt: 1, display: "block" }}
|
||||||
>
|
>
|
||||||
رسته واحد صنفی باید شامل کلمه "مرغ" باشد
|
{blockingErrors.map((msg, i) => (
|
||||||
</Typography>
|
<span key={i} style={{ display: "block" }}>
|
||||||
)}
|
• {msg}
|
||||||
{hasGuildsError && (
|
</span>
|
||||||
<Typography
|
))}
|
||||||
variant="caption"
|
|
||||||
color="error"
|
|
||||||
sx={{ mt: 1, display: "block" }}
|
|
||||||
>
|
|
||||||
{typeof formik.errors.guilds === "string"
|
|
||||||
? formik.errors.guilds
|
|
||||||
: "برای هر واحد صنفی، حداقل یکی از گزینههای مباشر یا صنف باید انتخاب شود"}
|
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export const prepareSubmitData = (
|
|||||||
title: values.guild_name || "",
|
title: values.guild_name || "",
|
||||||
role: getRoleFromUrl(),
|
role: getRoleFromUrl(),
|
||||||
has_inquiry: hasInquiry !== null ? hasInquiry : false,
|
has_inquiry: hasInquiry !== null ? hasInquiry : false,
|
||||||
...(values.active !== null && { active: values.active }),
|
...(values.active !== null && { active: values.active })
|
||||||
};
|
};
|
||||||
|
|
||||||
if (guild) {
|
if (guild) {
|
||||||
@@ -159,12 +159,12 @@ const extractFormFieldsFromDatabaseInquiry = (
|
|||||||
guild_national_id: firstGuildFromDb.nationalCode || "",
|
guild_national_id: firstGuildFromDb.nationalCode || "",
|
||||||
corporation_name: firstGuildFromDb.companyName || "",
|
corporation_name: firstGuildFromDb.companyName || "",
|
||||||
|
|
||||||
// Status Fields
|
// Status Fields (is_foreign_national is at guild level in API response)
|
||||||
is_foreigner:
|
is_foreigner:
|
||||||
responseDataFromDb.isForeignNational === false
|
firstGuildFromDb.isForeignNational === true
|
||||||
? false
|
? "بلی"
|
||||||
: responseDataFromDb.isForeignNational === true
|
: firstGuildFromDb.isForeignNational === false
|
||||||
? true
|
? "خیر"
|
||||||
: "",
|
: "",
|
||||||
has_steward:
|
has_steward:
|
||||||
responseDataFromDb.steward === false
|
responseDataFromDb.steward === false
|
||||||
@@ -187,7 +187,7 @@ const extractFormFieldsFromDatabaseInquiry = (
|
|||||||
// Additional Database Fields
|
// Additional Database Fields
|
||||||
company_name: firstGuildFromDb.companyName || "",
|
company_name: firstGuildFromDb.companyName || "",
|
||||||
company_identifier: firstGuildFromDb.companyIdentifier || "",
|
company_identifier: firstGuildFromDb.companyIdentifier || "",
|
||||||
type_activity_name: firstGuildFromDb.typeActivity || "",
|
type_activity_name: firstGuildFromDb.typeActivity || ""
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ const extractFormFieldsFromExternalApi = (
|
|||||||
guild:
|
guild:
|
||||||
typeof firstGuildFromExternalApi.guild === "boolean"
|
typeof firstGuildFromExternalApi.guild === "boolean"
|
||||||
? firstGuildFromExternalApi.guild
|
? firstGuildFromExternalApi.guild
|
||||||
: false,
|
: false
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -48,14 +48,14 @@ export const getValidationSchema = (isEditMode) =>
|
|||||||
license_number: yup.string().required("شماره مجوز الزامی است"),
|
license_number: yup.string().required("شماره مجوز الزامی است"),
|
||||||
|
|
||||||
steward: yup.boolean(),
|
steward: yup.boolean(),
|
||||||
guild: yup.boolean(),
|
guild: yup.boolean()
|
||||||
})
|
})
|
||||||
.test(
|
.test(
|
||||||
"steward-guild-required",
|
"steward-guild-required",
|
||||||
"برای هر واحد صنفی، حداقل یکی از گزینههای مباشر یا صنف باید انتخاب شود",
|
"برای هر واحد صنفی، حداقل یکی از گزینههای مباشر یا صنف باید انتخاب شود",
|
||||||
(value) => value?.steward === true || value?.guild === true
|
(value) => value?.steward === true || value?.guild === true
|
||||||
)
|
)
|
||||||
),
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,7 +110,12 @@ export const getInitialValues = (guildDataForEdit) => {
|
|||||||
),
|
),
|
||||||
|
|
||||||
// Status Fields (from guild object in edit mode)
|
// Status Fields (from guild object in edit mode)
|
||||||
is_foreigner: guildDataForEdit?.is_foreign_national || "",
|
is_foreigner:
|
||||||
|
guildDataForEdit?.isForeignNational === true
|
||||||
|
? "بلی"
|
||||||
|
: guildDataForEdit?.isForeignNational === false
|
||||||
|
? "خیر"
|
||||||
|
: "",
|
||||||
has_steward: guildDataForEdit?.hasSteward || "",
|
has_steward: guildDataForEdit?.hasSteward || "",
|
||||||
has_partner: guildDataForEdit?.hasPartner || "",
|
has_partner: guildDataForEdit?.hasPartner || "",
|
||||||
steward:
|
steward:
|
||||||
@@ -149,9 +154,9 @@ export const getInitialValues = (guildDataForEdit) => {
|
|||||||
? guildDataForEdit.guild
|
? guildDataForEdit.guild
|
||||||
: typeof guildDataForEdit?.isGuild === "boolean"
|
: typeof guildDataForEdit?.isGuild === "boolean"
|
||||||
? guildDataForEdit.isGuild
|
? guildDataForEdit.isGuild
|
||||||
: false,
|
: false
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
: [],
|
: []
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export const ManageGuilds = ({ userType }) => {
|
|||||||
is_real_person: true,
|
is_real_person: true,
|
||||||
role_key: checkPathStartsWith("province")
|
role_key: checkPathStartsWith("province")
|
||||||
? selectedSubUser?.key || ""
|
? selectedSubUser?.key || ""
|
||||||
: "",
|
: ""
|
||||||
})
|
})
|
||||||
: provinceGetTotalGuildsService({
|
: provinceGetTotalGuildsService({
|
||||||
search: "filter",
|
search: "filter",
|
||||||
@@ -61,7 +61,7 @@ export const ManageGuilds = ({ userType }) => {
|
|||||||
is_real_person: true,
|
is_real_person: true,
|
||||||
role_key: checkPathStartsWith("province")
|
role_key: checkPathStartsWith("province")
|
||||||
? selectedSubUser?.key || ""
|
? selectedSubUser?.key || ""
|
||||||
: "",
|
: ""
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -119,64 +119,78 @@ export const ManageGuilds = ({ userType }) => {
|
|||||||
item?.limitationAllocation ? "دارد" : "ندارد",
|
item?.limitationAllocation ? "دارد" : "ندارد",
|
||||||
item?.allocationLimit ? item?.allocationLimit : "-",
|
item?.allocationLimit ? item?.allocationLimit : "-",
|
||||||
item?.getPosStatus?.hasActivePons ? "دارد" : "ندارد",
|
item?.getPosStatus?.hasActivePons ? "دارد" : "ندارد",
|
||||||
item?.getPosStatus?.lenActiveSessions || "-",
|
item?.getPosStatus?.lenActiveSessions || "-"
|
||||||
];
|
];
|
||||||
|
|
||||||
if (getRoleFromUrl() !== "KillHouse") {
|
if (getRoleFromUrl() !== "KillHouse") {
|
||||||
commonData.push(
|
commonData.push(
|
||||||
<Button
|
(item?.stewards?.length || 0) === 0 ? (
|
||||||
key={`stewards-${i}`}
|
"ندارد"
|
||||||
onClick={() => {
|
) : (
|
||||||
const tableData = item?.stewards?.map((option, index) => [
|
<Button
|
||||||
index + 1,
|
key={`stewards-${i}`}
|
||||||
option?.guildsName || "-",
|
variant="outlined"
|
||||||
option?.user?.mobile || "-",
|
size="small"
|
||||||
]);
|
sx={{ whiteSpace: "nowrap", fontSize: "0.8125rem" }}
|
||||||
dispatch(
|
onClick={() => {
|
||||||
OPEN_MODAL({
|
const tableData = item?.stewards?.map((option, index) => [
|
||||||
title: IS_STEWARD ? "مباشرین" : "اصناف",
|
index + 1,
|
||||||
content: (
|
option?.guildsName || "-",
|
||||||
<SimpleTable
|
option?.user?.mobile || "-"
|
||||||
paginated
|
]);
|
||||||
title={IS_STEWARD ? "مباشرین" : "اصناف"}
|
dispatch(
|
||||||
columns={["ردیف", "نام و نام خانوادگی", "تلفن"]}
|
OPEN_MODAL({
|
||||||
data={tableData}
|
title: IS_STEWARD ? "مباشرین" : "اصناف",
|
||||||
/>
|
content: (
|
||||||
),
|
<SimpleTable
|
||||||
})
|
paginated
|
||||||
);
|
title={IS_STEWARD ? "مباشرین" : "اصناف"}
|
||||||
}}
|
columns={["ردیف", "نام و نام خانوادگی", "تلفن"]}
|
||||||
>
|
data={tableData}
|
||||||
نمایش ({item?.stewards?.length || 0})
|
/>
|
||||||
</Button>
|
)
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
نمایش ({item?.stewards?.length || 0})
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
commonData.push(
|
commonData.push(
|
||||||
<Button
|
(item?.killHouse?.length || 0) === 0 ? (
|
||||||
key={`killHouse-${i}`}
|
"ندارد"
|
||||||
onClick={() => {
|
) : (
|
||||||
const tableData = item?.killHouse?.map((option, index) => [
|
<Button
|
||||||
index + 1,
|
key={`killHouse-${i}`}
|
||||||
option?.name || "-",
|
variant="outlined"
|
||||||
option?.killHouseOperator?.user?.mobile || "-",
|
size="small"
|
||||||
]);
|
sx={{ whiteSpace: "nowrap", fontSize: "0.8125rem" }}
|
||||||
dispatch(
|
onClick={() => {
|
||||||
OPEN_MODAL({
|
const tableData = item?.killHouse?.map((option, index) => [
|
||||||
title: "کشتارگاه ها",
|
index + 1,
|
||||||
content: (
|
option?.name || "-",
|
||||||
<SimpleTable
|
option?.killHouseOperator?.user?.mobile || "-"
|
||||||
paginated
|
]);
|
||||||
title={"کشتارگاه ها"}
|
dispatch(
|
||||||
columns={["ردیف", "نام و نام خانوادگی", "تلفن"]}
|
OPEN_MODAL({
|
||||||
data={tableData}
|
title: "کشتارگاه ها",
|
||||||
/>
|
content: (
|
||||||
),
|
<SimpleTable
|
||||||
})
|
paginated
|
||||||
);
|
title={"کشتارگاه ها"}
|
||||||
}}
|
columns={["ردیف", "نام و نام خانوادگی", "تلفن"]}
|
||||||
>
|
data={tableData}
|
||||||
نمایش ({item?.killHouse?.length || 0})
|
/>
|
||||||
</Button>
|
)
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
نمایش ({item?.killHouse?.length || 0})
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +256,7 @@ export const ManageGuilds = ({ userType }) => {
|
|||||||
is_real_person: true,
|
is_real_person: true,
|
||||||
role_key: checkPathStartsWith("province")
|
role_key: checkPathStartsWith("province")
|
||||||
? selectedSubUser?.key || ""
|
? selectedSubUser?.key || ""
|
||||||
: "",
|
: ""
|
||||||
})
|
})
|
||||||
: provinceGetTotalGuildsService({
|
: provinceGetTotalGuildsService({
|
||||||
search: "filter",
|
search: "filter",
|
||||||
@@ -254,7 +268,7 @@ export const ManageGuilds = ({ userType }) => {
|
|||||||
is_real_person: true,
|
is_real_person: true,
|
||||||
role_key: checkPathStartsWith("province")
|
role_key: checkPathStartsWith("province")
|
||||||
? selectedSubUser?.key || ""
|
? selectedSubUser?.key || ""
|
||||||
: "",
|
: ""
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -295,7 +309,7 @@ export const ManageGuilds = ({ userType }) => {
|
|||||||
bottom: window.innerWidth <= 600,
|
bottom: window.innerWidth <= 600,
|
||||||
size: window.innerWidth <= 600 ? "small" : "auto",
|
size: window.innerWidth <= 600 ? "small" : "auto",
|
||||||
title: `ثبت ${IS_STEWARD ? "مباشر" : "صنف"} جدید`,
|
title: `ثبت ${IS_STEWARD ? "مباشر" : "صنف"} جدید`,
|
||||||
content: <CreateGuilds updateTable={updateTable} />,
|
content: <CreateGuilds updateTable={updateTable} />
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
@@ -394,7 +408,7 @@ export const ManageGuilds = ({ userType }) => {
|
|||||||
"مباشرین",
|
"مباشرین",
|
||||||
"وضعیت فعالیت",
|
"وضعیت فعالیت",
|
||||||
"وضعیت",
|
"وضعیت",
|
||||||
"کشتارگاه ها",
|
"کشتارگاه ها"
|
||||||
]
|
]
|
||||||
: getRoleFromUrl() === "KillHouse"
|
: getRoleFromUrl() === "KillHouse"
|
||||||
? [
|
? [
|
||||||
@@ -415,7 +429,7 @@ export const ManageGuilds = ({ userType }) => {
|
|||||||
"وضعیت کارتخوان",
|
"وضعیت کارتخوان",
|
||||||
"تعداد کارتخوان ",
|
"تعداد کارتخوان ",
|
||||||
"وضعیت فعالیت",
|
"وضعیت فعالیت",
|
||||||
"وضعیت",
|
"وضعیت"
|
||||||
// "عملیات",
|
// "عملیات",
|
||||||
]
|
]
|
||||||
: [
|
: [
|
||||||
@@ -442,7 +456,7 @@ export const ManageGuilds = ({ userType }) => {
|
|||||||
"کشتارگاه ها",
|
"کشتارگاه ها",
|
||||||
"وضعیت فعالیت",
|
"وضعیت فعالیت",
|
||||||
"وضعیت",
|
"وضعیت",
|
||||||
"عملیات",
|
"عملیات"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
handlePageChange={handlePageChange}
|
handlePageChange={handlePageChange}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ export const slaughterGetCitiesService = createAsyncThunk(
|
|||||||
dispatch(LOADING_START());
|
dispatch(LOADING_START());
|
||||||
const { data, status } = await axios.get("iran_city/?name=" + d);
|
const { data, status } = await axios.get("iran_city/?name=" + d);
|
||||||
dispatch(LOADING_END());
|
dispatch(LOADING_END());
|
||||||
|
|
||||||
return { data, status };
|
return { data, status };
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ import {
|
|||||||
ROUTE_ADMINX_ROUTE_OUT_PROVINCE_TRUE_GUILDS,
|
ROUTE_ADMINX_ROUTE_OUT_PROVINCE_TRUE_GUILDS,
|
||||||
ROUTE_SLAUGHTER_INVENTORY_SELL_CARCASS_OUT_PROVINCE,
|
ROUTE_SLAUGHTER_INVENTORY_SELL_CARCASS_OUT_PROVINCE,
|
||||||
ROUTE_SLAUGHTER_MANAGE_GUILDS_OUT_PROVINCE_TRUE,
|
ROUTE_SLAUGHTER_MANAGE_GUILDS_OUT_PROVINCE_TRUE,
|
||||||
ROUTE_STEWARD_SALE_OUT_PROVINCE,
|
ROUTE_STEWARD_SALE_OUT_PROVINCE
|
||||||
} from "../../../../routes/routes";
|
} from "../../../../routes/routes";
|
||||||
import {
|
import {
|
||||||
handleSetFormDataFromTableDataForStewardAddBuyer,
|
handleSetFormDataFromTableDataForStewardAddBuyer,
|
||||||
handleSubmitForStewardAddBuyer,
|
handleSubmitForStewardAddBuyer,
|
||||||
InquiryForStewardAddBuyer,
|
InquiryForStewardAddBuyer,
|
||||||
StewardAddBuyerForm,
|
StewardAddBuyerForm,
|
||||||
validationSchemaForStewardAddBuyer,
|
validationSchemaForStewardAddBuyer
|
||||||
} from "./InquiryForStewardAddBuyer";
|
} from "./InquiryForStewardAddBuyer";
|
||||||
import { useAddBuyer } from "./hooks/useAddBuyer";
|
import { useAddBuyer } from "./hooks/useAddBuyer";
|
||||||
import { slaughterGetCitiesService } from "../../../slaughter-house/services/slaughter-get-provinces";
|
import { slaughterGetCitiesService } from "../../../slaughter-house/services/slaughter-get-provinces";
|
||||||
@@ -30,7 +30,7 @@ import {
|
|||||||
handleSubmitForSlaughterAddBuyer,
|
handleSubmitForSlaughterAddBuyer,
|
||||||
InquiryForSlaughterAddBuyer,
|
InquiryForSlaughterAddBuyer,
|
||||||
SlaughterAddBuyerForm,
|
SlaughterAddBuyerForm,
|
||||||
validationSchemaForSlaughterAddBuyer,
|
validationSchemaForSlaughterAddBuyer
|
||||||
} from "./InquiryForSlaughterAddBuyer";
|
} from "./InquiryForSlaughterAddBuyer";
|
||||||
import { useFormik } from "formik";
|
import { useFormik } from "formik";
|
||||||
import {
|
import {
|
||||||
@@ -38,7 +38,7 @@ import {
|
|||||||
handleSetFormDataFromTableDataForAdminAddBuyer,
|
handleSetFormDataFromTableDataForAdminAddBuyer,
|
||||||
handleSubmitForAdminAddBuyer,
|
handleSubmitForAdminAddBuyer,
|
||||||
InquiryForAdminAddBuyer,
|
InquiryForAdminAddBuyer,
|
||||||
validationSchemaForAdminAddBuyer,
|
validationSchemaForAdminAddBuyer
|
||||||
} from "./InquiryForAdminAddBuyer";
|
} from "./InquiryForAdminAddBuyer";
|
||||||
import { inspectorGetKillHousesService } from "../../../inspector/services/inspector-get-kill-houses";
|
import { inspectorGetKillHousesService } from "../../../inspector/services/inspector-get-kill-houses";
|
||||||
import { slaughterGetStewardsForAllocateService } from "../../../slaughter-house/services/slaughter-get-guilds-for-allocate";
|
import { slaughterGetStewardsForAllocateService } from "../../../slaughter-house/services/slaughter-get-guilds-for-allocate";
|
||||||
@@ -64,7 +64,7 @@ const getCurrentPage = (role, pathname) => {
|
|||||||
ROUTE_ADMINX_ROUTE_OUT_PROVINCE_TRUE_GUILDS,
|
ROUTE_ADMINX_ROUTE_OUT_PROVINCE_TRUE_GUILDS,
|
||||||
ROUTE_ADMINX_ROUTE_OUT_PROVINCE_LEGAL_GUILDS,
|
ROUTE_ADMINX_ROUTE_OUT_PROVINCE_LEGAL_GUILDS,
|
||||||
ROUTE_ADMINX_ROUTE_MANAGE_STEWARDS_OUT_PROVINCE_LEGAL,
|
ROUTE_ADMINX_ROUTE_MANAGE_STEWARDS_OUT_PROVINCE_LEGAL,
|
||||||
ROUTE_ADMINX_ROUTE_MANAGE_STEWARDS_OUT_PROVINCE_TRUE,
|
ROUTE_ADMINX_ROUTE_MANAGE_STEWARDS_OUT_PROVINCE_TRUE
|
||||||
];
|
];
|
||||||
if (routes.some((r) => r === pathname)) {
|
if (routes.some((r) => r === pathname)) {
|
||||||
return "admin_add_buyer";
|
return "admin_add_buyer";
|
||||||
@@ -79,20 +79,20 @@ const getInitialValues = (page) => {
|
|||||||
lastName: "",
|
lastName: "",
|
||||||
unit_name: "",
|
unit_name: "",
|
||||||
province: "",
|
province: "",
|
||||||
city: "",
|
city: ""
|
||||||
};
|
};
|
||||||
if (page === "steward_add_buyer" || page === "slaughter_manage_add_buyer") {
|
if (page === "steward_add_buyer" || page === "slaughter_manage_add_buyer") {
|
||||||
return initialValues;
|
return initialValues;
|
||||||
} else if (page === "slaughter_add_buyer") {
|
} else if (page === "slaughter_add_buyer") {
|
||||||
return {
|
return {
|
||||||
...initialValues,
|
...initialValues,
|
||||||
nationalId: "",
|
nationalId: ""
|
||||||
};
|
};
|
||||||
} else if (page === "admin_add_buyer") {
|
} else if (page === "admin_add_buyer") {
|
||||||
return {
|
return {
|
||||||
...initialValues,
|
...initialValues,
|
||||||
role_key: "",
|
role_key: "",
|
||||||
type: "",
|
type: ""
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return initialValues;
|
return initialValues;
|
||||||
@@ -103,7 +103,7 @@ export const StewardAddBuyer = ({
|
|||||||
isEdit = false,
|
isEdit = false,
|
||||||
data,
|
data,
|
||||||
isRealPerson,
|
isRealPerson,
|
||||||
buyerType = "",
|
buyerType = ""
|
||||||
// buyerYype => "Guilds" | "Steward"
|
// buyerYype => "Guilds" | "Steward"
|
||||||
}) => {
|
}) => {
|
||||||
const role = getRoleFromUrl();
|
const role = getRoleFromUrl();
|
||||||
@@ -124,7 +124,7 @@ export const StewardAddBuyer = ({
|
|||||||
cityData,
|
cityData,
|
||||||
setCityData,
|
setCityData,
|
||||||
userData,
|
userData,
|
||||||
setUserData,
|
setUserData
|
||||||
} = useAddBuyer(page);
|
} = useAddBuyer(page);
|
||||||
|
|
||||||
const { selectedSubUser } = useSelector((state) => state.userSlice);
|
const { selectedSubUser } = useSelector((state) => state.userSlice);
|
||||||
@@ -141,7 +141,7 @@ export const StewardAddBuyer = ({
|
|||||||
? validationSchemaForSlaughterAddBuyer(isRealPerson, isEdit)
|
? validationSchemaForSlaughterAddBuyer(isRealPerson, isEdit)
|
||||||
: IS_ADMIN_ADD_BUYER
|
: IS_ADMIN_ADD_BUYER
|
||||||
? validationSchemaForAdminAddBuyer(isRealPerson, isEdit)
|
? validationSchemaForAdminAddBuyer(isRealPerson, isEdit)
|
||||||
: Yup.object({}),
|
: Yup.object({})
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -157,7 +157,7 @@ export const StewardAddBuyer = ({
|
|||||||
} else {
|
} else {
|
||||||
dispatch(
|
dispatch(
|
||||||
slaughterGetStewardsForAllocateService({
|
slaughterGetStewardsForAllocateService({
|
||||||
free: true,
|
free: true
|
||||||
})
|
})
|
||||||
).then((r) => {
|
).then((r) => {
|
||||||
setStewards(r.payload.data || []);
|
setStewards(r.payload.data || []);
|
||||||
|
|||||||
@@ -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"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,21 +6,21 @@ 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 { AppContext } from "../../../../contexts/AppContext";
|
import { AppContext } from "../../../../contexts/AppContext";
|
||||||
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 {
|
||||||
slaughterEditBuyerDataService,
|
slaughterEditBuyerDataService,
|
||||||
slaughterGetBuyerDataService,
|
slaughterGetBuyerDataService,
|
||||||
slaughterSubmitBuyerDataService,
|
slaughterSubmitBuyerDataService
|
||||||
} from "../../../slaughter-house/services/slaughter-house-submit-buyer";
|
} from "../../../slaughter-house/services/slaughter-house-submit-buyer";
|
||||||
import { DRAWER, LOADING_END } from "../../../../lib/redux/slices/appSlice";
|
import { DRAWER, LOADING_END } from "../../../../lib/redux/slices/appSlice";
|
||||||
import { fetchStewardBroadcastAndProducts } from "../../services/handle-fetch-steward-products";
|
import { fetchStewardBroadcastAndProducts } from "../../services/handle-fetch-steward-products";
|
||||||
@@ -28,7 +28,7 @@ import { fetchStewardBroadcastAndProducts } from "../../services/handle-fetch-st
|
|||||||
export const StewardSellOutOfProvinceBuyersEditBuyer = ({
|
export const StewardSellOutOfProvinceBuyersEditBuyer = ({
|
||||||
updateTable,
|
updateTable,
|
||||||
isEdit,
|
isEdit,
|
||||||
data,
|
data
|
||||||
}) => {
|
}) => {
|
||||||
const [openNotif] = useContext(AppContext);
|
const [openNotif] = useContext(AppContext);
|
||||||
const [userData, setUserData] = useState(null);
|
const [userData, setUserData] = useState(null);
|
||||||
@@ -44,7 +44,7 @@ export const StewardSellOutOfProvinceBuyersEditBuyer = ({
|
|||||||
lastName: "",
|
lastName: "",
|
||||||
unitName: "",
|
unitName: "",
|
||||||
province: "",
|
province: "",
|
||||||
city: "",
|
city: ""
|
||||||
},
|
},
|
||||||
validationSchema: Yup.object({
|
validationSchema: Yup.object({
|
||||||
mobile: Yup.string()
|
mobile: Yup.string()
|
||||||
@@ -66,22 +66,22 @@ export const StewardSellOutOfProvinceBuyersEditBuyer = ({
|
|||||||
.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(() => {
|
||||||
@@ -96,7 +96,7 @@ export const StewardSellOutOfProvinceBuyersEditBuyer = ({
|
|||||||
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();
|
||||||
@@ -112,7 +112,7 @@ export const StewardSellOutOfProvinceBuyersEditBuyer = ({
|
|||||||
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();
|
||||||
@@ -189,7 +189,7 @@ export const StewardSellOutOfProvinceBuyersEditBuyer = ({
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: "خریدار یافت نشد، یک خریدار جدید ثبت کنید!",
|
msg: "خریدار یافت نشد، یک خریدار جدید ثبت کنید!",
|
||||||
severity: "error",
|
severity: "error"
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setUserData(r.payload.data);
|
setUserData(r.payload.data);
|
||||||
@@ -317,7 +317,7 @@ export const StewardSellOutOfProvinceBuyersEditBuyer = ({
|
|||||||
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();
|
||||||
@@ -327,7 +327,7 @@ export const StewardSellOutOfProvinceBuyersEditBuyer = ({
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: r.payload.error,
|
msg: r.payload.error,
|
||||||
severity: "error",
|
severity: "error"
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
dispatch(
|
dispatch(
|
||||||
@@ -338,7 +338,7 @@ export const StewardSellOutOfProvinceBuyersEditBuyer = ({
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: "عملیات با موفقیت انجام شد.",
|
msg: "عملیات با موفقیت انجام شد.",
|
||||||
severity: "success",
|
severity: "success"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -350,7 +350,7 @@ export const StewardSellOutOfProvinceBuyersEditBuyer = ({
|
|||||||
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 StewardSellOutOfProvinceBuyersEditBuyer = ({
|
|||||||
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 StewardSellOutOfProvinceBuyersEditBuyer = ({
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: "عملیات با موفقیت انجام شد.",
|
msg: "عملیات با موفقیت انجام شد.",
|
||||||
severity: "success",
|
severity: "success"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ import { AppContext } from "../../../../contexts/AppContext";
|
|||||||
import { slaughterGetProductsService } from "../../../slaughter-house/services/slaughter-inventory-gets";
|
import { slaughterGetProductsService } from "../../../slaughter-house/services/slaughter-inventory-gets";
|
||||||
import {
|
import {
|
||||||
slaughterGetCitiesService,
|
slaughterGetCitiesService,
|
||||||
slaughterGetProvinceService,
|
slaughterGetProvinceService
|
||||||
} from "../../../slaughter-house/services/slaughter-get-provinces";
|
} from "../../../slaughter-house/services/slaughter-get-provinces";
|
||||||
import { fixBase64 } from "../../../../utils/toBase64";
|
import { fixBase64 } from "../../../../utils/toBase64";
|
||||||
import { DRAWER } from "../../../../lib/redux/slices/appSlice";
|
import { DRAWER } from "../../../../lib/redux/slices/appSlice";
|
||||||
import {
|
import {
|
||||||
stewardEditFreeBarService,
|
stewardEditFreeBarService,
|
||||||
stewardSubmitFreeBarService,
|
stewardSubmitFreeBarService
|
||||||
} from "../../../guild/services/steward-submit-free-bar-service";
|
} from "../../../guild/services/steward-submit-free-bar-service";
|
||||||
import { Grid } from "../../../../components/grid/Grid";
|
import { Grid } from "../../../../components/grid/Grid";
|
||||||
import { SPACING } from "../../../../data/spacing";
|
import { SPACING } from "../../../../data/spacing";
|
||||||
@@ -32,7 +32,7 @@ const ValidationSchema = Yup.object().shape({
|
|||||||
bar_image: Yup.string().when("$isEdit", {
|
bar_image: Yup.string().when("$isEdit", {
|
||||||
is: true,
|
is: true,
|
||||||
then: Yup.string(),
|
then: Yup.string(),
|
||||||
otherwise: Yup.string().required("عکس بار الزامی است"),
|
otherwise: Yup.string().required("عکس بار الزامی است")
|
||||||
}),
|
}),
|
||||||
number_of_carcasses: Yup.number()
|
number_of_carcasses: Yup.number()
|
||||||
.required("حجم لاشه الزامی است")
|
.required("حجم لاشه الزامی است")
|
||||||
@@ -40,7 +40,7 @@ const ValidationSchema = Yup.object().shape({
|
|||||||
weight_of_carcasses: Yup.number()
|
weight_of_carcasses: Yup.number()
|
||||||
.required("وزن لاشه الزامی است")
|
.required("وزن لاشه الزامی است")
|
||||||
.min(0.01, "وزن باید بیشتر از 0 باشد"),
|
.min(0.01, "وزن باید بیشتر از 0 باشد"),
|
||||||
product_key: Yup.string().required("انتخاب محصول الزامی است"),
|
product_key: Yup.string().required("انتخاب محصول الزامی است")
|
||||||
});
|
});
|
||||||
|
|
||||||
export const StewardSubmitFreeBar = ({ updateTable, item }) => {
|
export const StewardSubmitFreeBar = ({ updateTable, item }) => {
|
||||||
@@ -59,7 +59,7 @@ export const StewardSubmitFreeBar = ({ updateTable, item }) => {
|
|||||||
slaughterGetProductsService({
|
slaughterGetProductsService({
|
||||||
role_key: checkPathStartsWith("steward")
|
role_key: checkPathStartsWith("steward")
|
||||||
? selectedSubUser?.key || ""
|
? selectedSubUser?.key || ""
|
||||||
: "",
|
: ""
|
||||||
})
|
})
|
||||||
).then((r) => {
|
).then((r) => {
|
||||||
// Handle both direct array response and nested data response
|
// Handle both direct array response and nested data response
|
||||||
@@ -90,7 +90,7 @@ export const StewardSubmitFreeBar = ({ updateTable, item }) => {
|
|||||||
role_key: checkPathStartsWith("steward")
|
role_key: checkPathStartsWith("steward")
|
||||||
? selectedSubUser?.key || ""
|
? selectedSubUser?.key || ""
|
||||||
: "",
|
: "",
|
||||||
...(item?.key && { key: item.key }),
|
...(item?.key && { key: item.key })
|
||||||
},
|
},
|
||||||
validationSchema: ValidationSchema,
|
validationSchema: ValidationSchema,
|
||||||
onSubmit: (values) => {
|
onSubmit: (values) => {
|
||||||
@@ -107,7 +107,7 @@ export const StewardSubmitFreeBar = ({ updateTable, item }) => {
|
|||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
msg: r.payload.error,
|
msg: r.payload.error,
|
||||||
severity: "error",
|
severity: "error"
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
updateTable();
|
updateTable();
|
||||||
@@ -118,7 +118,7 @@ export const StewardSubmitFreeBar = ({ updateTable, item }) => {
|
|||||||
msg: item?.key
|
msg: item?.key
|
||||||
? "اطلاعات خرید با موفقیت ویرایش شد"
|
? "اطلاعات خرید با موفقیت ویرایش شد"
|
||||||
: "اطلاعات خرید جدید با موفقیت ثبت شد",
|
: "اطلاعات خرید جدید با موفقیت ثبت شد",
|
||||||
severity: "success",
|
severity: "success"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -128,7 +128,7 @@ export const StewardSubmitFreeBar = ({ updateTable, item }) => {
|
|||||||
} else {
|
} else {
|
||||||
dispatch(stewardSubmitFreeBarService(values)).then(thenCallback);
|
dispatch(stewardSubmitFreeBarService(values)).then(thenCallback);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const factorPaymentHandler = (imageList) => {
|
const factorPaymentHandler = (imageList) => {
|
||||||
@@ -164,7 +164,7 @@ export const StewardSubmitFreeBar = ({ updateTable, item }) => {
|
|||||||
Array.isArray(productData) && productData.length > 0
|
Array.isArray(productData) && productData.length > 0
|
||||||
? productData.map((i) => ({
|
? productData.map((i) => ({
|
||||||
id: i.key,
|
id: i.key,
|
||||||
label: i.name || "",
|
label: i.name || ""
|
||||||
}))
|
}))
|
||||||
: []
|
: []
|
||||||
}
|
}
|
||||||
@@ -199,7 +199,7 @@ export const StewardSubmitFreeBar = ({ updateTable, item }) => {
|
|||||||
style={{
|
style={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
gap: SPACING.LARGE,
|
gap: SPACING.LARGE
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TextField
|
<TextField
|
||||||
@@ -240,13 +240,13 @@ export const StewardSubmitFreeBar = ({ updateTable, item }) => {
|
|||||||
id="province"
|
id="province"
|
||||||
options={provinceData.map((i) => ({
|
options={provinceData.map((i) => ({
|
||||||
id: i.name,
|
id: i.name,
|
||||||
label: i.name,
|
label: i.name
|
||||||
}))}
|
}))}
|
||||||
value={
|
value={
|
||||||
formik.values.province
|
formik.values.province
|
||||||
? {
|
? {
|
||||||
id: formik.values.province,
|
id: formik.values.province,
|
||||||
label: formik.values.province,
|
label: formik.values.province
|
||||||
}
|
}
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
@@ -276,7 +276,7 @@ export const StewardSubmitFreeBar = ({ updateTable, item }) => {
|
|||||||
formik.values.city
|
formik.values.city
|
||||||
? {
|
? {
|
||||||
id: formik.values.city,
|
id: formik.values.city,
|
||||||
label: formik.values.city,
|
label: formik.values.city
|
||||||
}
|
}
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
@@ -300,9 +300,7 @@ export const StewardSubmitFreeBar = ({ updateTable, item }) => {
|
|||||||
label="حجم لاشه"
|
label="حجم لاشه"
|
||||||
type="number"
|
type="number"
|
||||||
InputProps={{
|
InputProps={{
|
||||||
endAdornment: (
|
endAdornment: <InputAdornment position="end">قطعه</InputAdornment>
|
||||||
<InputAdornment position="end">قطعه</InputAdornment>
|
|
||||||
),
|
|
||||||
}}
|
}}
|
||||||
value={formik.values.number_of_carcasses}
|
value={formik.values.number_of_carcasses}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
@@ -325,7 +323,7 @@ export const StewardSubmitFreeBar = ({ updateTable, item }) => {
|
|||||||
InputProps={{
|
InputProps={{
|
||||||
endAdornment: (
|
endAdornment: (
|
||||||
<InputAdornment position="end">کیلوگرم</InputAdornment>
|
<InputAdornment position="end">کیلوگرم</InputAdornment>
|
||||||
),
|
)
|
||||||
}}
|
}}
|
||||||
value={formik.values.weight_of_carcasses}
|
value={formik.values.weight_of_carcasses}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
|
|||||||
Reference in New Issue
Block a user