refactor(client): split client to cms/mobile/party
Signed-off-by: Noa Virellia <noa@requiem.garden>
This commit is contained in:
18
client/cms/src/hooks/data/useGetCheckInCode.ts
Normal file
18
client/cms/src/hooks/data/useGetCheckInCode.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { axiosClient } from '@/lib/axios';
|
||||
|
||||
export function useCheckinCode(eventId: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: ['getCheckinCode', eventId],
|
||||
queryFn: async () => {
|
||||
return axiosClient.get<{
|
||||
checkin_code: string;
|
||||
}>('/user/checkin', {
|
||||
params: {
|
||||
event_id: eventId,
|
||||
},
|
||||
});
|
||||
},
|
||||
enabled,
|
||||
});
|
||||
}
|
||||
16
client/cms/src/hooks/data/useGetMagicLink.ts
Normal file
16
client/cms/src/hooks/data/useGetMagicLink.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { AuthorizeSearchParams } from '@/routes/authorize';
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { axiosClient } from '@/lib/axios';
|
||||
|
||||
interface GetMagicLinkPayload extends AuthorizeSearchParams {
|
||||
email: string;
|
||||
turnstile_token: string;
|
||||
}
|
||||
|
||||
export function useGetMagicLink() {
|
||||
return useMutation({
|
||||
mutationFn: async (payload: GetMagicLinkPayload) => {
|
||||
return axiosClient.post<{ status: string }>('/auth/magic', payload);
|
||||
},
|
||||
});
|
||||
}
|
||||
22
client/cms/src/hooks/data/useUserInfo.ts
Normal file
22
client/cms/src/hooks/data/useUserInfo.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { useSuspenseQuery } from '@tanstack/react-query';
|
||||
import { axiosClient } from '@/lib/axios';
|
||||
|
||||
export function useUserInfo() {
|
||||
return useSuspenseQuery({
|
||||
queryKey: ['userInfo'],
|
||||
queryFn: async () => {
|
||||
const response = await axiosClient.get<{
|
||||
user_id: string;
|
||||
email: string;
|
||||
type: string;
|
||||
nickname: string;
|
||||
subtitle: string;
|
||||
avatar: string;
|
||||
bio: string;
|
||||
}
|
||||
>('/user/info');
|
||||
return response.data;
|
||||
},
|
||||
staleTime: 10 * 60 * 1000,
|
||||
});
|
||||
}
|
||||
11
client/cms/src/hooks/data/useValidateMagicLink.ts
Normal file
11
client/cms/src/hooks/data/useValidateMagicLink.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useSuspenseQuery } from '@tanstack/react-query';
|
||||
import { axiosClient } from '@/lib/axios';
|
||||
|
||||
export function useValidateMagicLink(ticket: string) {
|
||||
return useSuspenseQuery({
|
||||
queryKey: ['validateMagicLink', ticket],
|
||||
queryFn: async () => {
|
||||
return axiosClient.get<{ access_token: string; refresh_token: string }>('/auth/magic/verify', { params: { token: ticket } });
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user