feat: 사이트 반영 api 날짜 payload 수정

This commit is contained in:
2025-04-04 16:24:57 +09:00
parent 7f4e973c5f
commit b0f8638df2
2 changed files with 16 additions and 4 deletions
@@ -19,8 +19,8 @@ export const postSchema = z.object({
pstgTypeCd: z.string(), pstgTypeCd: z.string(),
pstgTypeNm: z.string(), pstgTypeNm: z.string(),
pstgTrgtNo: z.number(), pstgTrgtNo: z.number(),
pstgBgngDt: z.string(), pstgBgngDt: z.string().optional(),
pstgEndDt: z.string(), pstgEndDt: z.string().optional(),
pstgPrdSeCd: z.string(), pstgPrdSeCd: z.string(),
pstgPrdSeNm: z.string(), pstgPrdSeNm: z.string(),
delYn: z.string(), delYn: z.string(),
@@ -90,6 +90,9 @@ function PostingDialog({ postingType, postingTargets }: PostingDialogProps) {
name: "pstg", name: "pstg",
}); });
const isFormValid =
fields.length && fields.every((field) => field.pstgPrdSeCd !== "");
const isAllSelected = const isAllSelected =
siteList && selectedRows.length === siteList.content.length; siteList && selectedRows.length === siteList.content.length;
@@ -164,19 +167,28 @@ function PostingDialog({ postingType, postingTargets }: PostingDialogProps) {
replace([]); replace([]);
setSelectedRows([]); setSelectedRows([]);
} else { } else {
setSelectedRows(siteList?.content.map((_, i) => i) ?? []);
replace([]); replace([]);
setSelectedRows(siteList?.content.map((_, i) => i) ?? []);
siteList?.content.forEach((_, i) => handleAppendFields(i)); siteList?.content.forEach((_, i) => handleAppendFields(i));
} }
}; };
const handlePeriodCodeChange = (siteId: string) => (value: string) => { const handlePeriodCodeChange = (siteId: string) => (value: string) => {
const from = dayjs().format("YYYY-MM-DD 00:00:00");
const to = dayjs().add(Number(value), "day").format("YYYY-MM-DD 23:59:59");
setRememberPeriodCode((prev) => ({ setRememberPeriodCode((prev) => ({
...prev, ...prev,
[siteId]: value, [siteId]: value,
})); }));
setRememberPeriodDate((prev) => ({
...prev,
[siteId]: { from, to },
}));
handleUpdateFields(siteId)({ handleUpdateFields(siteId)({
pstgPrdSeCd: value, pstgPrdSeCd: value,
pstgBgngDt: from,
pstgEndDt: to,
}); });
}; };
@@ -288,7 +300,7 @@ function PostingDialog({ postingType, postingTargets }: PostingDialogProps) {
</Table> </Table>
</div> </div>
<DialogFooter className="!justify-center"> <DialogFooter className="!justify-center">
<Button size="lg" onClick={handleSave}> <Button size="lg" onClick={handleSave} disabled={!isFormValid}>
저장 저장
</Button> </Button>
<DialogClose asChild> <DialogClose asChild>