mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 21:06:42 +07:00
removed redux completely
This commit is contained in:
parent
26e6d8d41b
commit
a4bb07e9cf
323 changed files with 2464 additions and 3348 deletions
|
@ -1,9 +1,9 @@
|
|||
import useSWR from 'swr';
|
||||
import { API } from '~/constants/api';
|
||||
import { apiAuthGetUserProfile } from '~/redux/auth/api';
|
||||
import { EMPTY_USER } from '~/redux/auth/constants';
|
||||
import { apiAuthGetUserProfile } from '~/api/auth';
|
||||
import { EMPTY_USER } from '~/constants/auth';
|
||||
import { useCallback } from 'react';
|
||||
import { IUser } from '~/redux/auth/types';
|
||||
import { IUser } from '~/types/auth';
|
||||
|
||||
const getKey = (username?: string): string | null => {
|
||||
return username ? `${API.USER.PROFILE}/${username}` : null;
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
import { useUploader } from '~/hooks/data/useUploader';
|
||||
import { UploadSubject, UploadTarget } from '~/constants/uploads';
|
||||
import { useCallback } from 'react';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
import { ApiUpdateUserRequest, IUser } from '~/redux/auth/types';
|
||||
import { apiUpdateUser } from '~/redux/auth/api';
|
||||
|
||||
export const usePatchProfile = (updateUserData: (user: Partial<IUser>) => void) => {
|
||||
const { uploadFile } = useUploader(UploadSubject.Avatar, UploadTarget.Profiles);
|
||||
|
||||
const updateProfile = useCallback(
|
||||
async (user: Partial<ApiUpdateUserRequest['user']>) => {
|
||||
const result = await apiUpdateUser({ user });
|
||||
await updateUserData(result.user);
|
||||
return result.user;
|
||||
},
|
||||
[updateUserData]
|
||||
);
|
||||
|
||||
const updatePhoto = useCallback(
|
||||
async (file: File) => {
|
||||
try {
|
||||
const photo = await uploadFile(file);
|
||||
await updateProfile({ photo });
|
||||
} catch (error) {
|
||||
showErrorToast(error);
|
||||
}
|
||||
},
|
||||
[uploadFile, updateProfile]
|
||||
);
|
||||
|
||||
return { updatePhoto, updateProfile };
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
import { IUser } from '~/redux/auth/types';
|
||||
import { IUser } from '~/types/auth';
|
||||
import { Asserts, object, string } from 'yup';
|
||||
import { ERRORS } from '~/constants/errors';
|
||||
import { FormikConfig, useFormik } from 'formik';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue