fix update-avatar

This commit is contained in:
Aaron William Po
2023-12-07 21:12:17 -05:00
parent c7d5c65ffb
commit 01a9bfaf4e
3 changed files with 4 additions and 46 deletions

View File

@@ -0,0 +1,28 @@
import UpdateProfileSchema from '@/services/User/schema/UpdateProfileSchema';
import { z } from 'zod';
interface UpdateProfileRequestParams {
userId: string;
bio: z.infer<typeof UpdateProfileSchema>['bio'];
}
const sendUpdateUserProfileRequest = async ({
bio,
userId,
}: UpdateProfileRequestParams) => {
const response = await fetch(`/api/users/${userId}/profile/update-profile`, {
method: 'PUT',
body: JSON.stringify({ bio }),
headers: { 'Content-Type': 'application/json' },
});
if (!response.ok) {
throw new Error('Failed to update profile.');
}
const json = await response.json();
return json;
};
export default sendUpdateUserProfileRequest;