use-post-register.tsx 821 B

1234567891011121314151617181920212223242526272829303132
  1. import { useQuery } from '@tanstack/react-query';
  2. import { authApi, PostLoginUserReturn } from '../auth-api';
  3. import { BaseAxiosError } from '../../../../types';
  4. import { authQueryKeys } from '../auth-query-keys';
  5. export type UserRegistrationData = {
  6. user: {
  7. username: string;
  8. email: string;
  9. password: string;
  10. first_name: string;
  11. last_name: string;
  12. date_of_birth: Date;
  13. homebase: number;
  14. };
  15. photo: {
  16. type: string;
  17. uri: string;
  18. name: string;
  19. };
  20. };
  21. export const usePostRegister = (data: UserRegistrationData, enabled: boolean) => {
  22. return useQuery<PostLoginUserReturn, BaseAxiosError>({
  23. queryKey: authQueryKeys.registerUser(),
  24. queryFn: async () => {
  25. const response = await authApi.registerUser(data);
  26. return response.data;
  27. },
  28. enabled
  29. });
  30. };