From 54ae6a4b02e3f64e47ac46734464255af4f8fea3 Mon Sep 17 00:00:00 2001 From: gunshiz Date: Sat, 12 Sep 2026 15:01:22 +0700 Subject: [PATCH] feat : add codition for stats build --- app/admin/login/page.tsx | 4 +- components/admin/guide-section-editor.tsx | 106 +- components/admin/login-card.tsx | 40 +- components/public/artifact-image-export.tsx | 28 +- components/public/structured-guide.tsx | 114 +- db/schema.ts | 4 + drizzle/0043_eager_killmonger.sql | 1 + drizzle/meta/0043_snapshot.json | 2701 +++++++++++++++++++ drizzle/meta/_journal.json | 7 + lib/auth/server.ts | 12 +- lib/guides/mutations.ts | 2 +- lib/guides/queries.ts | 2 +- lib/guides/schemas.test.ts | 14 + lib/guides/schemas.ts | 8 + lib/guides/stats.ts | 6 +- 15 files changed, 2951 insertions(+), 98 deletions(-) create mode 100644 drizzle/0043_eager_killmonger.sql create mode 100644 drizzle/meta/0043_snapshot.json diff --git a/app/admin/login/page.tsx b/app/admin/login/page.tsx index 943b8be..99449ac 100644 --- a/app/admin/login/page.tsx +++ b/app/admin/login/page.tsx @@ -10,7 +10,7 @@ export default async function AdminLoginPage() { if (await getAdminSession()) redirect("/admin"); const turnstileSiteKey = process.env.TURNSTILE_SITE_KEY; - if (!turnstileSiteKey) { + if (process.env.NODE_ENV !== "development" && !turnstileSiteKey) { throw new Error("TURNSTILE_SITE_KEY is required for administrator login."); } @@ -18,7 +18,7 @@ export default async function AdminLoginPage() {
- +
); diff --git a/components/admin/guide-section-editor.tsx b/components/admin/guide-section-editor.tsx index baeeda9..7dc04a3 100644 --- a/components/admin/guide-section-editor.tsx +++ b/components/admin/guide-section-editor.tsx @@ -248,6 +248,14 @@ type ArtifactProfile = { goblet: string[]; circlet: string[]; substats: string[]; + recommendedConditions: Array<{ + name?: string | null; + note: string | null; + sands: string[]; + goblet: string[]; + circlet: string[]; + substats: string[]; + }>; targets: Array<{ stat: string; value: string }>; targetConditions: Array<{ name?: string | null; @@ -745,7 +753,7 @@ function StatSelect({ : undefined} - + {options.map((option) => ( { + const source = profile?.recommendedConditions.length + ? profile.recommendedConditions + : [{ name: null, note: null, sands: profile?.sands ?? [], goblet: profile?.goblet ?? [], circlet: profile?.circlet ?? [], substats: profile?.substats ?? [] }]; + return source.map((group, index) => ({ ...group, clientId: `recommended-condition-${index}`, name: group.name ?? "", note: group.note ?? "" })); + }); + const [activeRecommendedGroupIndex, setActiveRecommendedGroupIndex] = useState(0); + const [renamingRecommendedGroupIndex, setRenamingRecommendedGroupIndex] = useState(null); + const recommended = recommendedGroups[activeRecommendedGroupIndex]; + const { sands, goblet, circlet, substats } = recommended; + const setRecommendedStat = (slot: "sands" | "goblet" | "circlet" | "substats", values: string[]) => + setRecommendedGroups((current) => current.map((group, index) => index === activeRecommendedGroupIndex ? { ...group, [slot]: values } : group)); const [targetGroups, setTargetGroups] = useState(() => { const source = profile?.targetConditions.length ? profile.targetConditions @@ -1812,10 +1828,11 @@ function ArtifactEditor({ note: row.note?.trim() || null, })), })), - sands, - goblet, - circlet, - substats, + sands: recommendedGroups[0].sands, + goblet: recommendedGroups[0].goblet, + circlet: recommendedGroups[0].circlet, + substats: recommendedGroups[0].substats, + recommendedGroups: recommendedGroups.map(({ name, note, sands, goblet, circlet, substats }) => ({ name: name.trim() || null, note: note.trim() || null, sands, goblet, circlet, substats })), targetGroups: targetGroups.map((group) => ({ name: group.name.trim() || null, note: group.note.trim() || null, @@ -1836,6 +1853,8 @@ function ArtifactEditor({ goblet, circlet, substats, + recommendedGroups, + activeRecommendedGroupIndex, targetGroups, activeTargetGroupIndex, talents, @@ -1865,10 +1884,8 @@ function ArtifactEditor({ ), restoreLocalDraft: (draft) => { setGroups(draft.groups); - setSands(draft.sands); - setGoblet(draft.goblet); - setCirclet(draft.circlet); - setSubstats(draft.substats); + setRecommendedGroups(draft.recommendedGroups?.length ? draft.recommendedGroups : [{ clientId: createClientId("recommended-condition"), name: "", note: "", sands: draft.sands, goblet: draft.goblet, circlet: draft.circlet, substats: draft.substats }]); + setActiveRecommendedGroupIndex(Math.min(draft.activeRecommendedGroupIndex ?? 0, Math.max(0, (draft.recommendedGroups?.length ?? 1) - 1))); setTargetGroups(draft.targetGroups.map((group) => ({ ...group, name: group.name ?? "" }))); setActiveTargetGroupIndex(draft.activeTargetGroupIndex ?? 0); setTalents(draft.talents); @@ -2177,36 +2194,79 @@ function ArtifactEditor({ ))} - - - Recommended Stats + + + Recommended Stats +
+ { + const reordered = reorderConditions(recommendedGroups, activeRecommendedGroupIndex, from, to); + setRecommendedGroups(reordered.items); + setActiveRecommendedGroupIndex(reordered.activeIndex); + }} + /> + { if (!open) setRenamingRecommendedGroupIndex(null); }} + onChange={(name) => setRecommendedGroups(recommendedGroups.map((group, index) => index === renamingRecommendedGroupIndex ? { ...group, name } : group))} + /> + + + + + + +
+ + Condition note (optional) +