@@ -7,9 +7,8 @@ import TertiaryButton from '../../../../../design-system/ui/buttons/TertiaryButt
77import { useParams } from 'react-router-dom' ;
88import MemberEmailInput from '../../../../features/menu/ui/MemberEmailInput' ;
99import useHostChannelInfo from '../../../../entities/host/hook/useHostChannelInfoHook' ;
10- import { useQueryClient } from '@tanstack/react-query' ;
11- import { useHostInvitation } from '../../../../features/host/hook/useHostInvitation' ;
1210import { useHostInfoSave } from '../../../../features/host/hook/useHostInfoHook' ;
11+ import { useInviteMembers } from '../../../../features/host/hook/useInviteHostHook' ;
1312
1413const HostEditPage = ( ) => {
1514 const { id } = useParams < { id : string } > ( ) ;
@@ -20,8 +19,7 @@ const HostEditPage = () => {
2019
2120 const hostChannelId = Number ( id ) ;
2221 const { data : hostInfo } = useHostChannelInfo ( hostChannelId ) ;
23- const { mutate : inviteMember } = useHostInvitation ( hostChannelId ) ;
24- const queryClient = useQueryClient ( ) ;
22+ const { inviteMembers } = useInviteMembers ( hostChannelId ) ;
2523
2624 const { handleSave } = useHostInfoSave ( hostChannelId , hostInfo ! , channelDescription ) ;
2725
@@ -37,33 +35,7 @@ const HostEditPage = () => {
3735 const handleInviteMembers = ( ) => {
3836 if ( ! hostInfo ?. result . id ) return ;
3937
40- if ( emails . length === 0 ) {
41- alert ( '초대할 이메일을 입력해주세요.' ) ;
42- return ;
43- }
44-
45- const invitationPromises = emails . map (
46- email =>
47- new Promise ( ( resolve , reject ) => {
48- inviteMember (
49- { email } ,
50- {
51- onSuccess : resolve ,
52- onError : reject ,
53- }
54- ) ;
55- } )
56- ) ;
57-
58- Promise . all ( invitationPromises )
59- . then ( ( ) => {
60- alert ( '초대가 전송되었습니다.' ) ;
61- setEmails ( [ ] ) ;
62- queryClient . invalidateQueries ( { queryKey : [ 'hostInfo' , hostChannelId ] } ) ; // ✅ 멤버 목록 리패치
63- } )
64- . catch ( ( ) => {
65- alert ( '초대 중 일부 실패했습니다.' ) ;
66- } ) ;
38+ inviteMembers ( emails , ( ) => setEmails ( [ ] ) ) ;
6739 } ;
6840
6941 useEffect ( ( ) => {
0 commit comments