push rasad front on new repo

This commit is contained in:
2026-01-18 14:32:49 +03:30
commit 4fe6e70525
2139 changed files with 303150 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
import { SlaughterStockWrapper } from "../../slaughter-house/components/slaughter-stock-wrapper/SlaughterStockWrapper";
export const SenfEnterToWarehouse = () => {
return <SlaughterStockWrapper />;
};

View File

@@ -0,0 +1,54 @@
import { VscNewFolder } from "react-icons/vsc";
import { useLocation } from "react-router-dom";
import { Grid } from "../../../components/grid/Grid";
import LinkItem from "../../../components/link-item/LinkItem";
import { NavLink } from "../../../components/nav-link/NavLink";
import { SPACING } from "../../../data/spacing";
import {
ROUTE_SENF_INVENTORY_SEGMENTATION,
ROUTE_SENF_INVENTORY_STOCK,
} from "../../../routes/routes";
import ContentCutIcon from "@mui/icons-material/ContentCut";
export const SenfInventoryOperation = () => {
const { pathname } = useLocation();
return (
<Grid
container
gap={SPACING.SMALL}
p={SPACING.SMALL}
direction={{ xs: "column", md: "row" }}
justifyContent="center"
style={{ placeContent: "baseline" }}
>
<NavLink
to={ROUTE_SENF_INVENTORY_STOCK}
active={pathname === ROUTE_SENF_INVENTORY_STOCK ? "true" : null}
>
<LinkItem
icon={<VscNewFolder size={30} color="#244CCC" />}
title="ورود به انبار"
/>
</NavLink>
{/* <NavLink
to={ROUTE_SENF_INVENTORY_ENTER}
active={pathname === ROUTE_SENF_INVENTORY_ENTER ? "true" : null}
>
<LinkItem
icon={<WarehouseIcon sx={{ fontSize: 34, color: "#2444CC" }} />}
title="ورود به انبار"
/>
</NavLink> */}
<NavLink
to={ROUTE_SENF_INVENTORY_SEGMENTATION}
active={pathname === ROUTE_SENF_INVENTORY_SEGMENTATION ? "true" : null}
>
<LinkItem
icon={<ContentCutIcon sx={{ fontSize: 30, color: "#2444CC" }} />}
title="قطعه بندی"
/>
</NavLink>
</Grid>
);
};

View File

@@ -0,0 +1,320 @@
import { useContext, useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import moment from "moment";
import { Button, TextField, Typography } from "@mui/material";
import { DatePicker } from "@mui/x-date-pickers";
import { RiSearchLine } from "react-icons/ri";
import axios from "axios";
import { AppContext } from "../../../contexts/AppContext";
import {
DRAWER,
LOADING_END,
LOADING_START,
} from "../../../lib/redux/slices/appSlice";
import { formatJustDate, formatTime } from "../../../utils/formatTime";
import { StewardSegmentOperation } from "../../guild/components/StewardSegmentOperation";
import { getRoleFromUrl } from "../../../utils/getRoleFromUrl";
import { Grid } from "../../../components/grid/Grid";
import { SPACING } from "../../../data/spacing";
import ResponsiveTable from "../../../components/responsive-table/ResponsiveTable";
import { checkPathStartsWith } from "../../../utils/checkPathStartsWith";
import { stawardGetSegmentDashboardService } from "../../guild/services/steward-get-dashboard-service";
import { stewardGetOutSellService } from "../../guild/services/steward-get-sell-out-service";
import { StewardSegmentSubmitOperation } from "../../guild/components/StewardSegmentSubmitOperation";
export const SenfSegmentaion = () => {
const [data, setData] = useState([]);
const [products, setProducts] = useState([]);
const [tableData, setTableData] = useState([]);
const [totalRows, setTotalRows] = useState(0);
const [perPage, setPerPage] = useState(10);
const [textValue, setTextValue] = useState("");
const [page, setPage] = useState(1);
const [dashboardData, setDashboardData] = useState([]);
const selectedSubUser = useSelector(
(state) => state.userSlice.selectedSubUser
);
const [, , selectedDate1, setSelectedDate1, selectedDate2, setSelectedDate2] =
useContext(AppContext);
const dispatch = useDispatch();
// const userKey = useSelector((state) => state.userSlice.userProfile.key);
const getDashboardData = () => {
dispatch(
stawardGetSegmentDashboardService({
value: textValue,
date1: selectedDate1,
date2: selectedDate2,
role: getRoleFromUrl(),
role_key:
checkPathStartsWith("slaughter") || checkPathStartsWith("senf")
? selectedSubUser?.key
: "",
})
).then((r) => {
setDashboardData(r.payload.data);
});
};
useEffect(() => {
const currentDate = moment(new Date()).format("YYYY-MM-DD");
setSelectedDate1(currentDate);
setSelectedDate2(currentDate);
}, []);
const fetchApiData = async (page) => {
dispatch(LOADING_START());
const response = await axios.get(
`app-segmentation/?search=filter&value=${textValue}&date1=${selectedDate1}&date2=${selectedDate2}&page=${page}&page_size=${perPage}&role=${getRoleFromUrl()}${
checkPathStartsWith("slaughter") || checkPathStartsWith("senf")
? `&role_key=${selectedSubUser?.key}`
: ""
}`
);
getDashboardData();
dispatch(LOADING_END());
setData(response.data.results);
setTotalRows(response.data.count);
};
const handlePageChange = (page) => {
fetchApiData(page);
setPage(page);
};
const updateTable = () => {
fetchApiData(page);
};
const handlePerRowsChange = (perRows) => {
setPerPage(perRows);
setPage(1);
};
const handleTextChange = (event) => {
setTextValue(event.target.value);
};
useEffect(() => {
fetchApiData(1);
dispatch(
stewardGetOutSellService({
role_key:
checkPathStartsWith("slaughter") || checkPathStartsWith("senf")
? selectedSubUser?.key || ""
: "",
})
).then((r) => {
setProducts(r.payload.data);
});
}, []);
useEffect(() => {
const d = data?.map((item, i) => {
return [
page === 1 ? i + 1 : i + perPage * (page - 1) + 1,
item?.productionDate ? formatTime(item?.productionDate) : "-",
item?.distributionType === "web"
? "سایت"
: item?.distributionType === "app"
? "موبایل"
: item?.distributionType === "pos"
? "پوز"
: item?.distributionType || "-",
`${item?.buyer?.fullname}(${item?.buyer?.mobile})`,
item?.toGuild
? `به قطعه بند - ${item?.toGuild?.user?.fullname}(${item?.toGuild?.user?.mobile})`
: "قطعه بندی توسط کشتارگاه",
item?.date ? formatJustDate(item?.date) : "-",
item?.weight,
item?.quota === "governmental"
? "دولتی"
: item?.quota === "free"
? "آزاد"
: "-",
item?.saleType === "governmental"
? "دولتی"
: item?.saleType === "free"
? "آزاد"
: "-",
<StewardSegmentOperation
key={i}
item={item}
productKey={products?.[0]?.key}
updateTable={updateTable}
/>,
];
});
setTableData(d);
}, [data]);
useEffect(() => {
fetchApiData(1);
}, [selectedDate1, selectedDate2, perPage, selectedSubUser?.key]);
const handleSubmit = async (event) => {
event.preventDefault();
dispatch(LOADING_START());
try {
const response = await axios.get(
`app-segmentation/?search=filter&value=${textValue}&date1=${selectedDate1}&date2=${selectedDate2}&page=${page}&role=${getRoleFromUrl()}${
checkPathStartsWith("slaughter") || checkPathStartsWith("senf")
? `&role_key=${selectedSubUser?.key}`
: ""
}`
);
setData(response.data.results);
setTotalRows(response.data.count);
getDashboardData();
dispatch(LOADING_END());
} catch (error) {
console.error("Error fetching data:", error);
}
};
return (
<Grid container>
<Typography variant="h6" my={SPACING.SMALL}>
ثبت قطعه بندی
</Typography>
<Grid
xs={12}
container
alignItems="center"
gap={SPACING.SMALL}
justifyContent="flex-start"
>
<Grid container mb={4} isDashboard xs={12}>
<ResponsiveTable
noPagination
isDashboard
columns={[
"وزن کل (کیلوگرم)",
// "تخصیصات مباشر",
"وزن قطعه بندی",
// "تخصیصات قطعه بند",
"وزن تخصیصی به قطعه بندها",
]}
data={[
[
dashboardData?.totalWeight?.toLocaleString() || "0",
// dashboardData?.totalSelfCount?.toLocaleString() || "0",
dashboardData?.totalSelfWeight?.toLocaleString() || "0",
// dashboardData?.totalOtherCount?.toLocaleString() || "0",
dashboardData?.totalOtherWeight?.toLocaleString() || "0",
],
]}
title={"خلاصه اطلاعات"}
/>
</Grid>
<form>
<Grid container alignItems="center" gap={SPACING.SMALL}>
<Button
variant="contained"
onClick={() => {
dispatch(
DRAWER({
right: !(window.innerWidth <= 600),
bottom: window.innerWidth <= 600,
title: "ثبت قطعه بندی",
size: {
xs: "100%",
sm: "380px",
},
content: (
<StewardSegmentSubmitOperation
updateTable={updateTable}
productKey={products?.[0]?.key}
/>
),
})
);
}}
>
ثبت قطعه بندی
</Button>
<TextField
size="small"
autoComplete="off"
label="جستجو"
variant="outlined"
style={{ width: 250 }}
onChange={handleTextChange}
/>
<Button
type="submit"
onClick={handleSubmit}
endIcon={<RiSearchLine />}
>
جستجو
</Button>
<Grid>
<DatePicker
label="از تاریخ"
id="date"
renderInput={(params) => (
<TextField style={{ width: "160px" }} {...params} />
)}
value={selectedDate1}
onChange={(e) =>
setSelectedDate1(moment(e).format("YYYY-MM-DD"))
}
/>
</Grid>
<Grid>
<DatePicker
label="تا تاریخ"
id="date"
renderInput={(params) => (
<TextField style={{ width: "160px" }} {...params} />
)}
value={selectedDate2}
onChange={(e) =>
setSelectedDate2(moment(e).format("YYYY-MM-DD"))
}
/>
</Grid>
{/* <Tooltip title="خروجی اکسل">
<Button
color="success"
onClick={() => {
const link = `${
axios.defaults.baseURL
}kill_house_free_bar_excel/?role=${getRoleFromUrl()}&key=${userKey}&date1=${selectedDate1}&date2=${selectedDate2}&type=carcass&search=filter&value=${textValue}&date_type=buy`;
window.location.href = link;
}}
>
<RiFileExcel2Fill size={32} />
</Button>
</Tooltip> */}
</Grid>
</form>
<ResponsiveTable
data={tableData}
columns={[
"ردیف",
"تاریخ تولید گوشت",
"ثبت شده",
"قطعه بند",
"تخصیص",
"تاریخ ",
"وزن (کیلوگرم)",
"سهمیه",
"نوع فروش",
"عملیات",
]}
handlePageChange={handlePageChange}
totalRows={totalRows}
page={page}
perPage={perPage}
handlePerRowsChange={handlePerRowsChange}
title="قطعه بندی"
/>
</Grid>
</Grid>
);
};

View File

@@ -0,0 +1,339 @@
import { Button, TextField, Typography, Tabs, Tab } from "@mui/material";
import { DatePicker } from "@mui/x-date-pickers";
import moment from "moment/moment";
import { useContext, useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { Grid } from "../../../components/grid/Grid";
import { AppContext } from "../../../contexts/AppContext";
import { SPACING } from "../../../data/spacing";
import {
LOADING_END,
LOADING_START,
OPEN_MODAL,
} from "../../../lib/redux/slices/appSlice";
import { GuildReceiveBarOperation } from "../../guild/components/GuildReceiveBarOperation";
import { senfGetAllocationDashboardService } from "../../guild/services/senf-get-allocation-dashboard";
import { senfGetInventoryAllocatedService } from "../../guild/services/senf-get-inventory-allocated";
import { guildSalesInfoDashboardService } from "../../guild/services/guild-sales-info-dashboard";
import { getFaUserRole } from "../../../utils/getFaUserRole";
import { formatJustDate } from "../../../utils/formatTime";
import { checkPathStartsWith } from "../../../utils/checkPathStartsWith";
import ResponsiveTable from "../../../components/responsive-table/ResponsiveTable";
import { RiSearchLine } from "react-icons/ri";
export const SenfStock = () => {
const dispatch = useDispatch();
const [dataTable, setDataTable] = useState([]);
const [statusTab, setStatusTab] = useState("pending");
const [text, setText] = useState("");
const [, , selectedDate1, setSelectedDate1, selectedDate2, setSelectedDate2] =
useContext(AppContext);
const {
senfGetInventoryStock,
senfGetInventoryAllocated,
guildSalesInfoDashboard,
} = useSelector((state) => state.generalSlice);
const selectedSubUser = useSelector(
(state) => state.userSlice.selectedSubUser
);
useEffect(() => {
dispatch(
senfGetAllocationDashboardService({
date1: selectedDate1,
date2: selectedDate2,
role_key: checkPathStartsWith("senf") ? selectedSubUser?.key : "",
search: text,
})
);
dispatch(
senfGetInventoryAllocatedService({
date1: selectedDate1,
date2: selectedDate2,
role_key: checkPathStartsWith("senf") ? selectedSubUser?.key : "",
type: statusTab,
search: text,
})
);
dispatch(
guildSalesInfoDashboardService({
role_key: checkPathStartsWith("senf") ? selectedSubUser?.key : "",
})
);
}, [selectedDate1, selectedDate2, selectedSubUser?.key, statusTab, dispatch]);
useEffect(() => {
const items = senfGetInventoryAllocated?.results || [];
if (items.length > 0) {
const d = items.map((item, i) => {
let state = "";
if (item?.receiverState === "accepted") {
state = "تحویل گرفته شده";
} else if (item?.receiverState === "rejected") {
state = "رد شده";
} else {
state = "در انتظار تحویل";
}
const sellerRoleFa = getFaUserRole(item?.seller_type);
const sellerName =
item?.stewards?.user?.fullname ||
item?.stewards?.name ||
item?.killHouse?.name ||
item?.toKillHouse?.name ||
"-";
const sellerMobile =
item?.stewards?.user?.mobile ||
item?.killHouse?.user?.mobile ||
item?.toKillHouse?.user?.mobile ||
"-";
return [
i + 1,
`${sellerRoleFa} ${sellerName} (${sellerMobile})`,
formatJustDate(item.date),
(item?.weightOfCarcasses || 0).toLocaleString() + " کیلوگرم",
<Grid container direction="column" key={item.key}>
{item?.receiverRealNumberOfCarcasses && (
<>
<Typography variant="caption">
{item?.receiverRealNumberOfCarcasses?.toLocaleString() +
" قطعه"}
</Typography>
<Typography variant="caption">
{item?.receiverRealWeightOfCarcasses?.toLocaleString() +
" کیلوگرم"}
</Typography>
</>
)}
{/* {item?.receiverState === "pending" && (
<Grid>
<Button
onClick={() => {
dispatch(
OPEN_MODAL({
title: "ثبت/ویرایش تعداد و وزن تحویلی",
content: (
<RegisterEditDeliveryNumberAndWeight item={item} />
),
})
);
}}
>
{item?.receiverRealNumberOfCarcasses ? "ویرایش" : "ثبت"}
</Button>
</Grid>
)} */}
</Grid>,
<Grid container direction="column" key={item.key} gap={SPACING.SMALL}>
{item.receiverState === "pending" ? (
<Button
onClick={() => {
dispatch(
OPEN_MODAL({
title: "ثبت تحویل بار",
content: <GuildReceiveBarOperation item={item} />,
})
);
}}
>
تحویل بار
</Button>
) : (
state
)}
</Grid>,
];
});
setDataTable(d);
} else {
setDataTable([]);
}
}, [senfGetInventoryAllocated, dispatch]);
const handleSubmit = async (event) => {
event.preventDefault();
dispatch(LOADING_START());
try {
dispatch(
senfGetAllocationDashboardService({
date1: selectedDate1,
date2: selectedDate2,
role_key: checkPathStartsWith("senf") ? selectedSubUser?.key : "",
search: text,
})
);
dispatch(
senfGetInventoryAllocatedService({
date1: selectedDate1,
date2: selectedDate2,
role_key: checkPathStartsWith("senf") ? selectedSubUser?.key : "",
type: statusTab,
search: text,
})
);
} catch (error) {
console.error("Error fetching data:", error);
} finally {
dispatch(LOADING_END());
}
};
return (
<Grid container gap={SPACING.SMALL} pt={SPACING.MEDIUM}>
<ResponsiveTable
title="اطلاعات فروش"
columns={[
"وزن دولتی (کیلوگرم)",
"وزن آزاد (کیلوگرم)",
"فروش دولتی (کیلوگرم)",
"فروش آزاد (کیلوگرم)",
"وزن قطعه بندی (کیلوگرم)",
"وزن انجماد (کیلوگرم)",
"مانده دولتی (کیلوگرم)",
"مانده آزاد (کیلوگرم)",
]}
data={[
[
(
guildSalesInfoDashboard?.totalGovernmentalInputWeight || 0
).toLocaleString(),
(
guildSalesInfoDashboard?.totalFreeInputWeight || 0
).toLocaleString(),
(
guildSalesInfoDashboard?.totalGovernmentalOutputWeight || 0
).toLocaleString(),
(
guildSalesInfoDashboard?.totalFreeOutputWeight || 0
).toLocaleString(),
"0",
"0",
(
guildSalesInfoDashboard?.totalGovernmentalRemainWeight || 0
).toLocaleString(),
(
guildSalesInfoDashboard?.totalFreeRemainWeight || 0
).toLocaleString(),
],
]}
noPagination
isDashboard
/>
<Grid
container
gap={SPACING.SMALL}
alignItems="center"
justifyContent="space-between"
mb={2}
mt={2}
>
<Grid container gap={SPACING.SMALL} alignItems="center">
<DatePicker
label="تاریخ شروع"
id="date1"
renderInput={(params) => (
<TextField style={{ width: "160px" }} {...params} />
)}
value={selectedDate1}
onChange={(e) => {
setSelectedDate1(moment(e).format("YYYY-MM-DD"));
}}
/>
<DatePicker
label="تاریخ پایان"
id="date2"
renderInput={(params) => (
<TextField style={{ width: "160px" }} {...params} />
)}
value={selectedDate2}
onChange={(e) => {
setSelectedDate2(moment(e).format("YYYY-MM-DD"));
}}
/>
<form onSubmit={handleSubmit}>
<TextField
id="outlined-basic"
size="small"
label="جستجو"
variant="outlined"
style={{ width: 250 }}
value={text}
onChange={(e) => setText(e.target.value)}
/>
<Button
// disabled={!textValue}
type="submit"
onClick={handleSubmit}
endIcon={<RiSearchLine />}
>
جستجو
</Button>
</form>
</Grid>
</Grid>
<ResponsiveTable
title="ورودی به انبار"
columns={[
"تعداد بار تخصیصی",
"وزن لاشه در انتظار تحویل",
"وزن لاشه تحویلی",
]}
data={[
[
senfGetInventoryStock?.allocationsCount || 0,
(
(senfGetInventoryStock?.notEnteredWeight || 0) +
(senfGetInventoryStock?.enteredWeight || 0)
).toLocaleString() + " کیلوگرم",
(senfGetInventoryStock?.enteredWeight || 0).toLocaleString() +
" کیلوگرم",
],
]}
noPagination
isDashboard
/>
{/* Tabs for filtering by receiver state */}
<Grid container justifyContent="center" xs={12} mt={SPACING.SMALL}>
<Tabs
value={statusTab}
onChange={(_, value) => setStatusTab(value)}
sx={{ borderBottom: 1, borderColor: "divider", mb: 1 }}
>
<Tab label="در انتظار تحویل" value="pending" />
<Tab label="تحویل گرفته شده" value="accepted" />
</Tabs>
</Grid>
<ResponsiveTable
title={`بارهای اختصاصی ${
statusTab === "pending" ? "در انتظار تحویل" : "تحویل گرفته شده"
}`}
columns={
statusTab === "accepted"
? [
"ردیف",
"فروشنده",
"تاریخ تخصیص",
"وزن تخصیص",
"تعداد/وزن واقعی تحویلی",
]
: [
"ردیف",
"فروشنده",
"تاریخ تخصیص",
"وزن تخصیص",
"تعداد/وزن واقعی تحویلی",
"عملیات",
]
}
data={
statusTab === "accepted"
? dataTable.map((row) => row.slice(0, -1))
: dataTable
}
/>
</Grid>
);
};