feat: grid layout, global claim/qty toggles, admin access link, swaddle image
- Public wishlist now renders as responsive 3-col grid instead of list - Subtitle supports line breaks (whitespace-pre-line) - claimingEnabled and showQuantity moved to global site settings (not per-item); toggled in admin Configurações panel; claim API enforces server-side - Admin dashboard shows admin access link with copy button - Settings API exposes and persists the two new boolean settings Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,18 +13,18 @@ export async function GET() {
|
||||
return acc;
|
||||
}, {} as Record<string, string>);
|
||||
|
||||
if (!settingsObj.siteTitle) {
|
||||
settingsObj.siteTitle = 'Wishlist';
|
||||
}
|
||||
if (!settingsObj.homepageSubtext) {
|
||||
settingsObj.homepageSubtext = 'Browse and explore available wishlists';
|
||||
}
|
||||
if (!settingsObj.siteTitle) settingsObj.siteTitle = 'Wishlist';
|
||||
if (!settingsObj.homepageSubtext) settingsObj.homepageSubtext = 'Browse and explore available wishlists';
|
||||
if (settingsObj.claimingEnabled === undefined) settingsObj.claimingEnabled = 'true';
|
||||
if (settingsObj.showQuantity === undefined) settingsObj.showQuantity = 'true';
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
settings: {
|
||||
siteTitle: settingsObj.siteTitle,
|
||||
homepageSubtext: settingsObj.homepageSubtext,
|
||||
claimingEnabled: settingsObj.claimingEnabled !== 'false',
|
||||
showQuantity: settingsObj.showQuantity !== 'false',
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
@@ -44,7 +44,7 @@ export async function PUT(request: NextRequest) {
|
||||
}
|
||||
|
||||
const body = await request.json();
|
||||
const { siteTitle, homepageSubtext } = body;
|
||||
const { siteTitle, homepageSubtext, claimingEnabled, showQuantity } = body;
|
||||
|
||||
if (siteTitle !== undefined) {
|
||||
const existing = await db
|
||||
@@ -86,6 +86,18 @@ export async function PUT(request: NextRequest) {
|
||||
}
|
||||
}
|
||||
|
||||
for (const [key, val] of [['claimingEnabled', claimingEnabled], ['showQuantity', showQuantity]] as const) {
|
||||
if (val !== undefined) {
|
||||
const strVal = val ? 'true' : 'false';
|
||||
const existing = await db.select().from(settings).where(eq(settings.key, key)).limit(1);
|
||||
if (existing.length > 0) {
|
||||
await db.update(settings).set({ value: strVal, updatedAt: new Date() }).where(eq(settings.key, key));
|
||||
} else {
|
||||
await db.insert(settings).values({ key, value: strVal });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: 'Settings updated successfully',
|
||||
|
||||
Reference in New Issue
Block a user