-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new endpoint to event service and change current update eve…
…nt endpoint implementation (#7)
- Loading branch information
Showing
7 changed files
with
104 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { eventService } from '@/services/event'; | ||
import { UpdateAttendingEventBody } from '@/types/event'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
export const useUpdateEventByCircleID = () => { | ||
return useMutation({ | ||
mutationFn: async ({ | ||
circleID, | ||
payload, | ||
}: { | ||
circleID: number; | ||
payload: UpdateAttendingEventBody; | ||
}) => { | ||
const res = await eventService.putUpdateAttendingEventByCircleID( | ||
circleID, | ||
payload, | ||
); | ||
return res.data; | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,31 @@ | ||
import { getEventPaginationSchema } from '@/types/event'; | ||
import { getOneCircleResponse } from '@/types/circle'; | ||
import { | ||
getEventPaginationSchema, | ||
UpdateAttendingEventBody, | ||
} from '@/types/event'; | ||
import { fetchInstance } from '@/utils/fetch-wrapper'; | ||
|
||
export const eventService = { | ||
getEvents: async (params: { page: number; limit: number }) => { | ||
const res = await fetchInstance(null, '/v1/event', { params }); | ||
return getEventPaginationSchema.parse(res); | ||
}, | ||
putUpdateAttendingEventByCircleID: async ( | ||
circleID: number, | ||
body: UpdateAttendingEventBody, | ||
) => { | ||
const res = await fetchInstance(null, `/v1/circle/${circleID}/event`, { | ||
body, | ||
method: 'PUT', | ||
}); | ||
|
||
return getOneCircleResponse.parse(res); | ||
}, | ||
|
||
deleteAttendingEventByCircleID: async (circleID: number) => { | ||
const res = await fetchInstance(null, `/v1/circle/${circleID}/event`, { | ||
method: 'DELETE', | ||
}); | ||
return getOneCircleResponse.parse(res); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters