Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ export function UnivApplyInfoManageTab() {

const searchResultQuery = useQuery({
queryKey: ["univ-apply-infos", "search", committedSearch],
queryFn: () => adminApi.searchUnivApplyInfos(committedSearch?.value),
queryFn: () =>
adminApi.searchUnivApplyInfos({
value: committedSearch?.value,
homeUniversityId: committedSearch?.homeUniversityId,
termId: committedSearch?.termId,
}),
enabled: committedSearch !== null,
});

Expand Down Expand Up @@ -210,17 +215,7 @@ export function UnivApplyInfoManageTab() {
setCreateModal({ open: true });
};

const selectedHomeUniversityName = committedSearch?.homeUniversityId
? homeUniversitiesQuery.data?.find((university) => university.id === committedSearch.homeUniversityId)?.name
: undefined;
const selectedTermLabel = committedSearch?.termId
? termsQuery.data?.find((term) => term.id === committedSearch.termId)?.label
: undefined;
const results = (searchResultQuery.data?.univApplyInfoPreviews ?? []).filter(
(item) =>
(!committedSearch?.homeUniversityId || item.homeUniversityName === selectedHomeUniversityName) &&
(!committedSearch?.termId || item.term === selectedTermLabel),
);
const results = searchResultQuery.data?.univApplyInfoPreviews ?? [];
const isMutating = deleteMutation.isPending || updateMutation.isPending || createMutation.isPending;

return (
Expand Down
8 changes: 6 additions & 2 deletions apps/admin/src/lib/api/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,14 @@ export const adminApi = {
deleteUnivApplyInfo: (id: number) =>
axiosInstance.delete<void>(`/admin/univ-apply-infos/${id}`).then((res) => res.data),

searchUnivApplyInfos: (value?: string) =>
searchUnivApplyInfos: (params: { value?: string; homeUniversityId?: number; termId?: number }) =>
axiosInstance
.get<{ univApplyInfoPreviews: UnivApplyInfoSearchResult[] }>("/univ-apply-infos/search/text", {
params: { value: value ?? "" },
params: {
value: params.value ?? "",
homeUniversityId: params.homeUniversityId,
termId: params.termId,
},
})
.then((res) => res.data),
};
Loading