From a96b3d0b0de5a0c5cb7ddef03510e28103c4b2d2 Mon Sep 17 00:00:00 2001 From: Vxrcel Date: Thu, 25 Jul 2024 12:10:28 +0100 Subject: [PATCH] redeploy --- .../{page.test.tsx => page.test-backup.tsx} | 0 src/app/(auth-routes)/login/page.tsx | 6 ++- src/app/layout.tsx | 2 +- src/hooks/user/use-user.ts | 40 +++++++++++++++++++ 4 files changed, 45 insertions(+), 3 deletions(-) rename src/app/(auth-routes)/login/{page.test.tsx => page.test-backup.tsx} (100%) create mode 100644 src/hooks/user/use-user.ts diff --git a/src/app/(auth-routes)/login/page.test.tsx b/src/app/(auth-routes)/login/page.test-backup.tsx similarity index 100% rename from src/app/(auth-routes)/login/page.test.tsx rename to src/app/(auth-routes)/login/page.test-backup.tsx diff --git a/src/app/(auth-routes)/login/page.tsx b/src/app/(auth-routes)/login/page.tsx index d964bea4a..5de3c9d0b 100644 --- a/src/app/(auth-routes)/login/page.tsx +++ b/src/app/(auth-routes)/login/page.tsx @@ -6,7 +6,7 @@ import { useRouter } from "next-nprogress-bar"; import Image from "next/image"; import Link from "next/link"; import { useSearchParams } from "next/navigation"; -import { useState, useTransition } from "react"; +import { useEffect, useState, useTransition } from "react"; import { useForm } from "react-hook-form"; import * as z from "zod"; @@ -80,7 +80,9 @@ const LoginPage = () => { const togglePasswordVisibility = () => { setShowPassword(!showPassword); }; - + useEffect(() => { + document.title = "Login"; + }, []); return (
diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 8fd4ae246..5df7c4c2f 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -20,9 +20,9 @@ export default function RootLayout({ return ( + {children} - ); diff --git a/src/hooks/user/use-user.ts b/src/hooks/user/use-user.ts new file mode 100644 index 000000000..cfa8f5871 --- /dev/null +++ b/src/hooks/user/use-user.ts @@ -0,0 +1,40 @@ +import { create } from "zustand"; +import { persist, PersistStorage } from "zustand/middleware"; + +type UserProperties = { + name: string | undefined; + email: string | undefined; + id: string | undefined; +}; + +type ProductsStateProperties = { + user: UserProperties; + + updateUser: (user: UserProperties) => void; +}; + +const storage: PersistStorage = { + getItem: (name) => { + const string_ = localStorage.getItem(name); + if (!string_) return; + return JSON.parse(string_); + }, + setItem: (name, value) => { + localStorage.setItem(name, JSON.stringify(value)); + }, + removeItem: (name) => localStorage.removeItem(name), +}; + +export const useProductsFilters = create()( + persist( + (set) => ({ + user: { + name: undefined, + email: undefined, + id: undefined, + }, + updateUser: (user) => set({ user }), + }), + { name: "user_session", storage }, + ), +);