connect services => out province stewards
This commit is contained in:
@@ -80,7 +80,7 @@ export const ManageGuildsRequests = ({ userType }) => {
|
|||||||
item?.registerarMobile ? "(" + item?.registerarMobile + " )" : " "
|
item?.registerarMobile ? "(" + item?.registerarMobile + " )" : " "
|
||||||
}`,
|
}`,
|
||||||
item?.licenseNumber || "-",
|
item?.licenseNumber || "-",
|
||||||
item?.name || "-",
|
(IS_STEWARD ? item?.name : item?.guildsName) || "-",
|
||||||
`${item?.user?.fullname || "-"} (${item?.user?.mobile || "-"})`,
|
`${item?.user?.fullname || "-"} (${item?.user?.mobile || "-"})`,
|
||||||
item?.user?.nationalId || "-",
|
item?.user?.nationalId || "-",
|
||||||
item?.typeActivity || "-",
|
item?.typeActivity || "-",
|
||||||
|
|||||||
@@ -116,56 +116,22 @@ const getValidationSchema = (isAdmin, userFound) =>
|
|||||||
type_activity: yup.string(),
|
type_activity: yup.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const LegalGuildForm = ({ formik, isAdmin, typeActivities, userType }) => {
|
const LegalGuildForm = ({
|
||||||
|
formik,
|
||||||
|
isAdmin,
|
||||||
|
typeActivities,
|
||||||
|
userType,
|
||||||
|
provinces,
|
||||||
|
cities,
|
||||||
|
}) => {
|
||||||
const IS_STEWARD = userType === "steward";
|
const IS_STEWARD = userType === "steward";
|
||||||
|
|
||||||
const [provinceData, setProvinceData] = useState();
|
|
||||||
const [cityData, setCityData] = useState();
|
|
||||||
|
|
||||||
const dispatch = useDispatch();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
dispatch(LOADING_START());
|
|
||||||
dispatch(cityGetProvinces())
|
|
||||||
?.then((r) => {
|
|
||||||
if (r?.payload?.data) {
|
|
||||||
setProvinceData(r.payload.data);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error("Error fetching provinces:", error);
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
dispatch(LOADING_END());
|
|
||||||
});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (formik?.values?.province) {
|
|
||||||
dispatch(LOADING_START());
|
|
||||||
dispatch(cityGetCity(formik?.values?.province))
|
|
||||||
.then((r) => {
|
|
||||||
if (r?.payload?.data) {
|
|
||||||
setCityData(r.payload.data);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error("Error fetching cities:", error);
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
dispatch(LOADING_END());
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setCityData([]);
|
|
||||||
}
|
|
||||||
}, [formik?.values?.province]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={formik.handleSubmit}>
|
<form onSubmit={formik.handleSubmit}>
|
||||||
<Grid container gap={SPACING.SMALL} p={2}>
|
<Grid container gap={SPACING.SMALL} p={2}>
|
||||||
<Grid container spacing={2} xs={12}>
|
<Grid container spacing={2} xs={12}>
|
||||||
<Grid item xs={12} md={6}>
|
<Grid item xs={12} md={6}>
|
||||||
<Grid container direction="column" gap={SPACING.TINY}>
|
<Grid container gap={SPACING.SMALL}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
{isAdmin ? (
|
{isAdmin ? (
|
||||||
<TextField
|
<TextField
|
||||||
@@ -267,7 +233,7 @@ const LegalGuildForm = ({ formik, isAdmin, typeActivities, userType }) => {
|
|||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid item xs={12} md={6}>
|
<Grid item xs={12} md={6}>
|
||||||
<Grid container direction="column" gap={SPACING.TINY}>
|
<Grid container gap={SPACING.SMALL}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
size="small"
|
size="small"
|
||||||
@@ -275,8 +241,8 @@ const LegalGuildForm = ({ formik, isAdmin, typeActivities, userType }) => {
|
|||||||
disablePortal
|
disablePortal
|
||||||
id="province"
|
id="province"
|
||||||
options={
|
options={
|
||||||
provinceData
|
provinces
|
||||||
? provinceData.map((i) => ({
|
? provinces.map((i) => ({
|
||||||
id: i.key,
|
id: i.key,
|
||||||
label: i.name,
|
label: i.name,
|
||||||
}))
|
}))
|
||||||
@@ -301,22 +267,15 @@ const LegalGuildForm = ({ formik, isAdmin, typeActivities, userType }) => {
|
|||||||
disablePortal
|
disablePortal
|
||||||
id="city"
|
id="city"
|
||||||
options={
|
options={
|
||||||
cityData
|
cities
|
||||||
? cityData.map((i) => ({ id: i.name, label: i.name }))
|
? cities.map((i) => ({ id: i.key, label: i.name }))
|
||||||
: []
|
: []
|
||||||
}
|
}
|
||||||
onChange={(e, value) => {
|
onChange={(e, value) => {
|
||||||
formik.setFieldValue("city", value ? value.id : "");
|
formik.setFieldValue("city", value ? value.id : "");
|
||||||
}}
|
}}
|
||||||
renderInput={(params) => (
|
renderInput={(params) => (
|
||||||
<TextField
|
<TextField {...params} label={"شهر"} />
|
||||||
{...params}
|
|
||||||
label={
|
|
||||||
formik?.values?.city
|
|
||||||
? `شهر ${formik?.values?.city}`
|
|
||||||
: "شهر را انتخاب کنید"
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
@@ -436,6 +395,9 @@ export const ProvinceLegalGuildsForm = ({
|
|||||||
item,
|
item,
|
||||||
userType,
|
userType,
|
||||||
}) => {
|
}) => {
|
||||||
|
const [provinceData, setProvinceData] = useState();
|
||||||
|
const [cityData, setCityData] = useState();
|
||||||
|
|
||||||
const IS_STEWARD = userType === "steward";
|
const IS_STEWARD = userType === "steward";
|
||||||
const userInitialValue = {
|
const userInitialValue = {
|
||||||
national_id: item?.user?.national_id || "",
|
national_id: item?.user?.national_id || "",
|
||||||
@@ -471,6 +433,22 @@ export const ProvinceLegalGuildsForm = ({
|
|||||||
const currentRole = getRoleFromUrl();
|
const currentRole = getRoleFromUrl();
|
||||||
const isAdmin = currentRole === "AdminX";
|
const isAdmin = currentRole === "AdminX";
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
dispatch(LOADING_START());
|
||||||
|
dispatch(cityGetProvinces())
|
||||||
|
?.then((r) => {
|
||||||
|
if (r?.payload?.data) {
|
||||||
|
setProvinceData(r.payload.data);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error fetching provinces:", error);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
dispatch(LOADING_END());
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(provinceGetTypeActivity()).then((r) => {
|
dispatch(provinceGetTypeActivity()).then((r) => {
|
||||||
setTypeActivities(r.payload.data || []);
|
setTypeActivities(r.payload.data || []);
|
||||||
@@ -529,6 +507,12 @@ export const ProvinceLegalGuildsForm = ({
|
|||||||
if (r.payload.error) {
|
if (r.payload.error) {
|
||||||
setUserFound(false);
|
setUserFound(false);
|
||||||
if (isAdmin) {
|
if (isAdmin) {
|
||||||
|
openNotif({
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "center",
|
||||||
|
msg: r.payload.error,
|
||||||
|
severity: "error",
|
||||||
|
});
|
||||||
// Admin can create even if user not found
|
// Admin can create even if user not found
|
||||||
setUserData(
|
setUserData(
|
||||||
IS_STEWARD
|
IS_STEWARD
|
||||||
@@ -612,10 +596,10 @@ export const ProvinceLegalGuildsForm = ({
|
|||||||
first_name: values.first_name,
|
first_name: values.first_name,
|
||||||
last_name: values.last_name,
|
last_name: values.last_name,
|
||||||
national_id: values.national_id,
|
national_id: values.national_id,
|
||||||
province: values.province,
|
province: provinceData?.find((p) => p?.key === values.province)?.name,
|
||||||
address: values.address || "",
|
address: values.address || "",
|
||||||
mobile: values.mobile || "",
|
mobile: values.mobile || "",
|
||||||
city: values.city,
|
city: cityData?.find((c) => c?.key === values.city)?.name,
|
||||||
type_activity: typeActivityKey, // Send key instead of title
|
type_activity: typeActivityKey, // Send key instead of title
|
||||||
...(item?.key && { guilds_key: item.key }), // Include guild key for editing
|
...(item?.key && { guilds_key: item.key }), // Include guild key for editing
|
||||||
};
|
};
|
||||||
@@ -650,6 +634,26 @@ export const ProvinceLegalGuildsForm = ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (formik?.values?.province) {
|
||||||
|
dispatch(LOADING_START());
|
||||||
|
dispatch(cityGetCity(formik?.values?.province))
|
||||||
|
.then((r) => {
|
||||||
|
if (r?.payload?.data) {
|
||||||
|
setCityData(r.payload.data);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error fetching cities:", error);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
dispatch(LOADING_END());
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setCityData([]);
|
||||||
|
}
|
||||||
|
}, [formik?.values?.province]);
|
||||||
|
|
||||||
if (!userData && !item) {
|
if (!userData && !item) {
|
||||||
return (
|
return (
|
||||||
<InquiryForm
|
<InquiryForm
|
||||||
@@ -666,6 +670,8 @@ export const ProvinceLegalGuildsForm = ({
|
|||||||
isAdmin={isAdmin}
|
isAdmin={isAdmin}
|
||||||
typeActivities={typeActivities}
|
typeActivities={typeActivities}
|
||||||
userType={userType}
|
userType={userType}
|
||||||
|
provinces={provinceData}
|
||||||
|
cities={cityData}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,33 +29,28 @@ export const ProvinceLegalGuildsInProvince = ({ userType }) => {
|
|||||||
const handleTextChange = (e) => setTextValue(e.target.value);
|
const handleTextChange = (e) => setTextValue(e.target.value);
|
||||||
|
|
||||||
const fetchApiData = async (pageNum) => {
|
const fetchApiData = async (pageNum) => {
|
||||||
let response = null;
|
const response = await dispatch(
|
||||||
if (IS_STEWARD) {
|
IS_STEWARD
|
||||||
response = await dispatch(
|
? provinceGetTotalStewardsService({
|
||||||
provinceGetTotalStewardsService({
|
search: "filter",
|
||||||
search: "filter",
|
value: textValue,
|
||||||
value: textValue,
|
page: page,
|
||||||
page: page,
|
page_size: perPage,
|
||||||
page_size: perPage,
|
is_real_person: false,
|
||||||
is_real_person: false,
|
role_key: checkPathStartsWith("province")
|
||||||
role_key: checkPathStartsWith("province")
|
? selectedSubUser?.key || ""
|
||||||
? selectedSubUser?.key || ""
|
: "",
|
||||||
: "",
|
})
|
||||||
})
|
: provinceGetTotalGuildsService({
|
||||||
);
|
search: "filter",
|
||||||
} else {
|
value: textValue,
|
||||||
response = await dispatch(
|
page: pageNum,
|
||||||
provinceGetTotalGuildsService({
|
page_size: perPage,
|
||||||
search: "filter",
|
steward: false,
|
||||||
value: textValue,
|
active_state: "all",
|
||||||
page: pageNum,
|
is_real_person: false,
|
||||||
page_size: perPage,
|
})
|
||||||
steward: false,
|
);
|
||||||
active_state: "all",
|
|
||||||
is_real_person: false,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.payload.error) {
|
if (response.payload.error) {
|
||||||
console.error("Error fetching data:", response.payload.error);
|
console.error("Error fetching data:", response.payload.error);
|
||||||
@@ -90,7 +85,7 @@ export const ProvinceLegalGuildsInProvince = ({ userType }) => {
|
|||||||
const d = data.map((item, i) => {
|
const d = data.map((item, i) => {
|
||||||
return [
|
return [
|
||||||
page === 1 ? i + 1 : i + perPage * (page - 1) + 1,
|
page === 1 ? i + 1 : i + perPage * (page - 1) + 1,
|
||||||
item?.nationalId || "-",
|
(IS_STEWARD ? item?.licenseNumber : item?.nationalId) || "-",
|
||||||
(IS_STEWARD ? item?.name : item?.guildsName) || "-",
|
(IS_STEWARD ? item?.name : item?.guildsName) || "-",
|
||||||
`${item?.user?.fullname || "-"}`,
|
`${item?.user?.fullname || "-"}`,
|
||||||
item?.user?.mobile || "-",
|
item?.user?.mobile || "-",
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export const ProvinceLegalGuildsOutProvince = ({ userType }) => {
|
|||||||
page: page,
|
page: page,
|
||||||
pageSize: perPage,
|
pageSize: perPage,
|
||||||
searchValue: textValue,
|
searchValue: textValue,
|
||||||
|
buyer_type: IS_STEWARD ? "Steward" : "Guilds",
|
||||||
});
|
});
|
||||||
setData(response.data.results);
|
setData(response.data.results);
|
||||||
setTotalRows(response.data.count);
|
setTotalRows(response.data.count);
|
||||||
@@ -68,7 +69,9 @@ export const ProvinceLegalGuildsOutProvince = ({ userType }) => {
|
|||||||
return [
|
return [
|
||||||
page === 1 ? i + 1 : i + perPage * (page - 1) + 1,
|
page === 1 ? i + 1 : i + perPage * (page - 1) + 1,
|
||||||
item?.unitName || "-",
|
item?.unitName || "-",
|
||||||
item?.buyer?.parentLegalPersonNationalCode || "-",
|
(IS_STEWARD
|
||||||
|
? item?.buyer?.nationalId
|
||||||
|
: item?.buyer?.parentLegalPersonNationalCode) || "-",
|
||||||
killHouseInfo,
|
killHouseInfo,
|
||||||
item?.province || "-",
|
item?.province || "-",
|
||||||
item?.city || "-",
|
item?.city || "-",
|
||||||
@@ -79,6 +82,7 @@ export const ProvinceLegalGuildsOutProvince = ({ userType }) => {
|
|||||||
key={item?.unitName}
|
key={item?.unitName}
|
||||||
item={item}
|
item={item}
|
||||||
updateTable={() => fetchApiData(1)}
|
updateTable={() => fetchApiData(1)}
|
||||||
|
userType={userType}
|
||||||
/>,
|
/>,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export const ProvinceTrueGuildsOutProvince = ({ userType }) => {
|
|||||||
page: page,
|
page: page,
|
||||||
pageSize: perPage,
|
pageSize: perPage,
|
||||||
searchValue: textValue,
|
searchValue: textValue,
|
||||||
|
buyer_type: IS_STEWARD ? "Steward" : "Guilds",
|
||||||
});
|
});
|
||||||
setData(response.data.results);
|
setData(response.data.results);
|
||||||
setTotalRows(response.data.count);
|
setTotalRows(response.data.count);
|
||||||
|
|||||||
@@ -37,9 +37,15 @@ export const ProvinceTrueGuildsOutProvinceOperations = ({
|
|||||||
const deleteGuild = () => {
|
const deleteGuild = () => {
|
||||||
const buyerKey = item?.key;
|
const buyerKey = item?.key;
|
||||||
if (buyerKey)
|
if (buyerKey)
|
||||||
dispatch(deleteOutProvinceTrueGuilds({ buyer_key: buyerKey })).then(() =>
|
dispatch(
|
||||||
dispatch(CLOSE_MODAL())
|
deleteOutProvinceTrueGuilds({
|
||||||
);
|
buyer_key: buyerKey,
|
||||||
|
buyer_type: IS_STEWARD ? "Steward" : "Guilds",
|
||||||
|
})
|
||||||
|
).then(() => {
|
||||||
|
updateTable();
|
||||||
|
dispatch(CLOSE_MODAL());
|
||||||
|
});
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Grid container>
|
<Grid container>
|
||||||
@@ -93,7 +99,12 @@ export const ProvinceTrueGuildsOutProvinceOperations = ({
|
|||||||
? "legal"
|
? "legal"
|
||||||
: "real"
|
: "real"
|
||||||
}
|
}
|
||||||
defaultNationalCode={item?.buyer?.nationalCode}
|
defaultNationalCode={
|
||||||
|
IS_STEWARD
|
||||||
|
? item?.buyer?.nationalId
|
||||||
|
: item?.buyer?.nationalCode
|
||||||
|
}
|
||||||
|
userType={userType}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import axios from "axios";
|
|||||||
* @param {number} params.page - Page number
|
* @param {number} params.page - Page number
|
||||||
* @param {number} params.pageSize - Items per page
|
* @param {number} params.pageSize - Items per page
|
||||||
* @param {string} params.searchValue - Search value
|
* @param {string} params.searchValue - Search value
|
||||||
|
* @param {string} params.buyerType - buyer type
|
||||||
* @returns {Promise} Axios promise with buyers data
|
* @returns {Promise} Axios promise with buyers data
|
||||||
*/
|
*/
|
||||||
export const fetchOutProvinceRealBuyers = async ({
|
export const fetchOutProvinceRealBuyers = async ({
|
||||||
@@ -14,9 +15,12 @@ export const fetchOutProvinceRealBuyers = async ({
|
|||||||
page,
|
page,
|
||||||
pageSize,
|
pageSize,
|
||||||
searchValue = "",
|
searchValue = "",
|
||||||
|
buyer_type = "",
|
||||||
}) => {
|
}) => {
|
||||||
const response = await axios.get(
|
const response = await axios.get(
|
||||||
`out-province-carcasses-buyer/?search=filter&value=${searchValue}&role=${role}&page=${page}&page_size=${pageSize}&state=buyer-list&type=real`
|
`out-province-carcasses-buyer/?search=filter&value=${searchValue}&role=${role}&page=${page}&page_size=${pageSize}&state=buyer-list&type=real${
|
||||||
|
buyer_type ? "&buyer_type=" + buyer_type : ""
|
||||||
|
}`
|
||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
};
|
};
|
||||||
@@ -35,10 +39,12 @@ export const fetchOutProvinceLegalBuyers = async ({
|
|||||||
page,
|
page,
|
||||||
pageSize,
|
pageSize,
|
||||||
searchValue = "",
|
searchValue = "",
|
||||||
|
buyer_type = "",
|
||||||
}) => {
|
}) => {
|
||||||
const response = await axios.get(
|
const response = await axios.get(
|
||||||
`out-province-carcasses-buyer/?search=filter&value=${searchValue}&role=${role}&page=${page}&page_size=${pageSize}&state=buyer-list&type=legal`
|
`out-province-carcasses-buyer/?search=filter&value=${searchValue}&role=${role}&page=${page}&page_size=${pageSize}&state=buyer-list&type=legal${
|
||||||
|
buyer_type ? "&buyer_type=" + buyer_type : ""
|
||||||
|
}`
|
||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
data,
|
data,
|
||||||
defaultPersonType,
|
defaultPersonType,
|
||||||
defaultNationalCode,
|
defaultNationalCode,
|
||||||
|
userType,
|
||||||
}) => {
|
}) => {
|
||||||
|
const IS_STEWARD = userType === "steward";
|
||||||
const [openNotif] = useContext(AppContext);
|
const [openNotif] = useContext(AppContext);
|
||||||
const [userData, setUserData] = useState(null);
|
const [userData, setUserData] = useState(null);
|
||||||
const [notFound, setNotFound] = useState(false);
|
const [notFound, setNotFound] = useState(false);
|
||||||
@@ -131,7 +133,9 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
} else if (data.buyer.parentLegalPersonNationalCode) {
|
} else if (data.buyer.parentLegalPersonNationalCode) {
|
||||||
formik2.setFieldValue(
|
formik2.setFieldValue(
|
||||||
"nationalCode",
|
"nationalCode",
|
||||||
data.buyer.parentLegalPersonNationalCode,
|
IS_STEWARD
|
||||||
|
? data?.buyer?.nationalId
|
||||||
|
: data.buyer.parentLegalPersonNationalCode,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -140,15 +144,17 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (userData) {
|
if (userData) {
|
||||||
formik.setValues({
|
const formData = {
|
||||||
mobile: userData.mobile || "",
|
mobile: userData.mobile || "",
|
||||||
firstName: userData.firstName || "",
|
firstName: userData.firstName || "",
|
||||||
lastName: userData.lastName || "",
|
lastName: userData.lastName || "",
|
||||||
unitName: userData.unitName || "",
|
|
||||||
province: userData.province || "",
|
province: userData.province || "",
|
||||||
city: userData.city || "",
|
city: userData.city || "",
|
||||||
nationalId: userData.nationalId || "",
|
nationalId: userData.nationalId || "",
|
||||||
});
|
unitName: data?.unitName || "",
|
||||||
|
};
|
||||||
|
|
||||||
|
formik.setValues(formData);
|
||||||
|
|
||||||
const fieldKeys = [
|
const fieldKeys = [
|
||||||
"nationalId",
|
"nationalId",
|
||||||
@@ -174,15 +180,17 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isEdit) {
|
if (isEdit) {
|
||||||
formik.setValues({
|
const formData = {
|
||||||
mobile: data.mobile || "",
|
mobile: data.mobile || "",
|
||||||
firstName: data.firstName || "",
|
firstName: data.firstName || "",
|
||||||
lastName: data.lastName || "",
|
lastName: data.lastName || "",
|
||||||
unitName: data.unitName || "",
|
|
||||||
province: data.province || "",
|
province: data.province || "",
|
||||||
city: data.city || "",
|
city: data.city || "",
|
||||||
nationalId: data.national_id || data.nationalId || "",
|
nationalId: (IS_STEWARD ? defaultNationalCode : data.nationalId) || "",
|
||||||
});
|
unitName: data?.unitName || "",
|
||||||
|
};
|
||||||
|
|
||||||
|
formik.setValues(formData);
|
||||||
setLockedFields({});
|
setLockedFields({});
|
||||||
// formik2.setFieldValue(
|
// formik2.setFieldValue(
|
||||||
// "nationalCode",
|
// "nationalCode",
|
||||||
@@ -656,79 +664,85 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
disabled={!formik.isValid}
|
disabled={!formik.isValid}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (isEdit) {
|
if (isEdit) {
|
||||||
dispatch(
|
const submitData = {
|
||||||
slaughterEditBuyerDataService({
|
buyer_type: IS_STEWARD ? "Steward" : "Guilds",
|
||||||
buyer_key: data?.key,
|
buyer_key: data?.key,
|
||||||
mobile: formik.values.mobile,
|
mobile: formik.values.mobile,
|
||||||
first_name: formik.values.firstName,
|
first_name: formik.values.firstName,
|
||||||
last_name: formik.values.lastName,
|
last_name: formik.values.lastName,
|
||||||
unit_name: formik.values.unitName,
|
city: formik.values.city,
|
||||||
city: formik.values.city,
|
province: formik.values.province,
|
||||||
province: formik.values.province,
|
national_id: formik.values.nationalId,
|
||||||
national_id: formik.values.nationalId,
|
unit_name: formik.values.unitName,
|
||||||
})
|
};
|
||||||
).then((r) => {
|
|
||||||
updateTable();
|
|
||||||
if (r.payload.error) {
|
|
||||||
openNotif({
|
|
||||||
vertical: "top",
|
|
||||||
horizontal: "center",
|
|
||||||
msg: r.payload.error,
|
|
||||||
severity: "error",
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
dispatch(
|
|
||||||
DRAWER({ right: false, bottom: false, content: null })
|
|
||||||
);
|
|
||||||
|
|
||||||
openNotif({
|
dispatch(slaughterEditBuyerDataService(submitData)).then(
|
||||||
vertical: "top",
|
(r) => {
|
||||||
horizontal: "center",
|
updateTable();
|
||||||
msg: "عملیات با موفقیت انجام شد.",
|
if (r.payload.error) {
|
||||||
severity: "success",
|
openNotif({
|
||||||
});
|
vertical: "top",
|
||||||
|
horizontal: "center",
|
||||||
|
msg: r.payload.error,
|
||||||
|
severity: "error",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
dispatch(
|
||||||
|
DRAWER({ right: false, bottom: false, content: null })
|
||||||
|
);
|
||||||
|
|
||||||
|
openNotif({
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "center",
|
||||||
|
msg: "عملیات با موفقیت انجام شد.",
|
||||||
|
severity: "success",
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
} else {
|
} else {
|
||||||
dispatch(
|
const submitData = {
|
||||||
slaughterSubmitBuyerDataService({
|
mobile: formik.values.mobile,
|
||||||
mobile: formik.values.mobile,
|
buyer_type: IS_STEWARD ? "Steward" : "Guilds",
|
||||||
first_name: formik.values.firstName,
|
first_name: formik.values.firstName,
|
||||||
last_name: formik.values.lastName,
|
last_name: formik.values.lastName,
|
||||||
|
city: formik.values.city,
|
||||||
|
province: formik.values.province,
|
||||||
|
national_id:
|
||||||
|
formik2.values.personType === "legal"
|
||||||
|
? null
|
||||||
|
: formik.values.nationalId,
|
||||||
|
...(formik2.values.personType === "legal" && {
|
||||||
|
isRealPerson: false,
|
||||||
|
info_value: formik2.values.nationalCode,
|
||||||
unit_name: formik.values.unitName,
|
unit_name: formik.values.unitName,
|
||||||
city: formik.values.city,
|
}),
|
||||||
province: formik.values.province,
|
};
|
||||||
national_id:
|
|
||||||
formik2.values.personType === "legal"
|
|
||||||
? null
|
|
||||||
: formik.values.nationalId,
|
|
||||||
...(formik2.values.personType === "legal" && {
|
|
||||||
isRealPerson: false,
|
|
||||||
info_value: formik2.values.nationalCode,
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
).then((r) => {
|
|
||||||
updateTable();
|
|
||||||
if (r.payload.error) {
|
|
||||||
openNotif({
|
|
||||||
vertical: "top",
|
|
||||||
horizontal: "center",
|
|
||||||
msg: r.payload.error,
|
|
||||||
severity: "error",
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
dispatch(
|
|
||||||
DRAWER({ right: false, bottom: false, content: null })
|
|
||||||
);
|
|
||||||
|
|
||||||
openNotif({
|
dispatch(slaughterSubmitBuyerDataService(submitData)).then(
|
||||||
vertical: "top",
|
(r) => {
|
||||||
horizontal: "center",
|
updateTable();
|
||||||
msg: "عملیات با موفقیت انجام شد.",
|
if (r.payload.error) {
|
||||||
severity: "success",
|
openNotif({
|
||||||
});
|
vertical: "top",
|
||||||
|
horizontal: "center",
|
||||||
|
msg: r.payload.error,
|
||||||
|
severity: "error",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
dispatch(
|
||||||
|
DRAWER({ right: false, bottom: false, content: null })
|
||||||
|
);
|
||||||
|
|
||||||
|
openNotif({
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "center",
|
||||||
|
msg: "عملیات با موفقیت انجام شد.",
|
||||||
|
severity: "success",
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user