x
This commit is contained in:
1 parent
e405af357c
commit
e1cf9e62e7
51 files changed
+2598
-168
No files matched your search
@@ -699,6 +699,97 @@ async function main() {
|
||||
});
|
||||
|
||||
console.log("✅ Seeded default Category, Product Detail, FAQ, Wishlist, Search, Coupons, Contact, Order Success, and Track Order layouts successfully!");
|
||||
|
||||
// 14. Create Checkout Page Layout
|
||||
const checkoutPage = await prisma.page.upsert({
|
||||
where: { slug: "checkout-layout" },
|
||||
update: {},
|
||||
create: {
|
||||
slug: "checkout-layout",
|
||||
title: "Checkout Page Layout",
|
||||
isPublished: true,
|
||||
}
|
||||
});
|
||||
console.log(`✅ Created page: ${checkoutPage.title} (slug: ${checkoutPage.slug})`);
|
||||
await prisma.pageSection.deleteMany({ where: { pageId: checkoutPage.id } });
|
||||
await prisma.pageSection.create({
|
||||
data: {
|
||||
pageId: checkoutPage.id,
|
||||
type: "ANNOUNCEMENT_BAR",
|
||||
order: 1,
|
||||
isActive: true,
|
||||
payload: {
|
||||
slides: ["Secure checkout powered by HomAroma — all payments are encrypted and protected", "Free shipping on orders over ฿1,500"],
|
||||
backgroundColor: "#1F3D2D",
|
||||
textColor: "#FDFDF9",
|
||||
speed: 4000
|
||||
}
|
||||
}
|
||||
});
|
||||
await prisma.pageSection.create({
|
||||
data: {
|
||||
pageId: checkoutPage.id,
|
||||
type: "EDITORIAL_TILE",
|
||||
order: 2,
|
||||
isActive: true,
|
||||
payload: {
|
||||
title: "Crafted for Your [Sanctuary]",
|
||||
description: "Every HomAroma order is hand-packed with care using eco-conscious materials, so your botanicals arrive in perfect condition.",
|
||||
imageUrl: "/images/oil_ozone.png",
|
||||
imagePosition: "right",
|
||||
buttonText: "Our Sustainability Promise",
|
||||
buttonLink: "/about",
|
||||
backgroundColor: "#FDFDF9",
|
||||
textColor: "#1F3D2D"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 15. Create Profile Page Layout
|
||||
const profilePage = await prisma.page.upsert({
|
||||
where: { slug: "profile-layout" },
|
||||
update: {},
|
||||
create: {
|
||||
slug: "profile-layout",
|
||||
title: "Profile Page Layout",
|
||||
isPublished: true,
|
||||
}
|
||||
});
|
||||
console.log(`✅ Created page: ${profilePage.title} (slug: ${profilePage.slug})`);
|
||||
await prisma.pageSection.deleteMany({ where: { pageId: profilePage.id } });
|
||||
await prisma.pageSection.create({
|
||||
data: {
|
||||
pageId: profilePage.id,
|
||||
type: "ANNOUNCEMENT_BAR",
|
||||
order: 1,
|
||||
isActive: true,
|
||||
payload: {
|
||||
slides: ["Welcome back to HomAroma — manage your orders and wishlist from your profile", "Earn points with every purchase"],
|
||||
backgroundColor: "#1F3D2D",
|
||||
textColor: "#FDFDF9",
|
||||
speed: 4000
|
||||
}
|
||||
}
|
||||
});
|
||||
await prisma.pageSection.create({
|
||||
data: {
|
||||
pageId: profilePage.id,
|
||||
type: "NEWSLETTER",
|
||||
order: 2,
|
||||
isActive: true,
|
||||
payload: {
|
||||
title: "Exclusive Member Benefits",
|
||||
description: "Subscribe to receive early access to new collections, member-only discounts, and scent guides curated just for you.",
|
||||
buttonText: "Subscribe",
|
||||
placeholderText: "Enter your email address",
|
||||
showPrivacyCheckbox: true,
|
||||
privacyText: "I agree to the privacy policy."
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log("✅ Seeded checkout-layout and profile-layout successfully!");
|
||||
console.log("🌱 All 15 required pages seeded successfully!");
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 301 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 592 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 694 KiB |
@@ -115,4 +115,55 @@ export const settingsRoute = new Elysia({ prefix: "/settings" })
|
||||
set.status = 500;
|
||||
return { error: "Failed to update settings translation" };
|
||||
}
|
||||
})
|
||||
.post("/seed-pages", async ({ set }) => {
|
||||
try {
|
||||
const REQUIRED_PAGES = [
|
||||
{ slug: "home", title: "Home Page" },
|
||||
{ slug: "shop-layout", title: "Shop Page Layout" },
|
||||
{ slug: "scent-guide-layout", title: "Scent Guide Layout" },
|
||||
{ slug: "category-layout", title: "Category Page Layout" },
|
||||
{ slug: "product-detail-layout", title: "Product Detail Layout" },
|
||||
{ slug: "faq-layout", title: "FAQ Page Layout" },
|
||||
{ slug: "wishlist-layout", title: "Wishlist Page Layout" },
|
||||
{ slug: "search-layout", title: "Search Page Layout" },
|
||||
{ slug: "coupons-layout", title: "Coupons Page Layout" },
|
||||
{ slug: "contact-layout", title: "Contact Page Layout" },
|
||||
{ slug: "order-success-layout", title: "Order Success Page Layout" },
|
||||
{ slug: "track-order-layout", title: "Track Order Page Layout" },
|
||||
{ slug: "checkout-layout", title: "Checkout Page Layout" },
|
||||
{ slug: "profile-layout", title: "Profile Page Layout" },
|
||||
];
|
||||
|
||||
const results: { slug: string; status: "created" | "exists" }[] = [];
|
||||
|
||||
for (const page of REQUIRED_PAGES) {
|
||||
const existing = await prisma.page.findUnique({ where: { slug: page.slug } });
|
||||
if (!existing) {
|
||||
await prisma.page.create({
|
||||
data: {
|
||||
slug: page.slug,
|
||||
title: page.title,
|
||||
isPublished: true,
|
||||
}
|
||||
});
|
||||
results.push({ slug: page.slug, status: "created" });
|
||||
} else {
|
||||
results.push({ slug: page.slug, status: "exists" });
|
||||
}
|
||||
}
|
||||
|
||||
const created = results.filter(r => r.status === "created").length;
|
||||
const existed = results.filter(r => r.status === "exists").length;
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `Seed complete: ${created} pages created, ${existed} pages already existed.`,
|
||||
results
|
||||
};
|
||||
} catch (err) {
|
||||
console.error("[Settings] Seed Pages Error:", err);
|
||||
set.status = 500;
|
||||
return { error: "Failed to seed pages" };
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user