From 2445f2c3b219030a4ba19ad7e75fd6960b9b21c5 Mon Sep 17 00:00:00 2001 From: teegoood Date: Sun, 14 Jul 2024 17:46:52 +0700 Subject: [PATCH 01/22] fix --- src/app/page.tsx | 2 +- src/context/AuthContext.tsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 0a7ff976..a390e589 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -62,7 +62,7 @@ function Login() { let newPath; if (isStaff) { - newPath = isRegistered ? '/staff/home' : '/staff/register'; + newPath = isRegistered ? '/firstdate/staff/home' : '/staff/register'; } else { newPath = isRegistered ? '/home' : '/register'; } diff --git a/src/context/AuthContext.tsx b/src/context/AuthContext.tsx index 8a8acc27..845f65ca 100644 --- a/src/context/AuthContext.tsx +++ b/src/context/AuthContext.tsx @@ -34,6 +34,8 @@ const AuthProvider: React.FC<{ children: ReactNode }> = ({ const path = usePathname(); const router = useRouter(); const [isReady, setisReady] = useState(false); + console.log(user); + console.log(isReady); const resetContext = useCallback(async () => { const userData = await getUser(); @@ -109,7 +111,7 @@ const AuthProvider: React.FC<{ children: ReactNode }> = ({ setisReady(true); }, [router, path]); - + console.log((user || path == '/') && isReady); return ( {(user || path == '/') && isReady ? ( From 5f26700aacb033c3a5d9b6a9e4270ea2832281e9 Mon Sep 17 00:00:00 2001 From: teegoood Date: Sun, 14 Jul 2024 17:47:11 +0700 Subject: [PATCH 02/22] delete console.log --- src/context/AuthContext.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/context/AuthContext.tsx b/src/context/AuthContext.tsx index 845f65ca..ade6eb7a 100644 --- a/src/context/AuthContext.tsx +++ b/src/context/AuthContext.tsx @@ -34,8 +34,6 @@ const AuthProvider: React.FC<{ children: ReactNode }> = ({ const path = usePathname(); const router = useRouter(); const [isReady, setisReady] = useState(false); - console.log(user); - console.log(isReady); const resetContext = useCallback(async () => { const userData = await getUser(); @@ -111,7 +109,6 @@ const AuthProvider: React.FC<{ children: ReactNode }> = ({ setisReady(true); }, [router, path]); - console.log((user || path == '/') && isReady); return ( {(user || path == '/') && isReady ? ( From 70edd7ff888a3bfa374413ddf1c9d711b836d59f Mon Sep 17 00:00:00 2001 From: teegoood Date: Sun, 14 Jul 2024 19:16:36 +0700 Subject: [PATCH 03/22] refactor: title --- src/app/(main)/edit/page.tsx | 3 +-- src/app/(main)/register/page.tsx | 3 +-- src/app/(main)/staff/edit/page.tsx | 3 +-- src/app/(main)/staff/register/page.tsx | 3 +-- src/context/AuthContext.tsx | 2 +- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/app/(main)/edit/page.tsx b/src/app/(main)/edit/page.tsx index e3128861..2fe908be 100644 --- a/src/app/(main)/edit/page.tsx +++ b/src/app/(main)/edit/page.tsx @@ -157,8 +157,7 @@ export default function Edit() { - - + diff --git a/src/app/(main)/register/page.tsx b/src/app/(main)/register/page.tsx index c4e83fd9..fe582687 100644 --- a/src/app/(main)/register/page.tsx +++ b/src/app/(main)/register/page.tsx @@ -184,8 +184,7 @@ export default function Register() { - - + diff --git a/src/app/(main)/staff/register/page.tsx b/src/app/(main)/staff/register/page.tsx index aa57cf63..8ca99587 100644 --- a/src/app/(main)/staff/register/page.tsx +++ b/src/app/(main)/staff/register/page.tsx @@ -154,8 +154,7 @@ export default function Register() { - - + diff --git a/src/app/(main)/register/page.tsx b/src/app/(main)/register/page.tsx index fe582687..0cb299e2 100644 --- a/src/app/(main)/register/page.tsx +++ b/src/app/(main)/register/page.tsx @@ -184,7 +184,7 @@ export default function Register() { - + diff --git a/src/app/(main)/staff/register/page.tsx b/src/app/(main)/staff/register/page.tsx index 986b6132..5e62ced5 100644 --- a/src/app/(main)/staff/register/page.tsx +++ b/src/app/(main)/staff/register/page.tsx @@ -154,7 +154,7 @@ export default function Register() { - + diff --git a/src/app/(main)/staff/edit/page.tsx b/src/app/(main)/staff/edit/page.tsx index 81f58e9f..72ab7d11 100644 --- a/src/app/(main)/staff/edit/page.tsx +++ b/src/app/(main)/staff/edit/page.tsx @@ -222,6 +222,10 @@ export default function Edit() { + + + + diff --git a/src/app/(main)/staff/register/page.tsx b/src/app/(main)/staff/register/page.tsx index 5e62ced5..d90a8e4d 100644 --- a/src/app/(main)/staff/register/page.tsx +++ b/src/app/(main)/staff/register/page.tsx @@ -235,6 +235,10 @@ export default function Register() { + + + + From b4326ef4e92e5697f3c9ad6e0f629b725fef23dc Mon Sep 17 00:00:00 2001 From: teegoood Date: Sun, 14 Jul 2024 21:57:49 +0700 Subject: [PATCH 09/22] add: medical label --- src/app/(main)/edit/page.tsx | 62 ++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/src/app/(main)/edit/page.tsx b/src/app/(main)/edit/page.tsx index f1f3e045..d60b5f69 100644 --- a/src/app/(main)/edit/page.tsx +++ b/src/app/(main)/edit/page.tsx @@ -300,30 +300,44 @@ export default function Edit() {

ข้อมูลด้านสุขภาพ

- - - + +
+ + + + + +
Date: Sun, 14 Jul 2024 23:14:27 +0700 Subject: [PATCH 10/22] refactor: --- src/app/(main)/edit/page.tsx | 13 ++++++++++--- src/app/(main)/register/page.tsx | 11 +++++++++-- src/app/(main)/staff/edit/page.tsx | 11 +++++++++-- src/app/(main)/staff/register/page.tsx | 11 +++++++++-- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/app/(main)/edit/page.tsx b/src/app/(main)/edit/page.tsx index d60b5f69..c8f74745 100644 --- a/src/app/(main)/edit/page.tsx +++ b/src/app/(main)/edit/page.tsx @@ -59,10 +59,17 @@ export default function Edit() { const handleInputChange = ( e: ChangeEvent ) => { + let value: string = e.target.value; + if (['tel', 'parent_tel'].includes(e.target.name)) { + value = + '0123456789'.includes(value.at(-1) || '') && value.length <= 10 + ? value + : value.slice(0, -1); + } + setFormData({ ...formData, - [e.target.name]: - e.target.name === 'year' ? +e.target.value : e.target.value, + [e.target.name]: e.target.name === 'year' ? +value : value, }); }; @@ -301,7 +308,7 @@ export default function Edit() { ข้อมูลด้านสุขภาพ -
+
); }