-
Couldn't load subscription status.
- Fork 0
Dev #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev #104
Changes from 121 commits
3631609
fe86339
076210b
a25dc69
2eb62c2
4cbcbd3
a70b642
2fa23d2
560d6a0
382c2c8
a5e278f
9846fda
6b9742a
9447040
d3ac27c
cd6e983
e53584f
707f4a7
8395fc4
919a945
9523a05
7878eff
4104be7
80569df
0b94782
e0c6a73
f6e264a
d0acd9f
09d2d67
1c252d1
0bd0a31
82d9fc3
c3c7d6a
8448136
05e7123
dd16c0b
375308a
be3ec12
4657972
366cf26
c56c4d6
2b8d55e
b8cf671
05e413a
9646dcd
7e4ae70
81acaf5
bce2b41
cee3abe
35f12cb
5e26cb2
475d205
86c9d78
3f2f88b
aa7423e
750a5be
f54f419
800b2bb
3637bed
5cf263b
1a0cd73
8d6e30c
f39eb56
02eb4cf
65269ed
49270cb
72c2ba9
83accf5
1a8d9b5
95a5c7f
138bdaf
b2891b2
4afd871
15edd80
fc70ce2
f1e2b41
1e6bfe7
2c4ea81
b5e2297
07881af
96e5daf
6a6f02d
ac39a95
ac4b188
2df5102
becbb76
784401c
4da50d4
33138f5
e260e3a
ec27317
3cca08a
9bd4c79
a27d81a
3c840f9
9a81506
3e7dc2e
b44f991
4e1c296
cec92d3
d2a4c26
10df88e
526e72f
cad26f0
8668389
c9d0c1c
5d4dc0b
61254f2
72451c1
1ec5209
24cce65
3dc52e8
333dac8
da6da87
8bce893
3939045
d553bb9
e7adb11
ae88bf4
1ac9488
047dc2f
8ff1681
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,91 @@ | ||||||
| --- | ||||||
| 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 | ||||||
| --- | ||||||
|
|
||||||
| <div class="h-full w-full" id="view-house-final"> | ||||||
| { | ||||||
| !assignedHouse ? ( | ||||||
| <Frame size="xs" color="purple" contentContainerClass="!h-full"> | ||||||
| {/* Title */} | ||||||
| <p class="text-2xl font-semibold text-white"> | ||||||
| บ้านรับเพื่อนที่เลือกไว้ | ||||||
| </p> | ||||||
|
|
||||||
| {/* Empty Houses */} | ||||||
| <div class="pt-8"> | ||||||
| <p class="text-[28px] font-semibold text-white">คุณไม่ได้เลือกบ้าน</p> | ||||||
| </div> | ||||||
| </Frame> | ||||||
| ) : ( | ||||||
| <Frame | ||||||
| size="md" | ||||||
| color="purple" | ||||||
| contentContainerClass="!h-full !items-center !flex !flex-col" | ||||||
| > | ||||||
| {/* Title */} | ||||||
| <p class="text-2xl font-semibold text-white">บ้านรับเพื่อนที่ได้</p> | ||||||
|
|
||||||
| {/* House Image */} | ||||||
| <img | ||||||
| src="/images/rpkm/house-demo.png" | ||||||
| width={160} | ||||||
| height={160} | ||||||
| class="mt-5 border-4 border-white" | ||||||
| /> | ||||||
|
|
||||||
| {/* House Name */} | ||||||
| <p class="pt-5 text-3xl font-semibold text-white">บ้าน xxx</p> | ||||||
|
|
||||||
| {/* House Instagram */} | ||||||
| <a | ||||||
| id="house-instagram-link-final" | ||||||
| href="https://youtu.be/dQw4w9WgXcQ?si=To9bwNaRw7cl03NT" | ||||||
|
||||||
| target="_blank" | ||||||
| class="flex cursor-pointer items-center gap-1 pt-4 pb-8" | ||||||
| > | ||||||
| <img src="/images/rpkm/instagram-icon.svg" width="20" height="20" /> | ||||||
| <p id="house-instagram-final" class="font-medium text-white"> | ||||||
| baan.something | ||||||
|
||||||
| baan.something | |
| {assignedHouse?.instagramHandle || "Instagram handle not available"} |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,5 @@ | ||||||
| --- | ||||||
| import { disablePickingDate } from "@rpkm/data/date"; | ||||||
| import { | ||||||
| getHouses, | ||||||
| type HouseDisplayType, | ||||||
|
|
@@ -16,6 +17,9 @@ import { getGroupByGroupId } from "@/lib/groupAPI"; | |||||
| import { getProfile } from "@/lib/profileAPI"; | ||||||
| import type { Group, User } from "@/types/common"; | ||||||
|
|
||||||
| const currentDate = new Date(); | ||||||
| const isHousePickingDisabled = currentDate >= disablePickingDate; | ||||||
|
|
||||||
| const houseSizes = ["ทั้งหมด", "S", "M", "L", "XL", "XXL"]; | ||||||
|
|
||||||
| let houseDisplayData: HouseDisplayType[] = []; | ||||||
|
|
@@ -89,7 +93,13 @@ const isPickAllMainHouses = | |||||
|
|
||||||
| <!-- Empty Houses --> | ||||||
| <div class="pt-5"> | ||||||
| <p class="text-[28px] font-semibold text-white">คุณยังไม่ได้เลือกบ้าน</p> | ||||||
| <p class="text-[28px] font-semibold text-white"> | ||||||
| { | ||||||
| !isHousePickingDisabled | ||||||
| ? "คุณยังไม่ได้เลือกบ้าน" | ||||||
| : "คุณไม่ได้เลือกบ้าน" | ||||||
| } | ||||||
| </p> | ||||||
| </div> | ||||||
|
|
||||||
| <!-- Button --> | ||||||
|
|
@@ -253,42 +263,6 @@ const isPickAllMainHouses = | |||||
|
|
||||||
| <HouseConfirmPopup /> | ||||||
|
|
||||||
| <!-- House Final Wrapper --> | ||||||
| <div class="hidden h-full w-full" id="view-house-final"> | ||||||
| <Frame | ||||||
| size="md" | ||||||
| color="purple" | ||||||
| contentContainerClass="!h-full !items-center !flex !flex-col" | ||||||
| > | ||||||
| <!-- Title --> | ||||||
| <p class="text-2xl font-semibold text-white">บ้านรับเพื่อนที่ได้</p> | ||||||
|
|
||||||
| <!-- House Image --> | ||||||
| <img | ||||||
| src="/images/rpkm/house-demo.png" | ||||||
| width={160} | ||||||
| height={160} | ||||||
| class="mt-5 border-4 border-white" | ||||||
| /> | ||||||
|
|
||||||
| <!-- House Name --> | ||||||
| <p class="pt-5 text-3xl font-semibold text-white">บ้าน xxx</p> | ||||||
|
|
||||||
| <!-- House Instagram --> | ||||||
| <a | ||||||
| id="house-instagram-link-final" | ||||||
| href="https://youtu.be/dQw4w9WgXcQ?si=To9bwNaRw7cl03NT" | ||||||
| target="_blank" | ||||||
| class="flex cursor-pointer items-center gap-1 pt-4 pb-8" | ||||||
| > | ||||||
| <img src="/images/rpkm/instagram-icon.svg" width="20" height="20" /> | ||||||
| <p id="house-instagram-final" class="font-medium text-white"> | ||||||
| baan.something | ||||||
| </p> | ||||||
| </a> | ||||||
| </Frame> | ||||||
| </div> | ||||||
|
|
||||||
| <!-- Script --> | ||||||
| <script | ||||||
| define:vars={{ | ||||||
|
|
@@ -298,6 +272,7 @@ const isPickAllMainHouses = | |||||
| token: token || "", | ||||||
| isConfirmed: isConfirmed, | ||||||
| isOwner: isOwner, | ||||||
| isHousePickingDisabled: isHousePickingDisabled, | ||||||
| }} | ||||||
| > | ||||||
| document.addEventListener("DOMContentLoaded", () => { | ||||||
|
|
@@ -309,15 +284,17 @@ const isPickAllMainHouses = | |||||
| const houseSearchInput = document.getElementById("house-search"); | ||||||
| const houseSizeFilter = document.getElementById("house-size-filter"); | ||||||
| const houseSizeOptions = document.querySelectorAll(".size-option"); | ||||||
|
|
||||||
| const houseCardContainer = document.getElementById("house-card-container"); | ||||||
| const closeBtn = document.getElementById("popup-close-btn"); | ||||||
| if (!isOwner) { | ||||||
| if (!isOwner || isHousePickingDisabled) { | ||||||
| closeBtn.classList.add("hidden"); | ||||||
| } else { | ||||||
| closeBtn.classList.remove("hidden"); | ||||||
| } | ||||||
|
|
||||||
| const pickBtn = document.getElementById("btn-picking-house"); | ||||||
| if (!isOwner) { | ||||||
| if (!isOwner || isConfirmed || isHousePickingDisabled) { | ||||||
| pickBtn.disabled = true; | ||||||
| pickBtn.classList.add("cursor-not-allowed", "opacity-50"); | ||||||
| pickBtn.classList.remove("cursor-pointer", "opacity-100"); | ||||||
|
|
@@ -328,12 +305,14 @@ const isPickAllMainHouses = | |||||
| pickBtn.classList.add("cursor-pointer", "opacity-100"); | ||||||
| pickBtn.innerHTML = `<p class="text-xl text-white font-medium">เลือกบ้าน</p>`; | ||||||
| } | ||||||
|
|
||||||
| const submitBtn = document.getElementById("btn-submit-house"); | ||||||
| if (!isOwner) { | ||||||
| if (!isOwner || isHousePickingDisabled || isConfirmed) { | ||||||
| submitBtn.classList.add("hidden"); | ||||||
| } else { | ||||||
| submitBtn.classList.remove("hidden"); | ||||||
| } | ||||||
|
|
||||||
| const notPickingView = document.getElementById("view-not-picking"); | ||||||
| const pickingView = document.getElementById("view-picking"); | ||||||
|
|
||||||
|
|
@@ -676,7 +655,10 @@ const isPickAllMainHouses = | |||||
| <p class="text-xs text-[#2B2D42] font-semibold text-center overflow-hidden whitespace-nowrap text-ellipsis">${house.nameThai}</p> | ||||||
| </div> | ||||||
| ${ | ||||||
| isOwner && !isConfirmed && !isSubmitted | ||||||
| isOwner && | ||||||
| !isConfirmed && | ||||||
| !isSubmitted && | ||||||
| !isHousePickingDisabled | ||||||
| ? ` | ||||||
| <div class="flex justify-center"> | ||||||
| <button class="cursor-pointer flex justify-center items-center"> | ||||||
|
|
@@ -691,9 +673,9 @@ const isPickAllMainHouses = | |||||
| } else { | ||||||
| card.innerHTML = ` | ||||||
| <button | ||||||
| class="relative h-[100px] w-[80px] border-dashed border-2 flex justify-center items-center border-[#D38DD8] ${isOwner && !isConfirmed && !isSubmitted ? "hover:bg-[#D38DD8]/20 transition-colors cursor-pointer" : "cursor-default"}" | ||||||
| class="relative h-[100px] w-[80px] border-dashed border-2 flex justify-center items-center border-[#D38DD8] ${isOwner && !isConfirmed && !isSubmitted && !isHousePickingDisabled ? "hover:bg-[#D38DD8]/20 transition-colors cursor-pointer" : "cursor-default"}" | ||||||
| data-rank="${rank}" | ||||||
| ${!isOwner ? "disabled" : ""} | ||||||
| ${!isOwner || isHousePickingDisabled ? "disabled" : ""} | ||||||
| > | ||||||
| <img | ||||||
| src="/images/rpkm/rank-${rank}.svg" | ||||||
|
|
@@ -703,7 +685,7 @@ const isPickAllMainHouses = | |||||
| /> | ||||||
| <img | ||||||
| src="/images/rpkm/plus-icon.svg" | ||||||
| class="w-5 h-5 ${isOwner && !isConfirmed && !isSubmitted ? "" : "hidden"}" | ||||||
| class="w-5 h-5 ${!isHousePickingDisabled && isOwner && !isConfirmed && !isSubmitted ? "" : "hidden"}" | ||||||
| /> | ||||||
| </button> | ||||||
| `; | ||||||
|
|
@@ -877,7 +859,7 @@ const isPickAllMainHouses = | |||||
| // Update instagram link | ||||||
| const instagramLink = housePopup?.querySelector("#house-instagram-link"); | ||||||
| if (instagramLink) { | ||||||
| instagramLink.href = house.instagramURL; | ||||||
| instagramLink.href = house.instagram; | ||||||
|
||||||
| instagramLink.href = house.instagram; | |
| instagramLink.href = house.instagram || house.instagramURL || "#"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export const disablePickingDate = new Date("2025-07-24T00:00:00+07:00"); | ||
| export const displayHouseDate = new Date("2025-07-27T00:00:00+07:00"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assignedHouse variable is hardcoded to null with a TODO comment. This will always render the 'no house selected' state regardless of actual data. The logic should be implemented to fetch the actual assigned house from the group data.