fix: filter error

This commit is contained in:
2026-02-02 11:03:01 +03:30
parent 6b5276ce36
commit 5fd55c4b10

View File

@@ -42,7 +42,7 @@ export const SubmitTagDistribution = ({ item, getData }: any) => {
? item?.distribution_type === "random" ? item?.distribution_type === "random"
? "random" ? "random"
: "group" : "group"
: "group" : "group",
); );
const [batches, setBatches] = useState<BatchItem[]>([]); const [batches, setBatches] = useState<BatchItem[]>([]);
@@ -116,25 +116,25 @@ export const SubmitTagDistribution = ({ item, getData }: any) => {
showToast( showToast(
isEdit ? "ویرایش با موفقیت انجام شد" : "ثبت با موفقیت انجام شد", isEdit ? "ویرایش با موفقیت انجام شد" : "ثبت با موفقیت انجام شد",
"success" "success",
); );
getData(); getData();
closeModal(); closeModal();
} catch (error: any) { } catch (error: any) {
showToast( showToast(
error?.response?.data?.message || "خطا در ثبت اطلاعات!", error?.response?.data?.message || "خطا در ثبت اطلاعات!",
"error" "error",
); );
} }
}; };
const speciesOptions = () => { const speciesOptions = () => {
return speciesData?.results?.map((opt: any) => { return (
return { speciesData?.results?.map((opt: any) => ({
key: opt?.value, key: opt?.value,
value: opt?.name, value: opt?.name,
}; })) ?? []
}); );
}; };
return ( return (
@@ -195,14 +195,14 @@ export const SubmitTagDistribution = ({ item, getData }: any) => {
items?.map((r: any) => { items?.map((r: any) => {
const existing = batches.find( const existing = batches.find(
(b) => (b) =>
b.batch_identity === r.key1 && b.species_code === r.key2 b.batch_identity === r.key1 && b.species_code === r.key2,
); );
return { return {
batch_identity: r.key1, batch_identity: r.key1,
species_code: r.key2, species_code: r.key2,
count: existing?.count ?? "", count: existing?.count ?? "",
}; };
}) || [] }) || [],
); );
}} }}
onChangeValue={(labels) => { onChangeValue={(labels) => {
@@ -210,7 +210,7 @@ export const SubmitTagDistribution = ({ item, getData }: any) => {
prev.map((item, index) => ({ prev.map((item, index) => ({
...item, ...item,
label: labels[index], label: labels[index],
})) })),
); );
}} }}
/> />
@@ -229,7 +229,7 @@ export const SubmitTagDistribution = ({ item, getData }: any) => {
species_code: k as number, species_code: k as number,
count: prev?.count ?? "", count: prev?.count ?? "",
}; };
}) }),
); );
}} }}
title="گونه" title="گونه"
@@ -245,12 +245,12 @@ export const SubmitTagDistribution = ({ item, getData }: any) => {
distributionType === "group" distributionType === "group"
? `تعداد ${ ? `تعداد ${
speciesOptions().find( speciesOptions().find(
(s: any) => s.key === batch.species_code (s: any) => s.key === batch.species_code,
)?.value )?.value
} (${batch.label}) ` } (${batch.label}) `
: `تعداد ${ : `تعداد ${
speciesOptions().find( speciesOptions().find(
(s: any) => s.key === batch.species_code (s: any) => s.key === batch.species_code,
)?.value )?.value
}` }`
} }
@@ -271,7 +271,7 @@ export const SubmitTagDistribution = ({ item, getData }: any) => {
b.count === "" || b.count === "" ||
b.count === undefined || b.count === undefined ||
b.count === null || b.count === null ||
Number(b.count) <= 0 Number(b.count) <= 0,
) )
} }
type="submit" type="submit"