From 5a1c3f1b52a3f1ed1bbfbabddada0d80ed7ad81a Mon Sep 17 00:00:00 2001 From: marzban-dev Date: Thu, 26 Dec 2024 00:04:36 +0330 Subject: [PATCH 01/15] Add start script --- frontend/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/package.json b/frontend/package.json index c025667..3bc58ef 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -3,6 +3,7 @@ "private": true, "type": "module", "scripts": { + "start" : "node .output/server/index.mjs", "build": "nuxt build", "dev": "nuxt dev", "dev-o": "nuxt dev -- -o", @@ -15,6 +16,8 @@ "@nuxtjs/google-fonts": "^3.2.0", "@tanstack/vue-query": "^5.62.2", "@tanstack/vue-query-devtools": "^5.62.3", + "@vuelidate/core": "^2.0.3", + "@vuelidate/validators": "^2.0.4", "axios": "^1.7.9", "gsap": "^3.12.5", "nuxt": "^3.14.1592", From 94231d8331390261c4a6eead2699672d0b4687a0 Mon Sep 17 00:00:00 2001 From: marzban-dev Date: Mon, 30 Dec 2024 19:54:40 +0330 Subject: [PATCH 02/15] Updated --- frontend/assets/css/button.comp.css | 12 +++++----- frontend/assets/css/tailwind.css | 36 +++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/frontend/assets/css/button.comp.css b/frontend/assets/css/button.comp.css index 05a12d5..db43161 100644 --- a/frontend/assets/css/button.comp.css +++ b/frontend/assets/css/button.comp.css @@ -36,10 +36,10 @@ } &:disabled { - @apply bg-slate-50 text-slate-300; + @apply bg-slate-100 text-slate-400; svg[class~=iconify] path { - @apply stroke-slate-300; + @apply stroke-slate-400; } } } @@ -57,10 +57,10 @@ } &:disabled { - @apply bg-slate-100 text-slate-300; + @apply bg-slate-100 text-slate-400; svg[class~=iconify] path { - @apply stroke-slate-300; + @apply stroke-slate-400; } } } @@ -103,10 +103,10 @@ } &:disabled { - @apply text-slate-300; + @apply text-slate-400; svg[class~=iconify] path { - @apply stroke-slate-300; + @apply stroke-slate-400; } } } diff --git a/frontend/assets/css/tailwind.css b/frontend/assets/css/tailwind.css index 4e59175..1ce8cae 100644 --- a/frontend/assets/css/tailwind.css +++ b/frontend/assets/css/tailwind.css @@ -120,16 +120,15 @@ --breakpoint-xs: 480px; /* ANIMATIONS */ -<<<<<<< HEAD --animate-marquee: marquee 3s linear infinite; --animate-slide-down: slideDown 300ms ease-out; --animate-slide-up: slideUp 300ms ease-out; --animate-overlay-show: overlayShow 150ms ease-in; --animate-content-show: contentShow 150ms ease-in; -======= - --animate-marquee: marquee 25s linear infinite; - --animate-marquee-reverse: marquee 25s linear infinite reverse; ->>>>>>> be4fa509843c81855f5ffc118150196c94a7b17b + + --animate-toast-hide: toastHide 100ms ease-in; + --animate-toast-in: toastSlideIn 600ms cubic-bezier(0.16, 1, 0.3, 1); + --animate-toast-out: toastSlideOut 200ms ease-out; @keyframes marquee { to { @@ -174,6 +173,33 @@ transform: translate(-50%, -50%) scale(1); } } + + @keyframes toastHide { + from { opacity: 1 } + to { opacity: 0 } + } + + @keyframes toastSlideIn { + from { + opacity: 0; + transform: translateX(calc(100% + var(--viewport-padding))) + } + to { + opacity: 1; + transform: translateX(0) + } + } + + @keyframes toastSlideOut { + from { + opacity: 1; + transform: translateX(var(--reka-toast-swipe-end-x)) + } + to { + opacity: 0; + transform: translateX(calc(100% + var(--viewport-padding))) + } + } } /* CONTAINER */ From aba3a1e4271198de306928c97e90e4fda5d30551 Mon Sep 17 00:00:00 2001 From: marzban-dev Date: Mon, 30 Dec 2024 19:55:10 +0330 Subject: [PATCH 03/15] Create toast component --- .../components/ui/ToastContainer/ToastBox.vue | 63 +++++++++++++++++++ .../components/ui/ToastContainer/index.vue | 19 ++++++ 2 files changed, 82 insertions(+) create mode 100644 frontend/components/ui/ToastContainer/ToastBox.vue create mode 100644 frontend/components/ui/ToastContainer/index.vue diff --git a/frontend/components/ui/ToastContainer/ToastBox.vue b/frontend/components/ui/ToastContainer/ToastBox.vue new file mode 100644 index 0000000..152a043 --- /dev/null +++ b/frontend/components/ui/ToastContainer/ToastBox.vue @@ -0,0 +1,63 @@ + + + \ No newline at end of file diff --git a/frontend/components/ui/ToastContainer/index.vue b/frontend/components/ui/ToastContainer/index.vue new file mode 100644 index 0000000..266d557 --- /dev/null +++ b/frontend/components/ui/ToastContainer/index.vue @@ -0,0 +1,19 @@ + + + \ No newline at end of file From ac3c3483d8b1c2ea7ef3ccd90851bd0fa4c80ab7 Mon Sep 17 00:00:00 2001 From: marzban-dev Date: Mon, 30 Dec 2024 19:55:30 +0330 Subject: [PATCH 04/15] Add send otp api --- frontend/composables/api/auth/useOtp.ts | 28 +++++++++++++++++++++++++ frontend/constants/index.ts | 5 ++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 frontend/composables/api/auth/useOtp.ts diff --git a/frontend/composables/api/auth/useOtp.ts b/frontend/composables/api/auth/useOtp.ts new file mode 100644 index 0000000..7909ccc --- /dev/null +++ b/frontend/composables/api/auth/useOtp.ts @@ -0,0 +1,28 @@ +// imports + +import { useMutation } from "@tanstack/vue-query"; +import axios from "~/configs/axios.config"; +import { API_ENDPOINTS } from "~/constants"; + +// types + +export type OtpRequest = { + phone: string; +}; + +// methods + +export const handleOtp = async (variables: OtpRequest) => { + const { data } = await axios.post(`${API_ENDPOINTS.account.send_otp}`, variables); + return data; +}; + +// composable + +const useOtp = () => { + return useMutation({ + mutationFn: (variables: OtpRequest) => handleOtp(variables) + }); +}; + +export default useOtp; diff --git a/frontend/constants/index.ts b/frontend/constants/index.ts index ca13d19..51d3b72 100644 --- a/frontend/constants/index.ts +++ b/frontend/constants/index.ts @@ -1,6 +1,9 @@ export const API_ENDPOINTS = { + account : { + send_otp : "/accounts/send_otp", + }, auth: { - login: "/token", + signin: "/token", logout: "/accounts/logout", } }; From bf95002a41084b8273dfcdc157ddd8eb031c0468 Mon Sep 17 00:00:00 2001 From: marzban-dev Date: Mon, 30 Dec 2024 19:55:41 +0330 Subject: [PATCH 05/15] Add sign in apu --- frontend/composables/api/auth/useSignIn.ts | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 frontend/composables/api/auth/useSignIn.ts diff --git a/frontend/composables/api/auth/useSignIn.ts b/frontend/composables/api/auth/useSignIn.ts new file mode 100644 index 0000000..3ace4f1 --- /dev/null +++ b/frontend/composables/api/auth/useSignIn.ts @@ -0,0 +1,29 @@ +// imports + +import { useMutation } from "@tanstack/vue-query"; +import axios from "~/configs/axios.config"; +import { API_ENDPOINTS } from "~/constants"; + +// types + +export type SignInRequest = { + otp: string; + phone: string; +}; + +// methods + +export const handleSignIn = async (variables: SignInRequest) => { + const { data } = await axios.post(`${API_ENDPOINTS.auth.signin}/`, variables); + return data; +}; + +// composable + +const useSignIn = () => { + return useMutation({ + mutationFn: (variables: SignInRequest) => handleSignIn(variables) + }); +}; + +export default useSignIn; From 47947419c60f7e45216c825d5cdd122e00f25c4d Mon Sep 17 00:00:00 2001 From: marzban-dev Date: Mon, 30 Dec 2024 19:55:52 +0330 Subject: [PATCH 06/15] Create useTimer composable --- frontend/composables/useTimer.ts | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 frontend/composables/useTimer.ts diff --git a/frontend/composables/useTimer.ts b/frontend/composables/useTimer.ts new file mode 100644 index 0000000..5f6b943 --- /dev/null +++ b/frontend/composables/useTimer.ts @@ -0,0 +1,42 @@ +type Props = { + duration: number; + callback?: () => void +} + +export function useTimer({ duration, callback }: Props) { + const timeout = ref(null); + const interval = ref(null); + + const isPending = ref(false); + const timer = ref(duration / 1000); + + const reset = () => { + if (timeout.value) clearTimeout(timeout.value); + if (interval.value) clearInterval(interval.value); + + isPending.value = false; + timer.value = duration / 1000; + }; + + const start = () => { + isPending.value = true; + + timeout.value = setTimeout(() => { + if (interval.value) clearInterval(interval.value); + if (callback) callback(); + isPending.value = false; + timer.value = duration / 1000; + }, duration); + + interval.value = setInterval(() => { + timer.value -= 1; + }, 1000); + }; + + return { + isPending, + timer, + reset, + start + }; +} \ No newline at end of file From 6284319afbad33b75fb98bb549aea8a6ecb526c3 Mon Sep 17 00:00:00 2001 From: marzban-dev Date: Mon, 30 Dec 2024 19:55:58 +0330 Subject: [PATCH 07/15] Create useToast composable --- frontend/composables/useToast.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 frontend/composables/useToast.ts diff --git a/frontend/composables/useToast.ts b/frontend/composables/useToast.ts new file mode 100644 index 0000000..95bec80 --- /dev/null +++ b/frontend/composables/useToast.ts @@ -0,0 +1,32 @@ +type Toast = { + id: number; + message: string; + description?: string; + duration?: number; +} + +type Props = { + message: string, + description?: string, + options?: Omit +} + +const toasts = ref([]); + +export function useToast() { + const addToast = ({ message, description, options = {} }: Props) => { + const id = Date.now(); + + toasts.value.push({ id, message, description, ...options }); + }; + + const destroyToast = (id: number) => { + toasts.value = toasts.value.filter(toast => toast.id !== id); + }; + + return { + toasts, + addToast, + destroyToast + }; +} \ No newline at end of file From 6fc873d709e9b26a0de23e7352f34f56f7b1c5ed Mon Sep 17 00:00:00 2001 From: marzban-dev Date: Mon, 30 Dec 2024 19:56:07 +0330 Subject: [PATCH 08/15] Create sign in page --- frontend/pages/signin/index.vue | 196 ++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 frontend/pages/signin/index.vue diff --git a/frontend/pages/signin/index.vue b/frontend/pages/signin/index.vue new file mode 100644 index 0000000..73d33f8 --- /dev/null +++ b/frontend/pages/signin/index.vue @@ -0,0 +1,196 @@ + + + \ No newline at end of file From 37a15a9afee9755a29a8152680d31d0f65077760 Mon Sep 17 00:00:00 2001 From: marzban-dev Date: Mon, 30 Dec 2024 19:56:16 +0330 Subject: [PATCH 09/15] Create otp input component --- frontend/components/ui/OtpInput.vue | 138 ++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 frontend/components/ui/OtpInput.vue diff --git a/frontend/components/ui/OtpInput.vue b/frontend/components/ui/OtpInput.vue new file mode 100644 index 0000000..590fedd --- /dev/null +++ b/frontend/components/ui/OtpInput.vue @@ -0,0 +1,138 @@ + + + \ No newline at end of file From 3205325586a5a600109b03fb31a2558bb856df82 Mon Sep 17 00:00:00 2001 From: marzban-dev Date: Mon, 30 Dec 2024 19:56:28 +0330 Subject: [PATCH 10/15] Add loading indicator for button --- frontend/components/ui/Button.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/components/ui/Button.vue b/frontend/components/ui/Button.vue index 46ea375..4624e10 100644 --- a/frontend/components/ui/Button.vue +++ b/frontend/components/ui/Button.vue @@ -5,6 +5,7 @@ type Props = { size?: "xl" | "lg" | "md"; startIcon?: string; endIcon?: string; + loading?: boolean; }; // props @@ -35,8 +36,9 @@ const classes = computed(() => { From 9bd1bb81181822e0cbb90eeaaff6eee4d73e5ec8 Mon Sep 17 00:00:00 2001 From: marzban-dev Date: Mon, 30 Dec 2024 19:56:36 +0330 Subject: [PATCH 11/15] Updated --- frontend/components/ui/Input.vue | 35 +++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/frontend/components/ui/Input.vue b/frontend/components/ui/Input.vue index 6a69c0f..9054835 100644 --- a/frontend/components/ui/Input.vue +++ b/frontend/components/ui/Input.vue @@ -1,51 +1,66 @@