diff --git a/src/components/Profile/BaanSelection/components/BaanPanel.tsx b/src/components/Profile/BaanSelection/components/BaanPanel.tsx index 252e71d..bd34d93 100644 --- a/src/components/Profile/BaanSelection/components/BaanPanel.tsx +++ b/src/components/Profile/BaanSelection/components/BaanPanel.tsx @@ -1,6 +1,7 @@ import Image from 'next/image'; import { SelectedBaan } from '..'; import { CheckCircleIcon } from '@heroicons/react/24/outline'; +import Link from 'next/link'; const profilePic = '/images/pfp-placeholder.svg'; @@ -23,8 +24,8 @@ export default function BaanPanel() { key={data.name} className="flex h-full w-full flex-col items-center justify-center gap-4 px-4" > -
-

+

+

{data.num}

{data.name} @@ -42,9 +43,11 @@ export default function BaanPanel() { ระบบได้ทำการบันทึกเรียบร้อยแล้ว

- + + +
); diff --git a/src/components/Profile/BaanSelection/components/GroupPanel.tsx b/src/components/Profile/BaanSelection/components/GroupPanel.tsx index 60b3305..647ca31 100644 --- a/src/components/Profile/BaanSelection/components/GroupPanel.tsx +++ b/src/components/Profile/BaanSelection/components/GroupPanel.tsx @@ -25,14 +25,14 @@ export default function GroupPanel() {

สมาชิกในกลุ่ม(2/3)

-
+
{group.map((data: GroupMember) => { return (
-
+
{data.name}
diff --git a/src/components/Profile/BaanSelection/components/ProfileInfoPanel.tsx b/src/components/Profile/BaanSelection/components/ProfileInfoPanel.tsx index 6bf014b..8211639 100644 --- a/src/components/Profile/BaanSelection/components/ProfileInfoPanel.tsx +++ b/src/components/Profile/BaanSelection/components/ProfileInfoPanel.tsx @@ -6,14 +6,14 @@ const profilePic = '/images/pfp-placeholder.svg'; export default function ProfileInfoPanel() { return (
-
+
profile pic
-
+

แจฮยอน
คงแก่การเรียน -

+

diff --git a/src/components/baan-selection/FilterButton.tsx b/src/components/baan-selection/FilterButton.tsx index 6bb6041..b6067bd 100644 --- a/src/components/baan-selection/FilterButton.tsx +++ b/src/components/baan-selection/FilterButton.tsx @@ -1,34 +1,52 @@ import { BaanSize } from '@/types/baan'; -const FilterButton = (props: any) => { +interface FilterButtonProps { + filter: BaanSize; + filterBaan: (f: BaanSize, n: number) => void; +} + +const FilterButton = (props: FilterButtonProps) => { return ( -
+
+ ); }; diff --git a/src/components/baan-selection/SelectedBaan.tsx b/src/components/baan-selection/SelectedBaan.tsx index bf1c68a..db23426 100644 --- a/src/components/baan-selection/SelectedBaan.tsx +++ b/src/components/baan-selection/SelectedBaan.tsx @@ -7,44 +7,31 @@ const SelectedBaan = (props: any) => { return (
Go to line 349... + className="flex flex-col items-center gap-2 text-sm text-purple lg:flex-row" + onDrop={props.handleDrop} onDragOver={(e) => e.preventDefault()} > -
-
-

{props.num}

-
+
+

+ {props.num} +

{props.id === -1 ? (

Null

) : ( - {props.name} + {props.name} )}
{props.id === -1 ? ( -
-

ท่านยังไม่ได้เลือกบ้าน

-
+

ท่านยังไม่ได้เลือกบ้าน

) : ( -
-

{`${ - props.name - } (${convertSize.get(props.size)})`}

-
)} diff --git a/src/context/AuthContext.tsx b/src/context/AuthContext.tsx index 30ec41d..9fcd644 100644 --- a/src/context/AuthContext.tsx +++ b/src/context/AuthContext.tsx @@ -7,7 +7,6 @@ import { useRouter } from 'next/router'; import { ReactNode, createContext, - use, useCallback, useContext, useEffect, @@ -80,7 +79,7 @@ const AuthProvider = ({ children }: { children: ReactNode }) => { switch (router.pathname) { case '/': if (user) { - if (alreadyRegistered) router.push('/wait-baan-selection'); + if (alreadyRegistered) router.push('/profile'); else router.push('/register'); } break; @@ -88,10 +87,12 @@ const AuthProvider = ({ children }: { children: ReactNode }) => { if (!user) { router.push('/'); } else if (alreadyRegistered) { - router.push('/wait-baan-selection'); + router.push('/profile'); } break; case '/wait-baan-selection': + case '/profile': + case '/baan-selection': if (!user) { router.push('/'); } else if (!alreadyRegistered) { diff --git a/src/pages/baan-selection/index.tsx b/src/pages/baan-selection/index.tsx index 30e36f2..d064396 100644 --- a/src/pages/baan-selection/index.tsx +++ b/src/pages/baan-selection/index.tsx @@ -1,4 +1,4 @@ -import React, { ChangeEvent, useState } from 'react'; +import React, { useState } from 'react'; import SelectedBaan from '@/components/baan-selection/SelectedBaan'; import ListBaan from '@/components/baan-selection/ListBaan'; import { BaanSize, IBaan } from '@/types/baan'; @@ -9,15 +9,7 @@ import SearchBar from '@/components/baan-selection/SearchBar'; const BaanChoosing = () => { const [input, setInput] = useState(''); //Input in search-baan bar - const [fill, setFill] = useState(BaanSize._); //Check if the baan size filter is activated in which button - const [toggleColor, setToggleColor] = useState([ - //Set the style of the filter button - 'unclicked-size-button', - 'unclicked-size-button', - 'unclicked-size-button', - 'unclicked-size-button', - 'unclicked-size-button', - ]); + const [filter, setFilter] = useState(BaanSize._); //Check if the baan size filter is activated in which button const [baan, setBaan] = useState(testBaanData); //The list of every baans in RPKM... const [selectedBaan, setSelectedBaan] = useState([ //Baans that the user chooses @@ -45,31 +37,17 @@ const BaanChoosing = () => { ]); const filterBaan = (f: BaanSize, n: number) => { - //Handle when clicking on the filter button by size - setBaan(testBaanData); //Reset the data in Baan - const toToggle: string[] = [ - //Reset data in toggle - 'unclicked-size-button', - 'unclicked-size-button', - 'unclicked-size-button', - 'unclicked-size-button', - 'unclicked-size-button', - ]; - if (fill == f) setFill(BaanSize._); - //If clicking on the same button, reset to default filter (every baan) + setBaan(testBaanData); + if (filter == f) setFilter(BaanSize._); else { - setFill(f); - setBaan(testBaanData.filter((e: IBaan) => e.size == f)); //Filter baan by size button and change the button color - toToggle[n] = - 'bg-red-500 ring-pink-200/30 transition-all duration-300'; + setFilter(f); + setBaan(testBaanData.filter((e: IBaan) => e.size == f)); } - setToggleColor(toToggle); }; + const handleDrop = (e: React.DragEvent, n: number) => { - //Handle event when dragging - if (selectedBaan[n - 1].id !== -1) return; //If there is already a data in the div (not null), exit function + if (selectedBaan[n - 1].id !== -1) return; const widget: SelectedBaanRank = JSON.parse( - //Convert JSON string to SelectedBaanRank e.dataTransfer.getData('Data') as string ); const data: SelectedBaanRank[] = [...selectedBaan]; @@ -82,17 +60,18 @@ const BaanChoosing = () => { }; setSelectedBaan(data); }; + return ( - <> -
-
-

+
+
+
+

เลือกบ้าน

-

+

เลือก 3 บ้านที่สนใจมากที่สุด

-
+
{selectedBaan.map( (e: SelectedBaanRank, index: number) => { return ( @@ -110,18 +89,15 @@ const BaanChoosing = () => { )}
-
-
-
-

ค้นหาบ้าน

-
+
+
+

+ ค้นหาบ้าน +

- -
+ +
{
- +
); }; diff --git a/src/styles/globals.css b/src/styles/globals.css index bfdeb70..02bac95 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -6,10 +6,4 @@ .input { @apply mb-4 w-full rounded-full border-gray-100 bg-gray-100 p-2 px-3; } - .select-size-button { - @apply mr-6 w-fit rounded-lg px-2 py-1 text-xs ring-8 lg:px-4 lg:py-2 lg:text-sm; - } - .unclicked-size-button { - @apply bg-pink-400 ring-pink-400/30 transition-all duration-300 hover:bg-red-400; - } } diff --git a/tailwind.config.js b/tailwind.config.js index 0519a6e..841f2e1 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -35,6 +35,9 @@ const config = { '5xl': '3rem', '6xl': '4.5rem', }, + maxWidth: { + xxs: '14rem', + }, }, }, plugins: [],