Merge remote-tracking branch 'origin/iipbs_cs' into iipbs_cs

This commit is contained in:
2025-07-10 13:58:19 +09:00
12 changed files with 112 additions and 21 deletions
@@ -44,7 +44,9 @@ function PostPage({ bbsId }: { bbsId: string }) {
const thumbRefs = useRef<Map<number, string>>(new Map());
const [tableSort, setTableSort] = useState("");
const [postParams, setPostParams] = useState<PostParams>({
const [keywordType, setKeywordType] = useState("title");
const [keyword, setKeyword] = useState("");
const [searchParams, setSearchParams] = useState<PostParams>({
keywordType: "title",
keyword: "",
});
@@ -58,7 +60,7 @@ function PostPage({ bbsId }: { bbsId: string }) {
queryKey: [ENDPOINT.BOARD_SERVICE.POSTS_USER, bbsId, bbsInfo],
queryFn: () =>
PostApi.getPostList(parseInt(bbsId), {
...postParams,
...searchParams,
upndFixYn: bbsInfo?.upndFixUseYn,
}),
select: (data) => {
@@ -79,10 +81,16 @@ function PostPage({ bbsId }: { bbsId: string }) {
isLoading,
refetch,
} = useQuery({
queryKey: [ENDPOINT.BOARD_SERVICE.POSTS_USER, bbsId, pagination, tableSort],
queryKey: [
ENDPOINT.BOARD_SERVICE.POSTS_USER,
bbsId,
searchParams,
pagination,
tableSort,
],
queryFn: () =>
PostApi.getPostList(parseInt(bbsId), {
...postParams,
...searchParams,
ansUseYn: bbsInfo?.ansUseYn,
page: pagination.pageIndex,
size: pagination.pageSize,
@@ -128,7 +136,29 @@ function PostPage({ bbsId }: { bbsId: string }) {
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
refetch();
setPagination({
...pagination,
pageIndex: 0,
});
setSearchParams({
...searchParams,
keywordType,
keyword,
});
};
const handleReset = () => {
setKeywordType("title");
setKeyword("");
setPagination({
...pagination,
pageIndex: 0,
});
setSearchParams({
...searchParams,
keywordType: "title",
keyword: "",
});
};
const handleRowClick = (row: Post) => {
@@ -141,12 +171,7 @@ function PostPage({ bbsId }: { bbsId: string }) {
<div className="card card-border">
<form onSubmit={handleSubmit} className="flex items-center gap-2 p-2">
<Label className="mr-2 text-label">검색</Label>
<Select
value={postParams.keywordType}
onValueChange={(keywordType) => {
setPostParams({ ...postParams, keywordType });
}}
>
<Select value={keywordType} onValueChange={setKeywordType}>
<SelectTrigger className="h-[3.2rem] w-[10rem]">
<SelectValue placeholder="선택" />
</SelectTrigger>
@@ -157,15 +182,21 @@ function PostPage({ bbsId }: { bbsId: string }) {
</SelectContent>
</Select>
<Input
value={postParams.keyword}
onChange={(e) =>
setPostParams({ ...postParams, keyword: e.target.value })
}
value={keyword}
onChange={(e) => setKeyword(e.target.value)}
className="h-[3.2rem] w-[24rem] rounded-sm !text-[1.3rem]"
/>
<Button className="h-[3.2rem]" type="submit">
조회
</Button>
<Button
type="button"
color="white"
className="h-[3.2rem]"
onClick={handleReset}
>
초기화
</Button>
</form>
</div>
<div className="card card-border">
@@ -41,6 +41,10 @@ export class PopupApiService implements PopupService {
validatedData,
);
}
public async deletePopup(popupSn: number): Promise<void> {
await client.delete(`${ENDPOINT.CMS_SERVICE.POPUPS}/${popupSn}`);
}
}
export const PopupApi = new PopupApiService();
@@ -68,4 +68,5 @@ export interface PopupService {
getPopupInfo(popupSn: number): Promise<PopupInfo>;
createPopup(data: PopupFormData): Promise<void>;
updatePopup(popupSn: number, data: PopupUpdateFormData): Promise<void>;
deletePopup(popupSn: number): Promise<void>;
}
+13 -1
View File
@@ -52,6 +52,13 @@ function ModifyPage({ popupSn }: { popupSn: number }) {
},
});
const { mutateAsync: deletePopup } = useMutationWrapper({
mutationFn: () => PopupApi.deletePopup(popupSn),
onSuccess: () => {
alert("삭제되었습니다.", router.back);
},
});
const { mutateAsync: savePostingHistory } = useMutationWrapper({
mutationFn: (data: PostPayload[]) => PostingApi.savePosting(data),
onSuccess: () => {
@@ -101,7 +108,12 @@ function ModifyPage({ popupSn }: { popupSn: number }) {
<div className="card-header">
<h3 className="text-2xl font-medium text-label">팝업 수정</h3>
</div>
<PopupForm form={form} handleSave={updatePopup} />
<PopupForm
form={form}
popupSn={popupSn}
handleSave={updatePopup}
handleDelete={deletePopup}
/>
</div>
<div className="card card-border">
<div className="card-header">
+1 -1
View File
@@ -32,7 +32,7 @@ const Editor = dynamic(
type PopupFormProps<T extends PopupFormData | PopupUpdateFormData> = {
form: UseFormReturn<T>;
popupSn?: string;
popupSn?: number;
handleSave: (data: T) => Promise<void>;
handleDelete?: () => Promise<void>;
};
@@ -34,6 +34,10 @@ class ScheduleApiService implements ScheduleService {
): Promise<void> {
await client.put(`${ENDPOINT.CMS_SERVICE.SCHEDULES}/${schdlSn}`, data);
}
public async deleteSchedule(schdlSn: number): Promise<void> {
await client.delete(`${ENDPOINT.CMS_SERVICE.SCHEDULES}/${schdlSn}`);
}
}
export const ScheduleApi = new ScheduleApiService();
@@ -71,4 +71,5 @@ export interface ScheduleService {
getScheduleInfo(schdlSn: number): Promise<Schedule>;
createSchedule(data: ScheduleFormData): Promise<void>;
updateSchedule(schdlSn: number, data: ScheduleUpdateFormData): Promise<void>;
deleteSchedule(schdlSn: number): Promise<void>;
}
+16 -1
View File
@@ -35,6 +35,16 @@ function ModifyPage({ schdlSn }: { schdlSn: string }) {
},
});
const { mutateAsync: deleteSchedule } = useMutationWrapper({
mutationFn: () => ScheduleApi.deleteSchedule(parseInt(schdlSn)),
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: [ENDPOINT.CMS_SERVICE.SCHEDULES],
});
alert("일정이 삭제되었습니다.", router.back);
},
});
const form = useForm<ScheduleUpdateFormData>({
resolver: zodResolver(scheduleUpdateFormSchema),
values: {
@@ -57,7 +67,12 @@ function ModifyPage({ schdlSn }: { schdlSn: string }) {
<div className="card-header">
<h3 className="text-2xl font-medium text-label">스케줄 수정</h3>
</div>
<ScheduleForm form={form} handleSave={handleSave} />
<ScheduleForm
form={form}
scheduleId={schdlSn}
handleSave={handleSave}
handleDelete={deleteSchedule}
/>
</div>
);
}
@@ -45,6 +45,10 @@ export class SurveyApiService implements SurveyService {
await client.put(`${ENDPOINT.CMS_SERVICE.SURVEY}/${srvySn}`, data);
}
public async deleteSurvey(srvySn: number): Promise<void> {
await client.delete(`${ENDPOINT.CMS_SERVICE.SURVEY}/${srvySn}`);
}
public async getQuestionList(params: QuestionParams): Promise<QuestionList> {
const response = await client.get<QuestionList>(
`${ENDPOINT.CMS_SERVICE.SURVEY_QUESTION}`,
+16 -1
View File
@@ -29,6 +29,13 @@ function DetailPage({ srvySn }: { srvySn: string }) {
queryFn: () => SurveyApi.getSurveyInfo(parseInt(srvySn)),
});
const { mutateAsync: deleteSurvey } = useMutationWrapper({
mutationFn: () => SurveyApi.deleteSurvey(parseInt(srvySn)),
onSuccess: () => {
alert("삭제되었습니다.", router.back);
},
});
const postHistoryQuery = useQuery({
queryKey: [ENDPOINT.CMS_SERVICE.POSTINGS, srvySn],
queryFn: () =>
@@ -77,6 +84,12 @@ function DetailPage({ srvySn }: { srvySn: string }) {
},
});
const handleDeleteSurvey = async () => {
if (await confirm("삭제하시겠습니까?")) {
deleteSurvey();
}
};
const handleDeletePostingHistory = async () => {
const data = postingTable.getFilteredSelectedRowModel().rows.map((row) => ({
...row.original,
@@ -101,7 +114,9 @@ function DetailPage({ srvySn }: { srvySn: string }) {
<Button onClick={() => router.push(`${pathname}/modify`)}>
수정
</Button>
<Button color="red">삭제</Button>
<Button color="red" onClick={handleDeleteSurvey}>
삭제
</Button>
</div>
</div>
<ul className="flex flex-col">
@@ -102,7 +102,7 @@ function GeneralFileUploader<T extends { atflCd?: string | null }>({
<span>{attachment.orgnlFileNm}</span>
<Button
color="lightGray"
className="flex size-7 items-center justify-center rounded-full p-0"
className="flex size-7 shrink-0 items-center justify-center rounded-full p-0"
onClick={() =>
setDeleteAttachmentIds([...deleteAttachmentIds, atflId])
}
@@ -29,7 +29,11 @@ const TableHeader = React.forwardRef<
HTMLTableSectionElement,
React.HTMLAttributes<HTMLTableSectionElement>
>(({ className, ...props }, ref) => (
<thead ref={ref} className={cn("sticky top-0 bg-secondary [&_tr]:border-b", className)} {...props} />
<thead
ref={ref}
className={cn("sticky top-0 z-10 bg-secondary [&_tr]:border-b", className)}
{...props}
/>
));
TableHeader.displayName = "TableHeader";