From 0b40de30f2a7ee8af144d2dad718e0b1b350141d Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Tue, 11 Feb 2025 23:23:53 +0330 Subject: [PATCH 01/15] updated account types --- frontend/types/global.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/types/global.d.ts b/frontend/types/global.d.ts index 70a7644..9ba04d1 100644 --- a/frontend/types/global.d.ts +++ b/frontend/types/global.d.ts @@ -15,11 +15,13 @@ declare global { }; type Account = { + profile_photo: File | null; first_name: string; last_name: string; - email: string; - profile_photo: string; phone: string; + gender: string | undefined; + email: string; + birth_date: string; }; type Product = { From 99e830e72b638c250acd8164af938500b6a36e6b Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Tue, 11 Feb 2025 23:24:14 +0330 Subject: [PATCH 02/15] added submit profile --- frontend/pages/profile/index.vue | 197 ++++++++++++++++++++++++++++--- 1 file changed, 180 insertions(+), 17 deletions(-) diff --git a/frontend/pages/profile/index.vue b/frontend/pages/profile/index.vue index e64b2ff..9c2a28b 100644 --- a/frontend/pages/profile/index.vue +++ b/frontend/pages/profile/index.vue @@ -1,7 +1,15 @@ From 625c468b8bf65e311c0af78e34dd734a2ec73557 Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Tue, 11 Feb 2025 23:25:02 +0330 Subject: [PATCH 05/15] added update profile query key and route --- frontend/constants/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/constants/index.ts b/frontend/constants/index.ts index 6451bb7..98f6206 100644 --- a/frontend/constants/index.ts +++ b/frontend/constants/index.ts @@ -13,6 +13,7 @@ export const API_ENDPOINTS = { get_all: "/accounts/address/list", delete: "/accounts/address/delete", }, + update: "/accounts/profile", }, product: { comments: "/products/comments", From ce9de71f423eab6854f10d0302e0fe59397e8ba4 Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Tue, 11 Feb 2025 23:25:17 +0330 Subject: [PATCH 06/15] added use object track --- frontend/composables/global/useObjectTrack.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 frontend/composables/global/useObjectTrack.ts diff --git a/frontend/composables/global/useObjectTrack.ts b/frontend/composables/global/useObjectTrack.ts new file mode 100644 index 0000000..9a03a50 --- /dev/null +++ b/frontend/composables/global/useObjectTrack.ts @@ -0,0 +1,39 @@ +export const useObjectTrack = (object: Ref) => { + // state + + const isNotEqual = ref(false); + + const { history, reset, clear } = useRefHistory(object, { + deep: true, + }); + + // watch + + watch( + () => history.value, + (newHistory) => { + if (newHistory.length < 2) { + isNotEqual.value = false; + return; + } + + const initial = newHistory[0].snapshot; + const current = newHistory[newHistory.length - 1].snapshot; + + const hasChanges = Object.keys(initial).some( + (key) => + JSON.stringify(current[key]) !== + JSON.stringify(initial[key]) + ); + + isNotEqual.value = hasChanges; + }, + { deep: true } + ); + + return { + isNotEqual, + reset, + clear, + }; +}; From 8f88995ef772d29fb18ff285fc9a01f3e4d162dd Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Tue, 11 Feb 2025 23:25:25 +0330 Subject: [PATCH 07/15] added use update account --- .../api/account/useUpdateAccount.ts | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 frontend/composables/api/account/useUpdateAccount.ts diff --git a/frontend/composables/api/account/useUpdateAccount.ts b/frontend/composables/api/account/useUpdateAccount.ts new file mode 100644 index 0000000..521d56a --- /dev/null +++ b/frontend/composables/api/account/useUpdateAccount.ts @@ -0,0 +1,45 @@ +// imports + +import { useMutation } from "@tanstack/vue-query"; +import { API_ENDPOINTS } from "~/constants"; + +// types + +export type UpdateAccountRequest = { + profile_photo?: File | null; + first_name?: string; + last_name?: string; + phone?: string; + gender?: string | undefined; + email?: string; + birth_date?: string; +}; + +const useUpdateAccount = () => { + // state + + const { $axios: axios } = useNuxtApp(); + + // method + + const handleUpdateAccount = async (params: UpdateAccountRequest) => { + const { data } = await axios.patch( + API_ENDPOINTS.account.update, + { + ...params, + }, + { + headers: { + "Content-Type": "multipart/form-data", + }, + } + ); + return data; + }; + + return useMutation({ + mutationFn: (data: UpdateAccountRequest) => handleUpdateAccount(data), + }); +}; + +export default useUpdateAccount; From fccbaefc88d30e91282837cae0a77b143dc82676 Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Tue, 11 Feb 2025 23:25:40 +0330 Subject: [PATCH 08/15] added profile picture modal --- ...ctureModal.vue => ProfilePictureModal.vue} | 119 ++++++++++++------ 1 file changed, 84 insertions(+), 35 deletions(-) rename frontend/components/profile/index/{PictureModal.vue => ProfilePictureModal.vue} (59%) diff --git a/frontend/components/profile/index/PictureModal.vue b/frontend/components/profile/index/ProfilePictureModal.vue similarity index 59% rename from frontend/components/profile/index/PictureModal.vue rename to frontend/components/profile/index/ProfilePictureModal.vue index 17b4bdc..878624a 100644 --- a/frontend/components/profile/index/PictureModal.vue +++ b/frontend/components/profile/index/ProfilePictureModal.vue @@ -1,9 +1,48 @@