diff --git a/src/pages/baan-selection/components/ListBaan.tsx b/src/pages/baan-selection/components/ListBaan.tsx
index b082859..46ac07e 100644
--- a/src/pages/baan-selection/components/ListBaan.tsx
+++ b/src/pages/baan-selection/components/ListBaan.tsx
@@ -1,5 +1,5 @@
import Image from 'next/image';
-import { convertSize, isAdded } from '../hooks/utility';
+import { convertSize, isAdded } from '../utils/utility';
import { IBaan } from '@/types/baan';
const ListBaan = (props: any) => {
return props.baan
diff --git a/src/pages/baan-selection/components/SelectedBaan.tsx b/src/pages/baan-selection/components/SelectedBaan.tsx
index 8b13b55..36a76c4 100644
--- a/src/pages/baan-selection/components/SelectedBaan.tsx
+++ b/src/pages/baan-selection/components/SelectedBaan.tsx
@@ -1,8 +1,8 @@
import TrashIcon from '@heroicons/react/24/solid/TrashIcon';
-import { SelectedBaanRank } from '../hooks/types';
+import { SelectedBaanRank } from '../utils/types';
import Image from 'next/image';
import { BaanSize } from '@/types/baan';
-import { convertSize } from '../hooks/utility';
+import { convertSize } from '../utils/utility';
const SelectedBaan = (props: any) => {
return (
{
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
diff --git a/src/pages/baan-selection/utils/testData.tsx b/src/pages/baan-selection/utils/testData.tsx
new file mode 100644
index 0000000..f15d2a8
--- /dev/null
+++ b/src/pages/baan-selection/utils/testData.tsx
@@ -0,0 +1,172 @@
+import { IBaan, BaanSize } from '@/types/baan';
+
+export const picTest1: string = '/images/rocket.svg'; //Pictures for testing...
+
+export const testBaanData: IBaan[] = [
+ //Test Data
+ {
+ id: 0,
+ name: 'บ้านทรายทอง',
+ size: BaanSize.Small,
+ imageUrl: picTest1,
+ description: '',
+ facebook: '',
+ ig: '',
+ igUrl: '',
+ facebookUrl: '',
+ },
+ {
+ id: 1,
+ name: 'บ้านนี้มีรัก',
+ size: BaanSize.Small,
+ imageUrl: picTest1,
+ description: '',
+ facebook: '',
+ ig: '',
+ igUrl: '',
+ facebookUrl: '',
+ },
+ {
+ id: 2,
+ name: 'บ้านและสวน',
+ size: BaanSize.Small,
+ imageUrl: picTest1,
+ description: '',
+ facebook: '',
+ ig: '',
+ igUrl: '',
+ facebookUrl: '',
+ },
+ {
+ id: 3,
+ name: 'บ้านนอก',
+ size: BaanSize.Small,
+ imageUrl: picTest1,
+ description: '',
+ facebook: '',
+ ig: '',
+ igUrl: '',
+ facebookUrl: '',
+ },
+ {
+ id: 4,
+ name: 'บ้านของใคร',
+ size: BaanSize.Medium,
+ imageUrl: picTest1,
+ description: '',
+ facebook: '',
+ ig: '',
+ igUrl: '',
+ facebookUrl: '',
+ },
+ {
+ id: 5,
+ name: 'บ้านอะไรก็ไม่รู้',
+ size: BaanSize.Medium,
+ imageUrl: picTest1,
+ description: '',
+ facebook: '',
+ ig: '',
+ igUrl: '',
+ facebookUrl: '',
+ },
+ {
+ id: 6,
+ name: 'บ้านบ้าน',
+ size: BaanSize.Large,
+ imageUrl: picTest1,
+ description: '',
+ facebook: '',
+ ig: '',
+ igUrl: '',
+ facebookUrl: '',
+ },
+ {
+ id: 7,
+ name: 'บ้าน Pure',
+ size: BaanSize.Large,
+ imageUrl: picTest1,
+ description: '',
+ facebook: '',
+ ig: '',
+ igUrl: '',
+ facebookUrl: '',
+ },
+ {
+ id: 8,
+ name: 'บ้าน Dota',
+ size: BaanSize.Large,
+ imageUrl: picTest1,
+ description: '',
+ facebook: '',
+ ig: '',
+ igUrl: '',
+ facebookUrl: '',
+ },
+ {
+ id: 9,
+ name: 'บ้าน LOL',
+ size: BaanSize.ExtraLarge,
+ imageUrl: picTest1,
+ description: '',
+ facebook: '',
+ ig: '',
+ igUrl: '',
+ facebookUrl: '',
+ },
+ {
+ id: 10,
+ name: 'บ้าน ROV',
+ size: BaanSize.ExtraLarge,
+ imageUrl: picTest1,
+ description: '',
+ facebook: '',
+ ig: '',
+ igUrl: '',
+ facebookUrl: '',
+ },
+ {
+ id: 11,
+ name: 'บ้าน ggez',
+ size: BaanSize.ExtraLarge,
+ imageUrl: picTest1,
+ description: '',
+ facebook: '',
+ ig: '',
+ igUrl: '',
+ facebookUrl: '',
+ },
+ {
+ id: 12,
+ name: 'บ้าน HON',
+ size: BaanSize.ExtraExtraLarge,
+ imageUrl: picTest1,
+ description: '',
+ facebook: '',
+ ig: '',
+ igUrl: '',
+ facebookUrl: '',
+ },
+ {
+ id: 13,
+ name: 'บ้าน F',
+ size: BaanSize.ExtraExtraLarge,
+ imageUrl: picTest1,
+ description: '',
+ facebook: '',
+ ig: '',
+ igUrl: '',
+ facebookUrl: '',
+ },
+ {
+ id: 14,
+ name: 'บ้าน U ',
+ size: BaanSize.ExtraExtraLarge,
+ imageUrl: picTest1,
+ description: '',
+ facebook: '',
+ ig: '',
+ igUrl: '',
+ facebookUrl: '',
+ },
+];
diff --git a/src/pages/baan-selection/hooks/types.tsx b/src/pages/baan-selection/utils/types.tsx
similarity index 100%
rename from src/pages/baan-selection/hooks/types.tsx
rename to src/pages/baan-selection/utils/types.tsx
diff --git a/src/pages/baan-selection/hooks/utility.tsx b/src/pages/baan-selection/utils/utility.tsx
similarity index 100%
rename from src/pages/baan-selection/hooks/utility.tsx
rename to src/pages/baan-selection/utils/utility.tsx
diff --git a/src/utils/baan.ts b/src/utils/baan.ts
new file mode 100644
index 0000000..840442a
--- /dev/null
+++ b/src/utils/baan.ts
@@ -0,0 +1,50 @@
+import axios from 'axios';
+import { IBaan } from '../types/baan';
+import { IGroup } from '../types/group';
+import { BaanDTO } from '../dto/baanDTO';
+
+export const convertBaanDTOtoIBaan = (
+ baanDTO: BaanDTO,
+ locale: 'TH' | 'EN'
+): IBaan => ({
+ id: baanDTO.id,
+ name: baanDTO[`name${locale}`],
+ description: baanDTO[`description${locale}`]
+ .replaceAll(/[\n]*(?=[\n])/g, '')
+ .replaceAll('\n', '\n\n'),
+ facebook: baanDTO.facebook || '',
+ facebookUrl: baanDTO.facebookUrl || '',
+ imageUrl: baanDTO.imageUrl || '',
+ ig: baanDTO.instagram || '',
+ igUrl: baanDTO.instagramUrl || '',
+ size: baanDTO.size || 0,
+});
+
+export const getBaanInfo = async (locale?: string): Promise> => {
+ const res = await axios.get(`${process.env.NEXT_PUBLIC_API_BASE_URL}/baan`);
+ const baan = res.data as Array;
+
+ const localeStr = (locale?.toUpperCase() as 'TH' | 'EN') || 'TH';
+
+ if (!baan) return [];
+
+ return baan.map((b) => convertBaanDTOtoIBaan(b, localeStr));
+};
+
+export const haveBaan = (group?: IGroup) => group?.baans?.length !== 0;
+
+export const getBaanInfoById = async (
+ id: string,
+ locale?: string
+): Promise => {
+ const res = await axios.get(
+ `${process.env.NEXT_PUBLIC_API_BASE_URL}/baan/${id}`
+ );
+ const baan = res.data as BaanDTO;
+
+ const localeStr = (locale?.toUpperCase() as 'TH' | 'EN') || 'TH';
+
+ if (!baan) return {} as IBaan;
+
+ return convertBaanDTOtoIBaan(baan, localeStr);
+};