From b3fae0b5dbf335e847bafc5a0b9e5c4f23268bfa Mon Sep 17 00:00:00 2001 From: Peaceultime Date: Wed, 6 Nov 2024 14:29:32 +0100 Subject: [PATCH] Setup global toaster and finalize login/registration page --- app.vue | 27 ++++++----- components/base/Toast.vue | 84 -------------------------------- components/base/Toaster.vue | 92 ++++++++++++++++++++++++++++++++++++ composables/useToast.ts | 40 +++++++++++++++- db.sqlite-shm | Bin 32768 -> 32768 bytes pages/admin/index.vue | 2 - pages/index.vue | 1 - pages/user/login.vue | 21 +++++--- pages/user/register.vue | 70 ++++++++++++++------------- 9 files changed, 198 insertions(+), 139 deletions(-) delete mode 100644 components/base/Toast.vue create mode 100644 components/base/Toaster.vue diff --git a/app.vue b/app.vue index 2abf32f..5caf4b5 100644 --- a/app.vue +++ b/app.vue @@ -1,14 +1,19 @@ + + \ No newline at end of file diff --git a/components/base/Toast.vue b/components/base/Toast.vue deleted file mode 100644 index d05014e..0000000 --- a/components/base/Toast.vue +++ /dev/null @@ -1,84 +0,0 @@ - - - - - \ No newline at end of file diff --git a/components/base/Toaster.vue b/components/base/Toaster.vue new file mode 100644 index 0000000..bb9484a --- /dev/null +++ b/components/base/Toaster.vue @@ -0,0 +1,92 @@ + + + + + \ No newline at end of file diff --git a/composables/useToast.ts b/composables/useToast.ts index 2367c7b..ec38f8d 100644 --- a/composables/useToast.ts +++ b/composables/useToast.ts @@ -1,4 +1,40 @@ -export default function useToast() +export interface ToastConfig { - + closeable?: boolean + duration: number + title?: string + content?: string + timer?: boolean + type?: ToastType +} +export type ToastType = 'info' | 'success' | 'error'; +export type ExtraToastConfig = ToastConfig & { id: string, state: boolean }; + +let id = 0; + +const [provideToaster, useToast] = createInjectionState(() => { + const list = ref([]); + + function add(config: ToastConfig) + { + list.value.push({ ...config, id: (++id).toString(), state: true, }); + } + function clear(type?: ToastType) + { + list.value.forEach(e => { if(e.type !== type) { e.state = false; } }); + } + + return { list, add, clear } +}, { injectionKey: Symbol('toaster') }); + +export { provideToaster, useToastWithDefault as useToast }; + +function useToastWithDefault() +{ + const toasts = useToast(); + if(!toasts) + { + return { list: ref([]), add: () => {}, clear: () => {} }; + } + return toasts; } \ No newline at end of file diff --git a/db.sqlite-shm b/db.sqlite-shm index 49ed849c4fe2ce0eac03062e42227ded7e6c7c40..73c3e9d4d1bb9608d3d67a00ce4e30053ac442ec 100644 GIT binary patch delta 86 zcmZo@U}|V!;*@x#%K!!wIpqcCM8DQ Executer - - \ No newline at end of file diff --git a/pages/index.vue b/pages/index.vue index f98069e..d81a49b 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -31,7 +31,6 @@ watch(loading, (value) => { - \ No newline at end of file diff --git a/pages/user/login.vue b/pages/user/login.vue index f6621d4..4f312e5 100644 --- a/pages/user/login.vue +++ b/pages/user/login.vue @@ -3,25 +3,30 @@ Connexion
- Connexion +
+ + Connexion +
Pas de compte ? -
\ No newline at end of file diff --git a/pages/user/register.vue b/pages/user/register.vue index d8e0f55..1e48397 100644 --- a/pages/user/register.vue +++ b/pages/user/register.vue @@ -3,28 +3,31 @@ Inscription
- Inscription -
- - - -
+
+ + Inscription +
+ + + + +
Votre mot de passe doit respecter les critères de sécurité suivants : - Entre 8 et 128 + Entre 8 et 128 caractères - Au moins + Au moins une minuscule et une majuscule - Au moins un + Au moins un chiffre - Au moins un - caractère spécial parmis la liste suivante: + Au moins un + caractère spécial parmi la liste suivante:
! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ ] ^ _ ` { | } ~
- - - Pas de compte ? + + + Vous avez déjà un compte ?Se connecter
@@ -32,6 +35,7 @@ \ No newline at end of file