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.id === -1 ? (
Null
) : (
-
+
)}
{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: [],