Skip to content

Commit

Permalink
Feat: 커스텀훅 useNotice 반환 값 타입 정의
Browse files Browse the repository at this point in the history
  • Loading branch information
ParkSohyunee committed Nov 29, 2024
1 parent eb97059 commit 56a750a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/hooks/queries/useNotice.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query';
import { useMutation, UseMutationOptions, UseMutationResult, useQueryClient } from '@tanstack/react-query';

import deleteNotice from '@/app/_api/notice/deleteNotice';
import sendNoticeAlarm from '@/app/_api/notice/sendNoticeAlarm';
Expand All @@ -23,8 +23,16 @@ const useNoticeMutation = <TData = unknown, TError = unknown, TVariables = unkno
});
};

// useNoticeMutation이 반환하는 타입은 UseMutationResult<TData, TError, TVariables, unknown> 타입으로,
// useNotice 훅이 반환하는 각 함수의 반환값(void), 에러, 변수 타입(number), context 타입을 정의해주었다.
type UseNoticeReturnType = {
deletNoticeMutation: UseMutationResult<void, unknown, number, unknown>;
sendNoticeAlarmMutation: UseMutationResult<void, unknown, number, unknown>;
updateNoticePublicMutation: UseMutationResult<void, unknown, number, unknown>;
};

// React-query의 useMutation을 wrapping해주는 Notice 관련 custom hook
const useNotice = () => {
const useNotice = (): UseNoticeReturnType => {
const deletNoticeMutation = useNoticeMutation(deleteNotice);
const sendNoticeAlarmMutation = useNoticeMutation(sendNoticeAlarm);
const updateNoticePublicMutation = useNoticeMutation(updateNoticePublic);
Expand Down

0 comments on commit 56a750a

Please sign in to comment.