connect service => in province stewards
This commit is contained in:
@@ -244,7 +244,7 @@ const GuildMaangeGuilds = () => {
|
|||||||
selector: (item, i) => (
|
selector: (item, i) => (
|
||||||
<ManageGuildsOperations
|
<ManageGuildsOperations
|
||||||
key={i + item?.guildsId}
|
key={i + item?.guildsId}
|
||||||
guild={item}
|
item={item}
|
||||||
updateTable={updateTable}
|
updateTable={updateTable}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
@@ -311,7 +311,7 @@ const GuildMaangeGuilds = () => {
|
|||||||
?.map((item) => `${item.name} (${item.mobile})`)
|
?.map((item) => `${item.name} (${item.mobile})`)
|
||||||
.join(" - "),
|
.join(" - "),
|
||||||
getItemState(item),
|
getItemState(item),
|
||||||
<ManageGuildsOperations key={i + item?.guildsId} guild={item} />,
|
<ManageGuildsOperations key={i + item?.guildsId} item={item} />,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -27,13 +27,18 @@ import SendIcon from "@mui/icons-material/Send";
|
|||||||
import { AppContext } from "../../../../contexts/AppContext";
|
import { AppContext } from "../../../../contexts/AppContext";
|
||||||
import { SPACING } from "../../../../data/spacing";
|
import { SPACING } from "../../../../data/spacing";
|
||||||
import { ProvinceManageGuildsSubmitRegisterCode } from "../province-manage-guilds-submit-register-code/ProvinceManageGuildsSubmitRegisterCode";
|
import { ProvinceManageGuildsSubmitRegisterCode } from "../province-manage-guilds-submit-register-code/ProvinceManageGuildsSubmitRegisterCode";
|
||||||
import { provinceResendRegisterCodeStateService } from "../../services/province-get-register-code-state";
|
import {
|
||||||
|
provinceResendRegisterCodeStateService,
|
||||||
|
provinceSendAgainSmsForRegisterCodeSteward,
|
||||||
|
} from "../../services/province-get-register-code-state";
|
||||||
import { ViewGuildDetails } from "../view-guild-details/ViewGuildDetails";
|
import { ViewGuildDetails } from "../view-guild-details/ViewGuildDetails";
|
||||||
import TuneIcon from "@mui/icons-material/Tune";
|
import TuneIcon from "@mui/icons-material/Tune";
|
||||||
|
import { updateStewardService } from "../../services/update-steward";
|
||||||
|
|
||||||
export const ManageGuildsOperations = ({ guild, updateTable }) => {
|
export const ManageGuildsOperations = ({ item, updateTable, userType }) => {
|
||||||
|
const IS_STEWARD = userType === "steward";
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [checked, setChecked] = useState(guild.active);
|
const [checked, setChecked] = useState(item.active);
|
||||||
const [popoverOpen, setPopoverOpen] = useState(false);
|
const [popoverOpen, setPopoverOpen] = useState(false);
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
const [openNotif] = useContext(AppContext);
|
const [openNotif] = useContext(AppContext);
|
||||||
@@ -51,29 +56,51 @@ export const ManageGuildsOperations = ({ guild, updateTable }) => {
|
|||||||
const handleChange = async (event) => {
|
const handleChange = async (event) => {
|
||||||
const newChecked = event.target.checked;
|
const newChecked = event.target.checked;
|
||||||
setChecked(newChecked);
|
setChecked(newChecked);
|
||||||
|
|
||||||
dispatch(LOADING_START());
|
dispatch(LOADING_START());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.put("guilds/0/", {
|
let response = null;
|
||||||
guilds_key: guild?.key,
|
if (IS_STEWARD) {
|
||||||
active: newChecked,
|
response = await dispatch(
|
||||||
role: getRoleFromUrl(),
|
updateStewardService({
|
||||||
});
|
params: {
|
||||||
|
id: item?.id,
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
active: newChecked,
|
||||||
|
role: getRoleFromUrl(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
).then(() => {
|
||||||
|
updateTable();
|
||||||
|
dispatch(DRAWER({ right: false, bottom: false, content: null }));
|
||||||
|
openNotif({
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "center",
|
||||||
|
msg: "عملیات با موفقیت انجام شد.",
|
||||||
|
severity: "success",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
response = await axios.put("guilds/0/", {
|
||||||
|
guilds_key: item?.key,
|
||||||
|
active: newChecked,
|
||||||
|
role: getRoleFromUrl(),
|
||||||
|
});
|
||||||
|
if (response.status === 200) {
|
||||||
|
updateTable();
|
||||||
|
dispatch(DRAWER({ right: false, bottom: false, content: null }));
|
||||||
|
openNotif({
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "center",
|
||||||
|
msg: "عملیات با موفقیت انجام شد.",
|
||||||
|
severity: "success",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dispatch(LOADING_END());
|
dispatch(LOADING_END());
|
||||||
|
|
||||||
if (response.status === 200) {
|
|
||||||
updateTable();
|
|
||||||
dispatch(DRAWER({ right: false, bottom: false, content: null }));
|
|
||||||
openNotif({
|
|
||||||
vertical: "top",
|
|
||||||
horizontal: "center",
|
|
||||||
msg: "عملیات با موفقیت انجام شد.",
|
|
||||||
severity: "success",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
dispatch(LOADING_END());
|
dispatch(LOADING_END());
|
||||||
const errorMessage =
|
const errorMessage =
|
||||||
error.response?.data?.result ||
|
error.response?.data?.result ||
|
||||||
@@ -128,8 +155,10 @@ export const ManageGuildsOperations = ({ guild, updateTable }) => {
|
|||||||
closePopover();
|
closePopover();
|
||||||
dispatch(
|
dispatch(
|
||||||
OPEN_MODAL({
|
OPEN_MODAL({
|
||||||
title: "مشاهده جزییات صنف",
|
title: `مشاهده جزییات ${IS_STEWARD ? "مباشر" : "صنف"}`,
|
||||||
content: <ViewGuildDetails guild={guild} />,
|
content: (
|
||||||
|
<ViewGuildDetails userType={userType} item={item} />
|
||||||
|
),
|
||||||
size: window.innerWidth <= 600 ? "small" : "auto",
|
size: window.innerWidth <= 600 ? "small" : "auto",
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -173,7 +202,7 @@ export const ManageGuildsOperations = ({ guild, updateTable }) => {
|
|||||||
size: window.innerWidth <= 600 ? "small" : "auto",
|
size: window.innerWidth <= 600 ? "small" : "auto",
|
||||||
content: (
|
content: (
|
||||||
<CreateGuilds
|
<CreateGuilds
|
||||||
guild={guild}
|
guild={item}
|
||||||
updateTable={updateTable}
|
updateTable={updateTable}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
@@ -197,7 +226,7 @@ export const ManageGuildsOperations = ({ guild, updateTable }) => {
|
|||||||
title: "اعمال محدودیت",
|
title: "اعمال محدودیت",
|
||||||
content: (
|
content: (
|
||||||
<GuildLimitaion
|
<GuildLimitaion
|
||||||
guild={guild}
|
guild={item}
|
||||||
updateTable={updateTable}
|
updateTable={updateTable}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
@@ -210,7 +239,7 @@ export const ManageGuildsOperations = ({ guild, updateTable }) => {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!guild?.isRegistered && (
|
{!item?.isRegistered && (
|
||||||
<Grid
|
<Grid
|
||||||
container
|
container
|
||||||
alignItems="flex-start"
|
alignItems="flex-start"
|
||||||
@@ -228,10 +257,12 @@ export const ManageGuildsOperations = ({ guild, updateTable }) => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
OPEN_MODAL({
|
OPEN_MODAL({
|
||||||
title: "ثبت کد احراز",
|
title: "ثبت کد احراز",
|
||||||
|
size: "auto",
|
||||||
content: (
|
content: (
|
||||||
<ProvinceManageGuildsSubmitRegisterCode
|
<ProvinceManageGuildsSubmitRegisterCode
|
||||||
item={guild}
|
item={item}
|
||||||
updateTable={updateTable}
|
updateTable={updateTable}
|
||||||
|
userType={userType}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
@@ -248,11 +279,14 @@ export const ManageGuildsOperations = ({ guild, updateTable }) => {
|
|||||||
sx={{ fontSize: { xs: 12, md: 15 } }}
|
sx={{ fontSize: { xs: 12, md: 15 } }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
closePopover();
|
closePopover();
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
provinceResendRegisterCodeStateService({
|
IS_STEWARD
|
||||||
key: guild.key,
|
? provinceSendAgainSmsForRegisterCodeSteward({
|
||||||
})
|
key: item.key,
|
||||||
|
})
|
||||||
|
: provinceResendRegisterCodeStateService({
|
||||||
|
key: item.key,
|
||||||
|
})
|
||||||
).then((r) => {
|
).then((r) => {
|
||||||
if (r.payload.error) {
|
if (r.payload.error) {
|
||||||
openNotif({
|
openNotif({
|
||||||
|
|||||||
@@ -16,12 +16,14 @@ import { ProvinceManageGuildsSubmitRegisterCode } from "../province-manage-guild
|
|||||||
import { provinceResendRegisterCodeStateService } from "../../services/province-get-register-code-state";
|
import { provinceResendRegisterCodeStateService } from "../../services/province-get-register-code-state";
|
||||||
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
|
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
|
||||||
import { ViewGuildDetails } from "../view-guild-details/ViewGuildDetails";
|
import { ViewGuildDetails } from "../view-guild-details/ViewGuildDetails";
|
||||||
|
import { updateStewardService } from "../../services/update-steward";
|
||||||
|
|
||||||
export const ManageGuildsRequestsOperations = ({
|
export const ManageGuildsRequestsOperations = ({
|
||||||
guild,
|
item,
|
||||||
updateTable,
|
updateTable,
|
||||||
userType,
|
userType,
|
||||||
}) => {
|
}) => {
|
||||||
|
const IS_STEWARD = userType === "steward";
|
||||||
const [popoverOpen, setPopoverOpen] = useState(false);
|
const [popoverOpen, setPopoverOpen] = useState(false);
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
|
|
||||||
@@ -111,9 +113,9 @@ export const ManageGuildsRequestsOperations = ({
|
|||||||
closePopover();
|
closePopover();
|
||||||
dispatch(
|
dispatch(
|
||||||
OPEN_MODAL({
|
OPEN_MODAL({
|
||||||
title: "مشاهده جزییات صنف",
|
title: `مشاهده جزییات ${IS_STEWARD ? "مباشر" : "صنف"}`,
|
||||||
content: (
|
content: (
|
||||||
<ViewGuildDetails guild={guild} userType={userType} />
|
<ViewGuildDetails item={item} userType={userType} />
|
||||||
),
|
),
|
||||||
size: window.innerWidth <= 600 ? "small" : "auto",
|
size: window.innerWidth <= 600 ? "small" : "auto",
|
||||||
})
|
})
|
||||||
@@ -124,8 +126,8 @@ export const ManageGuildsRequestsOperations = ({
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{(guild?.activeRegisterCode && guild?.loggedRegisterCode) ||
|
{(item?.activeRegisterCode && item?.loggedRegisterCode) ||
|
||||||
!guild?.activeRegisterCode ? (
|
!item?.activeRegisterCode ? (
|
||||||
<Grid
|
<Grid
|
||||||
container
|
container
|
||||||
alignItems="flex-start"
|
alignItems="flex-start"
|
||||||
@@ -140,13 +142,21 @@ export const ManageGuildsRequestsOperations = ({
|
|||||||
sx={{ fontSize: { xs: 12, md: 15 } }}
|
sx={{ fontSize: { xs: 12, md: 15 } }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
closePopover();
|
closePopover();
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
checkKillhouseRequestGuildService({
|
IS_STEWARD
|
||||||
guilds_key: guild.key,
|
? updateStewardService({
|
||||||
state: "accepted",
|
body: {
|
||||||
role: getRoleFromUrl(),
|
province_accept_state: "accepted",
|
||||||
})
|
},
|
||||||
|
params: {
|
||||||
|
id: item?.id,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
: checkKillhouseRequestGuildService({
|
||||||
|
guilds_key: item.key,
|
||||||
|
state: "accepted",
|
||||||
|
role: getRoleFromUrl(),
|
||||||
|
})
|
||||||
).then((r) => {
|
).then((r) => {
|
||||||
if (r.payload.error) {
|
if (r.payload.error) {
|
||||||
openNotif({
|
openNotif({
|
||||||
@@ -179,10 +189,12 @@ export const ManageGuildsRequestsOperations = ({
|
|||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
OPEN_MODAL({
|
OPEN_MODAL({
|
||||||
title: "رد درخواست ثبت صنف",
|
title: `رد درخواست ثبت ${IS_STEWARD ? "مباشر" : "صنف"}`,
|
||||||
|
size: "auto",
|
||||||
content: (
|
content: (
|
||||||
<RejectModal
|
<RejectModal
|
||||||
guild={guild}
|
userType={userType}
|
||||||
|
item={item}
|
||||||
updateTable={updateTable}
|
updateTable={updateTable}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
@@ -213,7 +225,7 @@ export const ManageGuildsRequestsOperations = ({
|
|||||||
title: "ثبت کد احراز",
|
title: "ثبت کد احراز",
|
||||||
content: (
|
content: (
|
||||||
<ProvinceManageGuildsSubmitRegisterCode
|
<ProvinceManageGuildsSubmitRegisterCode
|
||||||
item={guild}
|
item={item}
|
||||||
updateTable={updateTable}
|
updateTable={updateTable}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
@@ -234,7 +246,7 @@ export const ManageGuildsRequestsOperations = ({
|
|||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
provinceResendRegisterCodeStateService({
|
provinceResendRegisterCodeStateService({
|
||||||
key: guild.key,
|
key: item.key,
|
||||||
})
|
})
|
||||||
).then((r) => {
|
).then((r) => {
|
||||||
if (r.payload.error) {
|
if (r.payload.error) {
|
||||||
@@ -267,7 +279,8 @@ export const ManageGuildsRequestsOperations = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const RejectModal = ({ guild, updateTable }) => {
|
const RejectModal = ({ userType, item, updateTable }) => {
|
||||||
|
const IS_STEWARD = userType === "steward";
|
||||||
const [openNotif] = useContext(AppContext);
|
const [openNotif] = useContext(AppContext);
|
||||||
const [text, setText] = useState("");
|
const [text, setText] = useState("");
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@@ -275,7 +288,7 @@ const RejectModal = ({ guild, updateTable }) => {
|
|||||||
return (
|
return (
|
||||||
<Grid container gap={SPACING.TINY}>
|
<Grid container gap={SPACING.TINY}>
|
||||||
<TextField
|
<TextField
|
||||||
placeholder="دلیل رد درخواست..."
|
placeholder=" دلیل رد درخواست ..."
|
||||||
value={text}
|
value={text}
|
||||||
onChange={(e) => setText(e.target.value)}
|
onChange={(e) => setText(e.target.value)}
|
||||||
/>
|
/>
|
||||||
@@ -286,12 +299,22 @@ const RejectModal = ({ guild, updateTable }) => {
|
|||||||
disabled={!text}
|
disabled={!text}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
dispatch(
|
dispatch(
|
||||||
checkKillhouseRequestGuildService({
|
IS_STEWARD
|
||||||
guilds_key: guild.key,
|
? updateStewardService({
|
||||||
state: "rejected",
|
body: {
|
||||||
message: text,
|
province_accept_state: "rejected",
|
||||||
role: getRoleFromUrl(),
|
province_message: text,
|
||||||
})
|
},
|
||||||
|
params: {
|
||||||
|
id: item?.id,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
: checkKillhouseRequestGuildService({
|
||||||
|
guilds_key: item.key,
|
||||||
|
state: "rejected",
|
||||||
|
message: text,
|
||||||
|
role: getRoleFromUrl(),
|
||||||
|
})
|
||||||
).then((r) => {
|
).then((r) => {
|
||||||
if (r.payload.error) {
|
if (r.payload.error) {
|
||||||
openNotif({
|
openNotif({
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ export const ManageGuildsRequests = ({ userType }) => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
dispatch(LOADING_END());
|
dispatch(LOADING_END());
|
||||||
setData(response.data?.results || []);
|
setData(response.payload?.data?.results || []);
|
||||||
setTotalRows(response.data?.count || 0);
|
setTotalRows(response.payload?.data?.count || 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePageChange = (page) => {
|
const handlePageChange = (page) => {
|
||||||
@@ -72,6 +72,7 @@ export const ManageGuildsRequests = ({ userType }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
console.log(data);
|
||||||
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,
|
||||||
@@ -79,21 +80,21 @@ export const ManageGuildsRequests = ({ userType }) => {
|
|||||||
item?.registerarMobile ? "(" + item?.registerarMobile + " )" : " "
|
item?.registerarMobile ? "(" + item?.registerarMobile + " )" : " "
|
||||||
}`,
|
}`,
|
||||||
item?.licenseNumber || "-",
|
item?.licenseNumber || "-",
|
||||||
item?.guildsName || "-",
|
item?.name || "-",
|
||||||
`${item?.user?.fullname || "-"} (${item?.user?.mobile || "-"})`,
|
`${item?.user?.fullname || "-"} (${item?.user?.mobile || "-"})`,
|
||||||
item?.user?.nationalId || "-",
|
item?.user?.nationalId || "-",
|
||||||
item?.typeActivity || "-",
|
item?.typeActivity || "-",
|
||||||
item?.areaActivity || "-",
|
item?.areaActivity || "-",
|
||||||
item?.address?.postalCode || "-",
|
item?.address?.postalCode || "-",
|
||||||
`${item?.address?.province?.name || "-"}/${
|
`${item?.address?.province?.name || "-"} / ${
|
||||||
item?.address?.city?.name || "-"
|
item?.address?.city?.name || "-"
|
||||||
}/${item?.address?.address || "-"}`,
|
} / ${item?.address?.address || "-"}`,
|
||||||
item?.hasInquiry ? "استعلامی" : "دستی",
|
item?.hasInquiry ? "استعلامی" : "دستی",
|
||||||
item?.activeRegisterCode ? "انجام شده" : "انجام نشده",
|
item?.activeRegisterCode ? "انجام شده" : "انجام نشده",
|
||||||
<ManageGuildsRequestsOperations
|
<ManageGuildsRequestsOperations
|
||||||
updateTable={updateTable}
|
updateTable={updateTable}
|
||||||
key={item?.guildsName}
|
key={item?.guildsName}
|
||||||
guild={item}
|
item={item}
|
||||||
userType={userType}
|
userType={userType}
|
||||||
/>,
|
/>,
|
||||||
];
|
];
|
||||||
@@ -121,8 +122,8 @@ export const ManageGuildsRequests = ({ userType }) => {
|
|||||||
state: "pending",
|
state: "pending",
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
setData(response.data?.results || []);
|
setData(response.payload?.data?.results || []);
|
||||||
setTotalRows(response.data?.count || 0);
|
setTotalRows(response.payload?.data?.count || 0);
|
||||||
dispatch(LOADING_END());
|
dispatch(LOADING_END());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching data:", error);
|
console.error("Error fetching data:", error);
|
||||||
@@ -182,14 +183,14 @@ export const ManageGuildsRequests = ({ userType }) => {
|
|||||||
columns={[
|
columns={[
|
||||||
"ردیف",
|
"ردیف",
|
||||||
"ثبت کننده",
|
"ثبت کننده",
|
||||||
`${IS_STEWARD ? "مباشر" : "صنف"} شناسه`,
|
`شناسه ${IS_STEWARD ? "مباشر" : "صنف"}`,
|
||||||
`نام ${IS_STEWARD ? "مباشر" : "واحد صنفی"}`,
|
`نام ${IS_STEWARD ? "مباشر" : "واحد صنفی"}`,
|
||||||
"نام شخص/شرکت",
|
"نام شخص/شرکت",
|
||||||
"کدملی",
|
"کد ملی",
|
||||||
"نوع فعالیت",
|
"نوع فعالیت",
|
||||||
"حوزه فعالیت",
|
"حوزه فعالیت",
|
||||||
"کدپستی",
|
"کدپستی",
|
||||||
"استان/شهر/آدرس",
|
"استان / شهر / آدرس",
|
||||||
"نوع ثبت",
|
"نوع ثبت",
|
||||||
"احراز شماره موبایل",
|
"احراز شماره موبایل",
|
||||||
"عملیات",
|
"عملیات",
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { SPACING } from "../../../../data/spacing";
|
|||||||
import { SimpleTable } from "../../../../components/simple-table/SimpleTable";
|
import { SimpleTable } from "../../../../components/simple-table/SimpleTable";
|
||||||
import { CreateGuilds } from "../create-guilds/CreateGuilds";
|
import { CreateGuilds } from "../create-guilds/CreateGuilds";
|
||||||
import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";
|
import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";
|
||||||
|
import { provinceGetTotalStewardsService } from "../../services/province-get-total-stewards";
|
||||||
|
|
||||||
export const ManageGuilds = ({ userType }) => {
|
export const ManageGuilds = ({ userType }) => {
|
||||||
const IS_STEWARD = userType === "steward";
|
const IS_STEWARD = userType === "steward";
|
||||||
@@ -37,18 +38,30 @@ export const ManageGuilds = ({ userType }) => {
|
|||||||
|
|
||||||
const fetchApiData = async (page) => {
|
const fetchApiData = async (page) => {
|
||||||
const response = await dispatch(
|
const response = await dispatch(
|
||||||
provinceGetTotalGuildsService({
|
IS_STEWARD
|
||||||
search: "filter",
|
? provinceGetTotalStewardsService({
|
||||||
value: textValue,
|
search: "filter",
|
||||||
page: page,
|
value: textValue,
|
||||||
page_size: perPage,
|
page: page,
|
||||||
steward: false,
|
page_size: perPage,
|
||||||
active_state: activeState,
|
active_state: activeState,
|
||||||
is_real_person: true,
|
is_real_person: true,
|
||||||
role_key: checkPathStartsWith("province")
|
role_key: checkPathStartsWith("province")
|
||||||
? selectedSubUser?.key || ""
|
? selectedSubUser?.key || ""
|
||||||
: "",
|
: "",
|
||||||
})
|
})
|
||||||
|
: provinceGetTotalGuildsService({
|
||||||
|
search: "filter",
|
||||||
|
value: textValue,
|
||||||
|
page: page,
|
||||||
|
page_size: perPage,
|
||||||
|
steward: false,
|
||||||
|
active_state: activeState,
|
||||||
|
is_real_person: true,
|
||||||
|
role_key: checkPathStartsWith("province")
|
||||||
|
? selectedSubUser?.key || ""
|
||||||
|
: "",
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.payload.error) {
|
if (response.payload.error) {
|
||||||
@@ -88,15 +101,15 @@ export const ManageGuilds = ({ userType }) => {
|
|||||||
const commonData = [
|
const commonData = [
|
||||||
page === 1 ? i + 1 : i + perPage * (page - 1) + 1,
|
page === 1 ? i + 1 : i + perPage * (page - 1) + 1,
|
||||||
item?.licenseNumber || "-",
|
item?.licenseNumber || "-",
|
||||||
item?.guildsName || "-",
|
(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?.user?.nationalId ? item?.user?.nationalId : "-",
|
||||||
item?.typeActivity || "-",
|
item?.typeActivity || "-",
|
||||||
item?.areaActivity || "-",
|
item?.areaActivity || "-",
|
||||||
item?.address?.postalCode || "-",
|
item?.address?.postalCode || "-",
|
||||||
`${item?.address?.province?.name || "-"}/${
|
`${item?.address?.province?.name || "-"} / ${
|
||||||
item?.address?.city?.name || "-"
|
item?.address?.city?.name || "-"
|
||||||
}/${item?.address?.address || "-"}`,
|
} / ${item?.address?.address || "-"}`,
|
||||||
item?.steward ? "می باشد" : "نمی باشد",
|
item?.steward ? "می باشد" : "نمی باشد",
|
||||||
item?.limitationAllocation ? "دارد" : "ندارد",
|
item?.limitationAllocation ? "دارد" : "ندارد",
|
||||||
item?.allocationLimit ? item?.allocationLimit : "-",
|
item?.allocationLimit ? item?.allocationLimit : "-",
|
||||||
@@ -196,7 +209,8 @@ export const ManageGuilds = ({ userType }) => {
|
|||||||
if (getRoleFromUrl() !== "KillHouse") {
|
if (getRoleFromUrl() !== "KillHouse") {
|
||||||
commonData.push(
|
commonData.push(
|
||||||
<ManageGuildsOperations
|
<ManageGuildsOperations
|
||||||
guild={item}
|
item={item}
|
||||||
|
userType={userType}
|
||||||
updateTable={updateTable}
|
updateTable={updateTable}
|
||||||
isModal={true}
|
isModal={true}
|
||||||
/>
|
/>
|
||||||
@@ -346,7 +360,7 @@ export const ManageGuilds = ({ userType }) => {
|
|||||||
getRoleFromUrl() === "CityJahad" || getRoleFromUrl() === "CityPoultry"
|
getRoleFromUrl() === "CityJahad" || getRoleFromUrl() === "CityPoultry"
|
||||||
? [
|
? [
|
||||||
"ردیف",
|
"ردیف",
|
||||||
"شناسه صنف",
|
IS_STEWARD ? "شناسه مباشر" : "شناسه صنف",
|
||||||
"نام واحد صنفی",
|
"نام واحد صنفی",
|
||||||
"نام شخص/شرکت",
|
"نام شخص/شرکت",
|
||||||
"کدملی",
|
"کدملی",
|
||||||
@@ -367,7 +381,7 @@ export const ManageGuilds = ({ userType }) => {
|
|||||||
: getRoleFromUrl() === "KillHouse"
|
: getRoleFromUrl() === "KillHouse"
|
||||||
? [
|
? [
|
||||||
"ردیف",
|
"ردیف",
|
||||||
"شناسه صنف",
|
IS_STEWARD ? "شناسه مباشر" : "شناسه صنف",
|
||||||
"نام واحد صنفی",
|
"نام واحد صنفی",
|
||||||
"نام شخص/شرکت",
|
"نام شخص/شرکت",
|
||||||
"کدملی",
|
"کدملی",
|
||||||
@@ -386,7 +400,7 @@ export const ManageGuilds = ({ userType }) => {
|
|||||||
]
|
]
|
||||||
: [
|
: [
|
||||||
"ردیف",
|
"ردیف",
|
||||||
"شناسه صنف",
|
IS_STEWARD ? "شناسه مباشر" : "شناسه صنف",
|
||||||
"نام واحد صنفی",
|
"نام واحد صنفی",
|
||||||
"نام شخص/شرکت",
|
"نام شخص/شرکت",
|
||||||
"کدملی",
|
"کدملی",
|
||||||
|
|||||||
@@ -17,20 +17,26 @@ import {
|
|||||||
Select,
|
Select,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
InputLabel,
|
InputLabel,
|
||||||
|
Autocomplete,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import BusinessIcon from "@mui/icons-material/Business";
|
import BusinessIcon from "@mui/icons-material/Business";
|
||||||
import PublicIcon from "@mui/icons-material/Public";
|
|
||||||
import PersonIcon from "@mui/icons-material/Person";
|
import PersonIcon from "@mui/icons-material/Person";
|
||||||
import BadgeIcon from "@mui/icons-material/Badge";
|
import BadgeIcon from "@mui/icons-material/Badge";
|
||||||
import { Grid } from "../../../../components/grid/Grid";
|
import { Grid } from "../../../../components/grid/Grid";
|
||||||
import { SPACING } from "../../../../data/spacing";
|
import { SPACING } from "../../../../data/spacing";
|
||||||
import { CLOSE_MODAL, OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
|
import {
|
||||||
|
CLOSE_MODAL,
|
||||||
|
LOADING_END,
|
||||||
|
LOADING_START,
|
||||||
|
OPEN_MODAL,
|
||||||
|
} from "../../../../lib/redux/slices/appSlice";
|
||||||
import { AppContext } from "../../../../contexts/AppContext";
|
import { AppContext } from "../../../../contexts/AppContext";
|
||||||
import { provinceGetLegalPersonUnitInfoService } from "../../services/province-get-legal-person-unit-info";
|
import { provinceGetLegalPersonUnitInfoService } from "../../services/province-get-legal-person-unit-info";
|
||||||
import { provinceCreateLegalGuildService } from "../../services/province-create-legal-guild";
|
import { provinceCreateLegalGuildService } from "../../services/province-create-legal-guild";
|
||||||
import { provinceGetCitiesService } from "../../services/province-get-cities";
|
|
||||||
import { provinceGetTypeActivity } from "../../services/provinceGetTypeActivity";
|
import { provinceGetTypeActivity } from "../../services/provinceGetTypeActivity";
|
||||||
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
|
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
|
||||||
|
import { cityGetProvinces } from "../../../city/services/CityGetProvinces";
|
||||||
|
import { cityGetCity } from "../../../city/services/city-get-city";
|
||||||
|
|
||||||
let preservedUserData = null;
|
let preservedUserData = null;
|
||||||
let preservedUserFound = false;
|
let preservedUserFound = false;
|
||||||
@@ -90,10 +96,11 @@ const getValidationSchema = (isAdmin, userFound) =>
|
|||||||
.string()
|
.string()
|
||||||
.required("شناسه حقوقی الزامی است")
|
.required("شناسه حقوقی الزامی است")
|
||||||
.matches(/^[0-9]{11}$/, "شناسه حقوقی باید 11 رقم باشد"),
|
.matches(/^[0-9]{11}$/, "شناسه حقوقی باید 11 رقم باشد"),
|
||||||
first_name: isAdmin || !userFound ? yup.string() : yup.string(),
|
first_name: yup.string(),
|
||||||
last_name: isAdmin || !userFound ? yup.string() : yup.string(),
|
last_name: yup.string(),
|
||||||
unit_name: isAdmin || !userFound ? yup.string() : yup.string(),
|
unit_name: yup.string(),
|
||||||
province: isAdmin || !userFound ? yup.string() : yup.string(),
|
name: yup.string(),
|
||||||
|
province: yup.string(),
|
||||||
city: yup.string(),
|
city: yup.string(),
|
||||||
mobile:
|
mobile:
|
||||||
isAdmin || !userFound
|
isAdmin || !userFound
|
||||||
@@ -106,25 +113,56 @@ const getValidationSchema = (isAdmin, userFound) =>
|
|||||||
(value) => !value || /^[0-9]{11}$/.test(value)
|
(value) => !value || /^[0-9]{11}$/.test(value)
|
||||||
)
|
)
|
||||||
: yup.string(),
|
: yup.string(),
|
||||||
type_activity: isAdmin || !userFound ? yup.string() : yup.string(),
|
type_activity: yup.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const LegalGuildForm = ({ formik, isAdmin, cities, typeActivities }) => {
|
const LegalGuildForm = ({ formik, isAdmin, typeActivities, userType }) => {
|
||||||
|
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 item xs={12}>
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
style={{
|
|
||||||
fontSize: "16px",
|
|
||||||
}}
|
|
||||||
gutterBottom
|
|
||||||
>
|
|
||||||
اطلاعات واحد حقوقی
|
|
||||||
</Typography>
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
<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 direction="column" gap={SPACING.TINY}>
|
||||||
@@ -205,19 +243,23 @@ const LegalGuildForm = ({ formik, isAdmin, cities, typeActivities }) => {
|
|||||||
label="نام واحد"
|
label="نام واحد"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
fullWidth
|
fullWidth
|
||||||
id="unit_name"
|
id={IS_STEWARD ? "name" : "unit_name"}
|
||||||
name="unit_name"
|
name={IS_STEWARD ? "name" : "unit_name"}
|
||||||
value={formik.values.unit_name}
|
value={formik.values[IS_STEWARD ? "name" : "unit_name"]}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
onBlur={formik.handleBlur}
|
onBlur={formik.handleBlur}
|
||||||
error={Boolean(formik.errors.unit_name)}
|
error={Boolean(
|
||||||
helperText={formik.errors.unit_name}
|
formik.errors[IS_STEWARD ? "name" : "unit_name"]
|
||||||
|
)}
|
||||||
|
helperText={
|
||||||
|
formik.errors[IS_STEWARD ? "name" : "unit_name"]
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<InfoBox
|
<InfoBox
|
||||||
icon={BusinessIcon}
|
icon={BusinessIcon}
|
||||||
label="نام واحد"
|
label="نام واحد"
|
||||||
value={formik.values.unit_name}
|
value={formik.values[IS_STEWARD ? "name" : "unit_name"]}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Grid>
|
</Grid>
|
||||||
@@ -227,61 +269,56 @@ const LegalGuildForm = ({ formik, isAdmin, cities, typeActivities }) => {
|
|||||||
<Grid item xs={12} md={6}>
|
<Grid item xs={12} md={6}>
|
||||||
<Grid container direction="column" gap={SPACING.TINY}>
|
<Grid container direction="column" gap={SPACING.TINY}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
{isAdmin ? (
|
<Autocomplete
|
||||||
<TextField
|
size="small"
|
||||||
label="استان"
|
style={{ width: "100%" }}
|
||||||
variant="outlined"
|
disablePortal
|
||||||
fullWidth
|
id="province"
|
||||||
id="province"
|
options={
|
||||||
name="province"
|
provinceData
|
||||||
value={formik.values.province}
|
? provinceData.map((i) => ({
|
||||||
onChange={formik.handleChange}
|
id: i.key,
|
||||||
onBlur={formik.handleBlur}
|
label: i.name,
|
||||||
error={Boolean(formik.errors.province)}
|
}))
|
||||||
helperText={formik.errors.province}
|
: []
|
||||||
/>
|
}
|
||||||
) : (
|
onChange={(e, value) => {
|
||||||
<InfoBox
|
formik.setFieldValue("province", value ? value.id : "");
|
||||||
icon={PublicIcon}
|
formik.setFieldValue("city", "");
|
||||||
label="استان"
|
}}
|
||||||
value={formik.values.province}
|
renderInput={(params) => (
|
||||||
/>
|
<TextField {...params} label={"استان"} />
|
||||||
)}
|
)}
|
||||||
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<FormControl fullWidth>
|
<Autocomplete
|
||||||
<InputLabel id="city-select-label">شهرستان</InputLabel>
|
size="small"
|
||||||
<Select
|
minWidth={210}
|
||||||
labelId="city-select-label"
|
style={{ width: "100%" }}
|
||||||
id="city"
|
disabled={!formik.values.province}
|
||||||
name="city"
|
disablePortal
|
||||||
value={formik.values.city || ""}
|
id="city"
|
||||||
label="شهرستان"
|
options={
|
||||||
onChange={(e) => {
|
cityData
|
||||||
formik.setFieldValue("city", e.target.value);
|
? cityData.map((i) => ({ id: i.name, label: i.name }))
|
||||||
}}
|
: []
|
||||||
onBlur={formik.handleBlur}
|
}
|
||||||
disabled={false}
|
onChange={(e, value) => {
|
||||||
>
|
formik.setFieldValue("city", value ? value.id : "");
|
||||||
{cities.map((city) => (
|
}}
|
||||||
<MenuItem key={city.key} value={city.name}>
|
renderInput={(params) => (
|
||||||
{city.name}
|
<TextField
|
||||||
</MenuItem>
|
{...params}
|
||||||
))}
|
label={
|
||||||
{formik.values.city &&
|
formik?.values?.city
|
||||||
!cities.some(
|
? `شهر ${formik?.values?.city}`
|
||||||
(city) => city.name === formik.values.city
|
: "شهر را انتخاب کنید"
|
||||||
) && (
|
}
|
||||||
<MenuItem
|
/>
|
||||||
key="current-value"
|
)}
|
||||||
value={formik.values.city}
|
/>
|
||||||
>
|
|
||||||
{formik.values.city}
|
|
||||||
</MenuItem>
|
|
||||||
)}
|
|
||||||
</Select>
|
|
||||||
</FormControl>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
@@ -396,44 +433,45 @@ const InquiryForm = ({ onInquiry, nationalCode, setNationalCode }) => {
|
|||||||
export const ProvinceLegalGuildsForm = ({
|
export const ProvinceLegalGuildsForm = ({
|
||||||
onClose,
|
onClose,
|
||||||
updateTable,
|
updateTable,
|
||||||
guild,
|
item,
|
||||||
userType,
|
userType,
|
||||||
}) => {
|
}) => {
|
||||||
const IS_STEWARD = userType === "steward";
|
const IS_STEWARD = userType === "steward";
|
||||||
|
const userInitialValue = {
|
||||||
|
national_id: item?.user?.national_id || "",
|
||||||
|
first_name: item?.user?.firstName || "",
|
||||||
|
last_name: item?.user?.lastName || "",
|
||||||
|
province: item?.address?.province?.name || "",
|
||||||
|
city: item?.address?.city?.name || "",
|
||||||
|
address: item?.address?.address || "",
|
||||||
|
mobile: item?.user?.mobile || "",
|
||||||
|
type_activity: item?.typeActivity || "",
|
||||||
|
};
|
||||||
|
|
||||||
|
if (IS_STEWARD) {
|
||||||
|
userInitialValue["name"] = item?.name;
|
||||||
|
} else {
|
||||||
|
userInitialValue["unit_name"] = item?.unitName;
|
||||||
|
}
|
||||||
|
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [openNotif] = useContext(AppContext);
|
const [openNotif] = useContext(AppContext);
|
||||||
const [nationalCode, setNationalCode] = useState(
|
const [nationalCode, setNationalCode] = useState(
|
||||||
guild?.user?.national_id ||
|
item?.user?.national_id ||
|
||||||
guild?.national_code ||
|
item?.national_code ||
|
||||||
preservedNationalCode ||
|
preservedNationalCode ||
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
const [userData, setUserData] = useState(
|
const [userData, setUserData] = useState(
|
||||||
guild
|
item ? userInitialValue : preservedUserData
|
||||||
? {
|
|
||||||
national_id: guild?.user?.national_id || guild?.national_code || "",
|
|
||||||
first_name: guild?.user?.first_name || "",
|
|
||||||
last_name: guild?.user?.last_name || "",
|
|
||||||
unit_name: guild?.guilds_name || "",
|
|
||||||
province: guild?.address?.province?.name || "",
|
|
||||||
city: guild?.address?.city?.name || "",
|
|
||||||
address: guild?.address?.address || "",
|
|
||||||
mobile: guild?.user?.mobile || "",
|
|
||||||
type_activity: guild?.type_activity || "",
|
|
||||||
}
|
|
||||||
: preservedUserData
|
|
||||||
);
|
);
|
||||||
const [userFound, setUserFound] = useState(guild ? true : preservedUserFound);
|
const [userFound, setUserFound] = useState(item ? true : preservedUserFound);
|
||||||
const [cities, setCities] = useState([]);
|
|
||||||
const [typeActivities, setTypeActivities] = useState([]);
|
const [typeActivities, setTypeActivities] = useState([]);
|
||||||
|
|
||||||
const currentRole = getRoleFromUrl();
|
const currentRole = getRoleFromUrl();
|
||||||
const isAdmin = currentRole === "AdminX";
|
const isAdmin = currentRole === "AdminX";
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(provinceGetCitiesService()).then((r) => {
|
|
||||||
setCities(r.payload.data || []);
|
|
||||||
});
|
|
||||||
dispatch(provinceGetTypeActivity()).then((r) => {
|
dispatch(provinceGetTypeActivity()).then((r) => {
|
||||||
setTypeActivities(r.payload.data || []);
|
setTypeActivities(r.payload.data || []);
|
||||||
});
|
});
|
||||||
@@ -460,11 +498,14 @@ export const ProvinceLegalGuildsForm = ({
|
|||||||
// Update modal with larger size
|
// Update modal with larger size
|
||||||
dispatch(
|
dispatch(
|
||||||
OPEN_MODAL({
|
OPEN_MODAL({
|
||||||
title: `ثبت ${IS_STEWARD ? "مباشر" : "صنف"} حقوقی`,
|
title: `${item ? "ویرایش" : "ثبت"} ${
|
||||||
|
IS_STEWARD ? "مباشر" : "صنف"
|
||||||
|
} حقوقی`,
|
||||||
content: (
|
content: (
|
||||||
<ProvinceLegalGuildsForm
|
<ProvinceLegalGuildsForm
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
updateTable={updateTable}
|
updateTable={updateTable}
|
||||||
|
userType={userType}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
size: { xs: "96vw", md: "90vw", lg: "600px" },
|
size: { xs: "96vw", md: "90vw", lg: "600px" },
|
||||||
@@ -489,16 +530,29 @@ export const ProvinceLegalGuildsForm = ({
|
|||||||
setUserFound(false);
|
setUserFound(false);
|
||||||
if (isAdmin) {
|
if (isAdmin) {
|
||||||
// Admin can create even if user not found
|
// Admin can create even if user not found
|
||||||
setUserData({
|
setUserData(
|
||||||
is_real_person: false,
|
IS_STEWARD
|
||||||
first_name: "",
|
? {
|
||||||
last_name: "",
|
is_real_person: false,
|
||||||
national_id: nationalCode,
|
first_name: "",
|
||||||
province: "",
|
last_name: "",
|
||||||
unit_name: "",
|
national_id: nationalCode,
|
||||||
mobile: "",
|
province: "",
|
||||||
type_activity: "",
|
name: "",
|
||||||
});
|
mobile: "",
|
||||||
|
type_activity: "",
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
is_real_person: false,
|
||||||
|
first_name: "",
|
||||||
|
last_name: "",
|
||||||
|
national_id: nationalCode,
|
||||||
|
province: "",
|
||||||
|
unit_name: "",
|
||||||
|
mobile: "",
|
||||||
|
type_activity: "",
|
||||||
|
}
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
openNotif({
|
openNotif({
|
||||||
vertical: "top",
|
vertical: "top",
|
||||||
@@ -524,21 +578,28 @@ export const ProvinceLegalGuildsForm = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [dispatch, nationalCode, openNotif, isAdmin]);
|
}, [dispatch, nationalCode, openNotif, isAdmin, IS_STEWARD]);
|
||||||
|
|
||||||
|
const formikIntitialValues = {
|
||||||
|
national_id: userData?.national_id || userData?.nationalId || "",
|
||||||
|
first_name: userData?.first_name || userData?.firstName || "",
|
||||||
|
last_name: userData?.last_name || userData?.lastName || "",
|
||||||
|
province: userData?.province || "",
|
||||||
|
city: userData?.city || "",
|
||||||
|
address: userData?.address || "",
|
||||||
|
mobile: userData?.mobile || "",
|
||||||
|
type_activity: userData?.type_activity || "",
|
||||||
|
};
|
||||||
|
|
||||||
|
if (IS_STEWARD) {
|
||||||
|
formikIntitialValues["name"] = userData?.name;
|
||||||
|
} else {
|
||||||
|
formikIntitialValues["unit_name"] = userData?.unit_name;
|
||||||
|
}
|
||||||
|
|
||||||
const formik = useFormik({
|
const formik = useFormik({
|
||||||
initialValues: {
|
initialValues: formikIntitialValues,
|
||||||
national_id: userData?.national_id || userData?.nationalId || "",
|
validationSchema: getValidationSchema(isAdmin, userFound, userType),
|
||||||
first_name: userData?.first_name || userData?.firstName || "",
|
|
||||||
last_name: userData?.last_name || userData?.lastName || "",
|
|
||||||
unit_name: userData?.unit_name || userData?.unitName || "",
|
|
||||||
province: userData?.province || "",
|
|
||||||
city: userData?.city || "",
|
|
||||||
address: userData?.address || "",
|
|
||||||
mobile: userData?.mobile || "",
|
|
||||||
type_activity: userData?.type_activity || "",
|
|
||||||
},
|
|
||||||
validationSchema: getValidationSchema(isAdmin, userFound),
|
|
||||||
enableReinitialize: true,
|
enableReinitialize: true,
|
||||||
onSubmit: (values) => {
|
onSubmit: (values) => {
|
||||||
// Find type_activity key from the title
|
// Find type_activity key from the title
|
||||||
@@ -553,13 +614,18 @@ export const ProvinceLegalGuildsForm = ({
|
|||||||
national_id: values.national_id,
|
national_id: values.national_id,
|
||||||
province: values.province,
|
province: values.province,
|
||||||
address: values.address || "",
|
address: values.address || "",
|
||||||
unit_name: values.unit_name,
|
|
||||||
mobile: values.mobile || "",
|
mobile: values.mobile || "",
|
||||||
city: values.city,
|
city: values.city,
|
||||||
type_activity: typeActivityKey, // Send key instead of title
|
type_activity: typeActivityKey, // Send key instead of title
|
||||||
...(guild?.key && { guilds_key: guild.key }), // Include guild key for editing
|
...(item?.key && { guilds_key: item.key }), // Include guild key for editing
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (IS_STEWARD) {
|
||||||
|
submitData["name"] = values?.name;
|
||||||
|
} else {
|
||||||
|
submitData["unit_name"] = values?.unit_name;
|
||||||
|
}
|
||||||
|
|
||||||
dispatch(provinceCreateLegalGuildService(submitData)).then((r) => {
|
dispatch(provinceCreateLegalGuildService(submitData)).then((r) => {
|
||||||
if (r.payload.error) {
|
if (r.payload.error) {
|
||||||
openNotif({
|
openNotif({
|
||||||
@@ -584,7 +650,7 @@ export const ProvinceLegalGuildsForm = ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!userData && !guild) {
|
if (!userData && !item) {
|
||||||
return (
|
return (
|
||||||
<InquiryForm
|
<InquiryForm
|
||||||
onInquiry={handleInquiry}
|
onInquiry={handleInquiry}
|
||||||
@@ -598,8 +664,8 @@ export const ProvinceLegalGuildsForm = ({
|
|||||||
<LegalGuildForm
|
<LegalGuildForm
|
||||||
formik={formik}
|
formik={formik}
|
||||||
isAdmin={isAdmin}
|
isAdmin={isAdmin}
|
||||||
cities={cities}
|
|
||||||
typeActivities={typeActivities}
|
typeActivities={typeActivities}
|
||||||
|
userType={userType}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { Button, TextField } from "@mui/material";
|
import { Button, TextField } from "@mui/material";
|
||||||
import { DatePicker } from "@mui/x-date-pickers";
|
|
||||||
import moment from "moment";
|
|
||||||
import { Grid } from "../../../../components/grid/Grid";
|
import { Grid } from "../../../../components/grid/Grid";
|
||||||
import { SPACING } from "../../../../data/spacing";
|
import { SPACING } from "../../../../data/spacing";
|
||||||
import { CLOSE_MODAL, OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
|
import { CLOSE_MODAL, OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
|
||||||
@@ -11,6 +9,8 @@ import { ProvinceLegalGuildsForm } from "./ProvinceLegalGuildsForm";
|
|||||||
import { ProvinceLegalGuildsOperations } from "./ProvinceLegalGuildsOperations";
|
import { ProvinceLegalGuildsOperations } from "./ProvinceLegalGuildsOperations";
|
||||||
import ResponsiveTable from "../../../../components/responsive-table/ResponsiveTable";
|
import ResponsiveTable from "../../../../components/responsive-table/ResponsiveTable";
|
||||||
import { RiSearchLine } from "react-icons/ri";
|
import { RiSearchLine } from "react-icons/ri";
|
||||||
|
import { provinceGetTotalStewardsService } from "../../services/province-get-total-stewards";
|
||||||
|
import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";
|
||||||
|
|
||||||
export const ProvinceLegalGuildsInProvince = ({ userType }) => {
|
export const ProvinceLegalGuildsInProvince = ({ userType }) => {
|
||||||
const IS_STEWARD = userType === "steward";
|
const IS_STEWARD = userType === "steward";
|
||||||
@@ -22,29 +22,40 @@ export const ProvinceLegalGuildsInProvince = ({ userType }) => {
|
|||||||
const [textValue, setTextValue] = useState("");
|
const [textValue, setTextValue] = useState("");
|
||||||
const [page, setPage] = useState(1);
|
const [page, setPage] = useState(1);
|
||||||
const [tableData, setTableData] = useState([]);
|
const [tableData, setTableData] = useState([]);
|
||||||
const [selectedDate1, setSelectedDate1] = useState(null);
|
const selectedSubUser = useSelector(
|
||||||
const [selectedDate2, setSelectedDate2] = useState(null);
|
(state) => state.userSlice.selectedSubUser
|
||||||
|
);
|
||||||
|
|
||||||
const handleTextChange = (e) => setTextValue(e.target.value);
|
const handleTextChange = (e) => setTextValue(e.target.value);
|
||||||
|
|
||||||
const fetchApiData = async (pageNum) => {
|
const fetchApiData = async (pageNum) => {
|
||||||
const response = await dispatch(
|
let response = null;
|
||||||
provinceGetTotalGuildsService({
|
if (IS_STEWARD) {
|
||||||
search: "filter",
|
response = await dispatch(
|
||||||
value: textValue,
|
provinceGetTotalStewardsService({
|
||||||
page: pageNum,
|
search: "filter",
|
||||||
page_size: perPage,
|
value: textValue,
|
||||||
steward: false,
|
page: page,
|
||||||
active_state: "all",
|
page_size: perPage,
|
||||||
is_real_person: false,
|
is_real_person: false,
|
||||||
...(selectedDate1 && {
|
role_key: checkPathStartsWith("province")
|
||||||
date_from: moment(selectedDate1).format("YYYY-MM-DD"),
|
? selectedSubUser?.key || ""
|
||||||
}),
|
: "",
|
||||||
...(selectedDate2 && {
|
})
|
||||||
date_to: moment(selectedDate2).format("YYYY-MM-DD"),
|
);
|
||||||
}),
|
} else {
|
||||||
})
|
response = await dispatch(
|
||||||
);
|
provinceGetTotalGuildsService({
|
||||||
|
search: "filter",
|
||||||
|
value: textValue,
|
||||||
|
page: pageNum,
|
||||||
|
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);
|
||||||
@@ -80,7 +91,7 @@ export const ProvinceLegalGuildsInProvince = ({ userType }) => {
|
|||||||
return [
|
return [
|
||||||
page === 1 ? i + 1 : i + perPage * (page - 1) + 1,
|
page === 1 ? i + 1 : i + perPage * (page - 1) + 1,
|
||||||
item?.nationalId || "-",
|
item?.nationalId || "-",
|
||||||
item?.guildsName || "-",
|
(IS_STEWARD ? item?.name : item?.guildsName) || "-",
|
||||||
`${item?.user?.fullname || "-"}`,
|
`${item?.user?.fullname || "-"}`,
|
||||||
item?.user?.mobile || "-",
|
item?.user?.mobile || "-",
|
||||||
item?.address?.province?.name || "-",
|
item?.address?.province?.name || "-",
|
||||||
@@ -89,7 +100,7 @@ export const ProvinceLegalGuildsInProvince = ({ userType }) => {
|
|||||||
item?.active ? "فعال" : "غیر فعال",
|
item?.active ? "فعال" : "غیر فعال",
|
||||||
<ProvinceLegalGuildsOperations
|
<ProvinceLegalGuildsOperations
|
||||||
key={`operations-${item?.key || i}`}
|
key={`operations-${item?.key || i}`}
|
||||||
guild={item}
|
item={item}
|
||||||
updateTable={updateTableData}
|
updateTable={updateTableData}
|
||||||
userType={userType}
|
userType={userType}
|
||||||
/>,
|
/>,
|
||||||
@@ -119,12 +130,6 @@ export const ProvinceLegalGuildsInProvince = ({ userType }) => {
|
|||||||
steward: false,
|
steward: false,
|
||||||
active_state: "all",
|
active_state: "all",
|
||||||
is_real_person: false,
|
is_real_person: false,
|
||||||
...(selectedDate1 && {
|
|
||||||
date_from: moment(selectedDate1).format("YYYY-MM-DD"),
|
|
||||||
}),
|
|
||||||
...(selectedDate2 && {
|
|
||||||
date_to: moment(selectedDate2).format("YYYY-MM-DD"),
|
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -156,13 +161,13 @@ export const ProvinceLegalGuildsInProvince = ({ userType }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid container gap={SPACING.SMALL} p={2}>
|
<Grid item gap={SPACING.SMALL} p={2} xs={12}>
|
||||||
<Grid
|
<Grid
|
||||||
container
|
container
|
||||||
xs={12}
|
|
||||||
justifyContent="start"
|
justifyContent="start"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
gap={SPACING.SMALL}
|
gap={SPACING.SMALL}
|
||||||
|
mb={SPACING.SMALL}
|
||||||
>
|
>
|
||||||
<Button variant="contained" color="primary" onClick={handleOpenModal}>
|
<Button variant="contained" color="primary" onClick={handleOpenModal}>
|
||||||
{`ثبت ${IS_STEWARD ? "مباشر" : "واحد صنفی"}`}
|
{`ثبت ${IS_STEWARD ? "مباشر" : "واحد صنفی"}`}
|
||||||
@@ -179,28 +184,6 @@ export const ProvinceLegalGuildsInProvince = ({ userType }) => {
|
|||||||
onChange={handleTextChange}
|
onChange={handleTextChange}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DatePicker
|
|
||||||
label="از تاریخ"
|
|
||||||
value={selectedDate1}
|
|
||||||
onChange={(newValue) => {
|
|
||||||
setSelectedDate1(newValue);
|
|
||||||
}}
|
|
||||||
renderInput={(params) => (
|
|
||||||
<TextField {...params} size="small" style={{ width: 160 }} />
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<DatePicker
|
|
||||||
label="تا تاریخ"
|
|
||||||
value={selectedDate2}
|
|
||||||
onChange={(newValue) => {
|
|
||||||
setSelectedDate2(newValue);
|
|
||||||
}}
|
|
||||||
renderInput={(params) => (
|
|
||||||
<TextField {...params} size="small" style={{ width: 160 }} />
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
|
|||||||
@@ -10,23 +10,34 @@ import {
|
|||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import EditIcon from "@mui/icons-material/Edit";
|
import EditIcon from "@mui/icons-material/Edit";
|
||||||
import DeleteIcon from "@mui/icons-material/Delete";
|
import DeleteIcon from "@mui/icons-material/Delete";
|
||||||
import { useState } from "react";
|
import { useContext, useState } from "react";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { Grid } from "../../../../components/grid/Grid";
|
import { Grid } from "../../../../components/grid/Grid";
|
||||||
import { OPEN_MODAL, CLOSE_MODAL } from "../../../../lib/redux/slices/appSlice";
|
import {
|
||||||
|
OPEN_MODAL,
|
||||||
|
CLOSE_MODAL,
|
||||||
|
LOADING_END,
|
||||||
|
LOADING_START,
|
||||||
|
DRAWER,
|
||||||
|
} from "../../../../lib/redux/slices/appSlice";
|
||||||
import { ProvinceLegalGuildsForm } from "./ProvinceLegalGuildsForm";
|
import { ProvinceLegalGuildsForm } from "./ProvinceLegalGuildsForm";
|
||||||
import TuneIcon from "@mui/icons-material/Tune";
|
import TuneIcon from "@mui/icons-material/Tune";
|
||||||
|
import { AppContext } from "../../../../contexts/AppContext";
|
||||||
|
import { updateStewardService } from "../../services/update-steward";
|
||||||
|
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
export const ProvinceLegalGuildsOperations = ({
|
export const ProvinceLegalGuildsOperations = ({
|
||||||
guild,
|
item,
|
||||||
updateTable,
|
updateTable,
|
||||||
userType,
|
userType,
|
||||||
}) => {
|
}) => {
|
||||||
const IS_STEWARD = userType === "steward";
|
const IS_STEWARD = userType === "steward";
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [checked, setChecked] = useState(guild?.active);
|
const [checked, setChecked] = useState(item?.active);
|
||||||
const [popoverOpen, setPopoverOpen] = useState(false);
|
const [popoverOpen, setPopoverOpen] = useState(false);
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
|
const [openNotif] = useContext(AppContext);
|
||||||
|
|
||||||
const openPopover = (event) => {
|
const openPopover = (event) => {
|
||||||
setPopoverOpen(true);
|
setPopoverOpen(true);
|
||||||
@@ -38,9 +49,68 @@ export const ProvinceLegalGuildsOperations = ({
|
|||||||
setAnchorEl(null);
|
setAnchorEl(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleActivationChange = (event) => {
|
const handleActivationChange = async (event) => {
|
||||||
const newChecked = event.target.checked;
|
const newChecked = event.target.checked;
|
||||||
setChecked(newChecked);
|
setChecked(newChecked);
|
||||||
|
dispatch(LOADING_START());
|
||||||
|
try {
|
||||||
|
let response = null;
|
||||||
|
if (IS_STEWARD) {
|
||||||
|
response = await dispatch(
|
||||||
|
updateStewardService({
|
||||||
|
params: {
|
||||||
|
id: item?.id,
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
active: newChecked,
|
||||||
|
role: getRoleFromUrl(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
).then(() => {
|
||||||
|
updateTable();
|
||||||
|
dispatch(DRAWER({ right: false, bottom: false, content: null }));
|
||||||
|
openNotif({
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "center",
|
||||||
|
msg: "عملیات با موفقیت انجام شد.",
|
||||||
|
severity: "success",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
response = await axios.put("guilds/0/", {
|
||||||
|
guilds_key: item?.key,
|
||||||
|
active: newChecked,
|
||||||
|
role: getRoleFromUrl(),
|
||||||
|
});
|
||||||
|
if (response.status === 200) {
|
||||||
|
updateTable();
|
||||||
|
dispatch(DRAWER({ right: false, bottom: false, content: null }));
|
||||||
|
openNotif({
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "center",
|
||||||
|
msg: "عملیات با موفقیت انجام شد.",
|
||||||
|
severity: "success",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatch(LOADING_END());
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
dispatch(LOADING_END());
|
||||||
|
const errorMessage =
|
||||||
|
error.response?.data?.result ||
|
||||||
|
error.response?.data?.error ||
|
||||||
|
"خطا در انجام عملیات";
|
||||||
|
openNotif({
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "center",
|
||||||
|
msg: errorMessage,
|
||||||
|
severity: "error",
|
||||||
|
});
|
||||||
|
// Revert the checkbox state on error
|
||||||
|
setChecked(!newChecked);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = () => {
|
const handleDelete = () => {
|
||||||
@@ -68,6 +138,41 @@ export const ProvinceLegalGuildsOperations = ({
|
|||||||
variant="contained"
|
variant="contained"
|
||||||
color="error"
|
color="error"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
if (IS_STEWARD) {
|
||||||
|
dispatch(
|
||||||
|
updateStewardService({
|
||||||
|
params: {
|
||||||
|
id: item?.id,
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
active: false,
|
||||||
|
trash: true,
|
||||||
|
role: getRoleFromUrl(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
updateTable();
|
||||||
|
openNotif({
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "center",
|
||||||
|
msg: "عملیات حذف با موفقیت انجام شد.",
|
||||||
|
severity: "error",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
const errorMessage =
|
||||||
|
error.response?.data?.result ||
|
||||||
|
error.response?.data?.error ||
|
||||||
|
"خطا در انجام عملیات";
|
||||||
|
openNotif({
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "center",
|
||||||
|
msg: errorMessage,
|
||||||
|
severity: "error",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
dispatch(CLOSE_MODAL());
|
dispatch(CLOSE_MODAL());
|
||||||
}}
|
}}
|
||||||
sx={{ width: "48%" }}
|
sx={{ width: "48%" }}
|
||||||
@@ -88,9 +193,10 @@ export const ProvinceLegalGuildsOperations = ({
|
|||||||
title: `ویرایش ${IS_STEWARD ? "مباشر" : "صنف"} حقوقی`,
|
title: `ویرایش ${IS_STEWARD ? "مباشر" : "صنف"} حقوقی`,
|
||||||
content: (
|
content: (
|
||||||
<ProvinceLegalGuildsForm
|
<ProvinceLegalGuildsForm
|
||||||
guild={guild}
|
item={item}
|
||||||
onClose={() => dispatch(CLOSE_MODAL())}
|
onClose={() => dispatch(CLOSE_MODAL())}
|
||||||
updateTable={updateTable}
|
updateTable={updateTable}
|
||||||
|
userType={userType}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
size: window.innerWidth <= 600 ? "small" : "auto",
|
size: window.innerWidth <= 600 ? "small" : "auto",
|
||||||
@@ -119,7 +225,7 @@ export const ProvinceLegalGuildsOperations = ({
|
|||||||
horizontal: "left",
|
horizontal: "left",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div style={{ padding: 10 }}>
|
<div style={{ padding: 10, width: 120 }}>
|
||||||
<Grid
|
<Grid
|
||||||
container
|
container
|
||||||
direction="column"
|
direction="column"
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ const validationSchema = yup.object({
|
|||||||
export const ProvinceManageGuildsSubmitRegisterCode = ({
|
export const ProvinceManageGuildsSubmitRegisterCode = ({
|
||||||
item,
|
item,
|
||||||
updateTable,
|
updateTable,
|
||||||
|
userType,
|
||||||
}) => {
|
}) => {
|
||||||
|
const IS_STEWARD = userType === "steward";
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const [openNotif] = useContext(AppContext);
|
const [openNotif] = useContext(AppContext);
|
||||||
@@ -32,12 +34,21 @@ export const ProvinceManageGuildsSubmitRegisterCode = ({
|
|||||||
validationSchema: validationSchema,
|
validationSchema: validationSchema,
|
||||||
onSubmit: (values) => {
|
onSubmit: (values) => {
|
||||||
dispatch(
|
dispatch(
|
||||||
checkKillhouseRequestGuildService({
|
checkKillhouseRequestGuildService(
|
||||||
guilds_key: item.key,
|
IS_STEWARD
|
||||||
state: "accepted",
|
? {
|
||||||
code: values.verificationCode,
|
steward_key: item.key,
|
||||||
role: getRoleFromUrl(),
|
state: "accepted",
|
||||||
})
|
code: values.verificationCode,
|
||||||
|
role: getRoleFromUrl(),
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
guilds_key: item.key,
|
||||||
|
state: "accepted",
|
||||||
|
code: values.verificationCode,
|
||||||
|
role: getRoleFromUrl(),
|
||||||
|
}
|
||||||
|
)
|
||||||
).then((r) => {
|
).then((r) => {
|
||||||
if (r.payload.error) {
|
if (r.payload.error) {
|
||||||
openNotif({
|
openNotif({
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ import FavoriteIcon from "@mui/icons-material/Favorite";
|
|||||||
import CakeIcon from "@mui/icons-material/Cake";
|
import CakeIcon from "@mui/icons-material/Cake";
|
||||||
import HomeIcon from "@mui/icons-material/Home";
|
import HomeIcon from "@mui/icons-material/Home";
|
||||||
import { formatJustDate } from "../../../../utils/formatTime";
|
import { formatJustDate } from "../../../../utils/formatTime";
|
||||||
export const ViewGuildDetails = ({ guild }) => {
|
|
||||||
|
export const ViewGuildDetails = ({ item, userType }) => {
|
||||||
|
const IS_STEWARD = userType === "steward";
|
||||||
// Helper function to safely render values
|
// Helper function to safely render values
|
||||||
const renderValue = (value) => {
|
const renderValue = (value) => {
|
||||||
if (!value) return "-";
|
if (!value) return "-";
|
||||||
@@ -31,11 +33,11 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Extract nested values
|
// Extract nested values
|
||||||
const provinceName = guild?.address?.province?.name || "-";
|
const provinceName = item?.address?.province?.name || "-";
|
||||||
const cityName = guild?.address?.city?.name || "-";
|
const cityName = item?.address?.city?.name || "-";
|
||||||
const postalCode = guild?.address?.postalCode || "-";
|
const postalCode = item?.address?.postalCode || "-";
|
||||||
const guildCategory = guild?.guildAreaActivity?.title || "-";
|
const guildCategory = item?.guildAreaActivity?.title || "-";
|
||||||
const unionName = guild?.unionName || "-";
|
const unionName = item?.unionName || "-";
|
||||||
return (
|
return (
|
||||||
<Grid
|
<Grid
|
||||||
container
|
container
|
||||||
@@ -85,7 +87,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
کد ملی
|
کد ملی
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{renderValue(guild?.user?.nationalId)}
|
{renderValue(item?.user?.nationalId)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -106,7 +108,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
نام
|
نام
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{renderValue(guild?.user?.firstName)}
|
{renderValue(item?.user?.firstName)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -128,7 +130,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
نام خانوادگی
|
نام خانوادگی
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{renderValue(guild?.user?.lastName)}
|
{renderValue(item?.user?.lastName)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -149,7 +151,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
شماره شناسنامه
|
شماره شناسنامه
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{renderValue(guild?.user?.nationalCode)}
|
{renderValue(item?.user?.nationalCode)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -170,7 +172,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
در قید حیات
|
در قید حیات
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{guild?.user?.isAlive ? "بلی" : "خیر"}
|
{item?.user?.isAlive ? "بلی" : "خیر"}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -202,7 +204,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
تاریخ تولد
|
تاریخ تولد
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{renderValue(guild?.user?.birthday)}
|
{renderValue(item?.user?.birthday)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -224,7 +226,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
نام پدر
|
نام پدر
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{renderValue(guild?.user?.fatherName)}
|
{renderValue(item?.user?.fatherName)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -246,9 +248,9 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
جنسیت
|
جنسیت
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{guild?.user?.gender === "True"
|
{item?.user?.gender === "True"
|
||||||
? "مرد"
|
? "مرد"
|
||||||
: guild?.user?.gender === "False"
|
: item?.user?.gender === "False"
|
||||||
? "زن"
|
? "زن"
|
||||||
: "-"}
|
: "-"}
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -271,7 +273,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
شماره همراه
|
شماره همراه
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{renderValue(guild?.user?.mobile)}
|
{renderValue(item?.user?.mobile)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -293,7 +295,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
شهر
|
شهر
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{renderValue(guild?.user?.city)}
|
{renderValue(item?.user?.city)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -307,7 +309,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
<Grid container gap={SPACING.TINY} direction="column">
|
<Grid container gap={SPACING.TINY} direction="column">
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Typography variant="h6" gutterBottom>
|
<Typography variant="h6" gutterBottom>
|
||||||
اطلاعات صنفی
|
اطلاعات واحد
|
||||||
</Typography>
|
</Typography>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container xs={12}>
|
<Grid container xs={12}>
|
||||||
@@ -335,7 +337,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
نام واحد
|
نام واحد
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{renderValue(guild?.guildsName)}
|
{renderValue(item?.guildsName)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -415,7 +417,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
تاریخ انقضا مجوز
|
تاریخ انقضا مجوز
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{formatJustDate(guild?.licenseExpireDate)}
|
{formatJustDate(item?.licenseExpireDate)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -436,7 +438,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
شماره مجوز
|
شماره مجوز
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{renderValue(guild?.licenseNumber)}
|
{renderValue(item?.licenseNumber)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -505,7 +507,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
شماره تلفن
|
شماره تلفن
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{renderValue(guild?.phone)}
|
{renderValue(item?.phone)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -527,7 +529,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
آیا اتباع است؟
|
آیا اتباع است؟
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{guild?.isForeignNational ? "بلی" : "خیر"}
|
{item?.isForeignNational ? "بلی" : "خیر"}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -549,7 +551,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
نام شرکت
|
نام شرکت
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{renderValue(guild?.companyName)}
|
{renderValue(item?.companyName)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -571,7 +573,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
شناسه ملی شرکت
|
شناسه ملی شرکت
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{renderValue(guild?.companyIdentifier)}
|
{renderValue(item?.companyIdentifier)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -593,7 +595,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
وضعیت مجوز
|
وضعیت مجوز
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{renderValue(guild?.licenseStatus)}
|
{renderValue(item?.licenseStatus)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -614,7 +616,7 @@ export const ViewGuildDetails = ({ guild }) => {
|
|||||||
آدرس
|
آدرس
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{renderValue(guild?.address?.address)}
|
{renderValue(item?.address?.address)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -29,3 +29,21 @@ export const provinceResendRegisterCodeStateService = createAsyncThunk(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const provinceSendAgainSmsForRegisterCodeSteward = createAsyncThunk(
|
||||||
|
"SEND_AGAIN_SMS_FOR_REGISTER_CODE_STEWARD",
|
||||||
|
async (d, { dispatch }) => {
|
||||||
|
dispatch(LOADING_START());
|
||||||
|
try {
|
||||||
|
const { data, status } = await axios.post(
|
||||||
|
"send_again_sms_for_register_code_steward/",
|
||||||
|
d
|
||||||
|
);
|
||||||
|
dispatch(LOADING_END());
|
||||||
|
return { data, status };
|
||||||
|
} catch (e) {
|
||||||
|
dispatch(LOADING_END());
|
||||||
|
return { error: e.response.data.result };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export const provinceGetTotalStewardsService = createAsyncThunk(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
dispatch(LOADING_END());
|
dispatch(LOADING_END());
|
||||||
return { data, status };
|
return { data: data, status };
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
dispatch(LOADING_END());
|
dispatch(LOADING_END());
|
||||||
return {
|
return {
|
||||||
|
|||||||
21
src/features/province/services/update-steward.js
Normal file
21
src/features/province/services/update-steward.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||||
|
import axios from "axios";
|
||||||
|
import { LOADING_END, LOADING_START } from "../../../lib/redux/slices/appSlice";
|
||||||
|
|
||||||
|
export const updateStewardService = createAsyncThunk(
|
||||||
|
"CHECK_KILLHOUSE_REQUEST_STEWARD_SERVICE",
|
||||||
|
async (d, { dispatch }) => {
|
||||||
|
try {
|
||||||
|
dispatch(LOADING_START());
|
||||||
|
const { data, status } = await axios.put(
|
||||||
|
`main_steward_view/${d?.params?.id}/`,
|
||||||
|
d?.body
|
||||||
|
);
|
||||||
|
dispatch(LOADING_END());
|
||||||
|
return { data, status };
|
||||||
|
} catch (e) {
|
||||||
|
dispatch(LOADING_END());
|
||||||
|
return { error: e.response.data.result };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user