From e6d79018828d3f271a747c69389d6283152dcba1 Mon Sep 17 00:00:00 2001 From: BadLuckZ Date: Wed, 23 Jul 2025 12:19:00 +0700 Subject: [PATCH 1/5] feat: House Display --- .../rpkm/components/house-display.astro | 94 +++++++++++++++++++ .../rpkm/components/house-picker.astro | 36 ------- src/components/rpkm/sample.astro | 9 +- 3 files changed, 102 insertions(+), 37 deletions(-) create mode 100644 src/components/rpkm/components/house-display.astro diff --git a/src/components/rpkm/components/house-display.astro b/src/components/rpkm/components/house-display.astro new file mode 100644 index 0000000..bdd5d6c --- /dev/null +++ b/src/components/rpkm/components/house-display.astro @@ -0,0 +1,94 @@ +--- +import Frame from "@/components/common/Frame.astro"; +import { getGroupByGroupId } from "@/lib/groupAPI"; +import { getProfile } from "@/lib/profileAPI"; +import type { Group, User } from "@/types/common"; + + +const token = Astro.cookies.get("token")?.value; + +let groupData: Group | null = null; +let user: User | null = null; + +if (token) { + let groupID = ""; + const userResponse = await getProfile(token); + if (userResponse.success && userResponse.data) { + user = userResponse.data.user as User; + groupID = user.groupId ? user.groupId : ""; + if (groupID) { + const groupResponse = await getGroupByGroupId(groupID, token); + if (groupResponse.success && groupResponse.data) { + groupData = groupResponse.data.data as Group; + } else { + return Astro.redirect("/login"); + } + } else { + return Astro.redirect("/login"); + } + } else { + console.error("Failed to fetch user data:", userResponse.error); + } +} else { + return Astro.redirect("/login"); +} + +if (!groupData || !user) { + return Astro.redirect("/login"); +} + +const assignedHouse = null; // Replace with actual house attribute +--- + +
+ { + assignedHouse ? ( + + {/* Title */} +

+ บ้านรับเพื่อนที่เลือกไว้ +

+ + {/* Empty Houses */} +
+

+ คุณยังไม่ได้เลือกบ้าน +

+
+ + ) : ( + + {/* Title */} +

บ้านรับเพื่อนที่ได้

+ + {/* House Image */} + + + {/* House Name */} +

บ้าน xxx

+ + {/* House Instagram */} + + +

+ baan.something +

+
+ + ) + } +
diff --git a/src/components/rpkm/components/house-picker.astro b/src/components/rpkm/components/house-picker.astro index df5b3b2..7b47ccb 100644 --- a/src/components/rpkm/components/house-picker.astro +++ b/src/components/rpkm/components/house-picker.astro @@ -253,42 +253,6 @@ const isPickAllMainHouses = - - -