add: document upload and sign
This commit is contained in:
@@ -12,6 +12,11 @@ import { Popover } from "../components/PopOver/PopOver";
|
||||
import Button from "../components/Button/Button";
|
||||
import { Tooltip } from "../components/Tooltip/Tooltip";
|
||||
import { DistributeFromDistribution } from "../partials/tagging/DistributeFromDistribution";
|
||||
import { DocumentOperation } from "../components/DocumentOperation/DocumentOperation";
|
||||
import { DocumentDownloader } from "../components/DocumentDownloader/DocumentDownloader";
|
||||
import { BooleanQuestion } from "../components/BooleanQuestion/BooleanQuestion";
|
||||
import { useUserProfileStore } from "../context/zustand-store/userStore";
|
||||
import { DeleteButtonForPopOver } from "../components/PopOverButtons/PopOverButtons";
|
||||
|
||||
const speciesMap: Record<number, string> = {
|
||||
1: "گاو",
|
||||
@@ -47,6 +52,37 @@ export default function TagDistribtutionDetails() {
|
||||
enabled: !!id,
|
||||
});
|
||||
|
||||
const { profile } = useUserProfileStore();
|
||||
|
||||
const showAssignDocColumn =
|
||||
childData?.results?.some(
|
||||
(item: any) =>
|
||||
profile?.role?.type?.key === "ADM" ||
|
||||
profile?.organization?.id === item?.assigned_org?.id,
|
||||
) ?? false;
|
||||
|
||||
const AbleToSeeAssignDoc = (item: any) => {
|
||||
if (
|
||||
profile?.role?.type?.key === "ADM" ||
|
||||
profile?.organization?.id === item?.assigned_org?.id
|
||||
) {
|
||||
return (
|
||||
<DocumentOperation
|
||||
key={item?.id}
|
||||
downloadLink={`/tag/web/api/v1/tag_distribution_batch/${item?.id}/distribution_pdf_view/`}
|
||||
payloadKey="dist_exit_document"
|
||||
validFiles={["pdf"]}
|
||||
page="tag_distribution"
|
||||
access="Upload-Assign-Document"
|
||||
uploadLink={`/tag/web/api/v1/tag_distribution_batch/${item?.id}/assign_document/`}
|
||||
onUploadSuccess={handleUpdate}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
return "-";
|
||||
}
|
||||
};
|
||||
|
||||
const handleUpdate = () => {
|
||||
refetchData();
|
||||
refetchChildList();
|
||||
@@ -157,6 +193,38 @@ export default function TagDistribtutionDetails() {
|
||||
))}
|
||||
</Grid>
|
||||
</ShowMoreInfo>,
|
||||
...(showAssignDocColumn ? [AbleToSeeAssignDoc(item)] : []),
|
||||
<DocumentDownloader
|
||||
key={`doc-${item?.id}`}
|
||||
link={item?.warehouse_exit_doc}
|
||||
title="دانلود"
|
||||
/>,
|
||||
item?.exit_doc_status ? (
|
||||
"تایید شده"
|
||||
) : (
|
||||
<Button
|
||||
key={`btn-${item?.id}`}
|
||||
page="tag_distribution"
|
||||
access="Accept-Assign-Document"
|
||||
size="small"
|
||||
disabled={item?.exit_doc_status}
|
||||
onClick={() => {
|
||||
openModal({
|
||||
title: "تایید سند خروج",
|
||||
content: (
|
||||
<BooleanQuestion
|
||||
api={`/tag/web/api/v1/tag_distribution_batch/${item?.id}/accept_exit_doc/`}
|
||||
method="post"
|
||||
getData={handleUpdate}
|
||||
title="آیا از تایید سند خروج مطمئنید؟"
|
||||
/>
|
||||
),
|
||||
});
|
||||
}}
|
||||
>
|
||||
تایید سند خروج
|
||||
</Button>
|
||||
),
|
||||
<Popover key={`popover-${item?.id}`}>
|
||||
<Tooltip title="ویرایش توزیع" position="right">
|
||||
<Button
|
||||
@@ -178,6 +246,12 @@ export default function TagDistribtutionDetails() {
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
<DeleteButtonForPopOver
|
||||
page="tag_distribution"
|
||||
access="Delete-Tag-Distribution"
|
||||
api={`/tag/web/api/v1/tag_distribution_batch/${item?.id}/`}
|
||||
getData={handleUpdate}
|
||||
/>
|
||||
</Popover>,
|
||||
];
|
||||
},
|
||||
@@ -326,6 +400,9 @@ export default function TagDistribtutionDetails() {
|
||||
"پلاک های باقیمانده",
|
||||
"نوع توزیع",
|
||||
"جزئیات توزیع",
|
||||
...(showAssignDocColumn ? ["امضا سند خروج از انبار"] : []),
|
||||
"سند خروج از انبار",
|
||||
"تایید سند خروج",
|
||||
"عملیات",
|
||||
]}
|
||||
rows={childTableData}
|
||||
|
||||
@@ -23,6 +23,9 @@ import { TableButton } from "../../components/TableButton/TableButton";
|
||||
import { DistributionSpeciesModal } from "./DistributionSpeciesModal";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { TAG_DISTRIBUTION } from "../../routes/paths";
|
||||
import { DocumentOperation } from "../../components/DocumentOperation/DocumentOperation";
|
||||
import { DocumentDownloader } from "../../components/DocumentDownloader/DocumentDownloader";
|
||||
import { useUserProfileStore } from "../../context/zustand-store/userStore";
|
||||
|
||||
export default function TagActiveDistributions() {
|
||||
const { openModal } = useModalStore();
|
||||
@@ -39,12 +42,43 @@ export default function TagActiveDistributions() {
|
||||
},
|
||||
});
|
||||
|
||||
const { profile } = useUserProfileStore();
|
||||
|
||||
const { data: tagDashboardData, refetch: updateDashboard } = useApiRequest({
|
||||
api: "/tag/web/api/v1/tag_distribution_batch/main_dashboard/?is_closed=false",
|
||||
method: "get",
|
||||
queryKey: ["tagDistributionActivesDashboard"],
|
||||
});
|
||||
|
||||
const showAssignDocColumn =
|
||||
(profile?.role?.type?.key === "ADM" ||
|
||||
tagsData?.results?.some(
|
||||
(item: any) => profile?.organization?.id === item?.assigned_org?.id,
|
||||
)) ??
|
||||
false;
|
||||
|
||||
const AbleToSeeAssignDoc = (item: any) => {
|
||||
if (
|
||||
profile?.role?.type?.key === "ADM" ||
|
||||
profile?.organization?.id === item?.assigned_org?.id
|
||||
) {
|
||||
return (
|
||||
<DocumentOperation
|
||||
key={item?.id}
|
||||
downloadLink={`/tag/web/api/v1/tag_distribution_batch/${item?.id}/distribution_pdf_view/`}
|
||||
payloadKey="dist_exit_document"
|
||||
validFiles={["pdf"]}
|
||||
page="tag_distribution"
|
||||
access="Upload-Assign-Document"
|
||||
uploadLink={`/tag/web/api/v1/tag_distribution_batch/${item?.id}/assign_document/`}
|
||||
onUploadSuccess={handleUpdate}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
return "-";
|
||||
}
|
||||
};
|
||||
|
||||
const handleUpdate = () => {
|
||||
refetch();
|
||||
updateDashboard();
|
||||
@@ -155,6 +189,37 @@ export default function TagActiveDistributions() {
|
||||
))}
|
||||
</Grid>
|
||||
</ShowMoreInfo>,
|
||||
...(showAssignDocColumn ? [AbleToSeeAssignDoc(item)] : []),
|
||||
<DocumentDownloader
|
||||
key={index}
|
||||
link={item?.warehouse_exit_doc}
|
||||
title="دانلود"
|
||||
/>,
|
||||
item?.exit_doc_status ? (
|
||||
"تایید شده"
|
||||
) : (
|
||||
<Button
|
||||
page="tag_distribution"
|
||||
access="Accept-Assign-Document"
|
||||
size="small"
|
||||
disabled={item?.exit_doc_status}
|
||||
onClick={() => {
|
||||
openModal({
|
||||
title: "تایید سند خروج",
|
||||
content: (
|
||||
<BooleanQuestion
|
||||
api={`/tag/web/api/v1/tag_distribution_batch/${item?.id}/accept_exit_doc/`}
|
||||
method="post"
|
||||
getData={handleUpdate}
|
||||
title="آیا از تایید سند خروج مطمئنید؟"
|
||||
/>
|
||||
),
|
||||
});
|
||||
}}
|
||||
>
|
||||
تایید سند خروج
|
||||
</Button>
|
||||
),
|
||||
<Popover key={index}>
|
||||
<Tooltip title="جزئیات توزیع" position="right">
|
||||
<Button
|
||||
@@ -321,6 +386,9 @@ export default function TagActiveDistributions() {
|
||||
"پلاک های باقیمانده",
|
||||
"نوع توزیع",
|
||||
"جزئیات توزیع",
|
||||
...(showAssignDocColumn ? ["امضا سند خروج از انبار"] : []),
|
||||
"سند خروج از انبار",
|
||||
"تایید سند خروج",
|
||||
"عملیات",
|
||||
]}
|
||||
rows={tagsTableData}
|
||||
|
||||
Reference in New Issue
Block a user