From 84a9b5c60323152a678782b2b2bb3e12e93823b3 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 14 Jun 2026 19:07:17 -0400 Subject: [PATCH] update lang --- apps/backend/scripts/migrate-production.ts | 94 ++++++++++++++++++++++ apps/backend/src/routes/pages.ts | 4 +- 2 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 apps/backend/scripts/migrate-production.ts diff --git a/apps/backend/scripts/migrate-production.ts b/apps/backend/scripts/migrate-production.ts new file mode 100644 index 0000000..3f35652 --- /dev/null +++ b/apps/backend/scripts/migrate-production.ts @@ -0,0 +1,94 @@ +import axios from 'axios'; + +const BACKEND_URL = "https://api.homaroma.shop/api"; +const ADMIN_USERNAME = "admin"; +const ADMIN_PASSWORD = "homaroma123"; + +async function main() { + console.log("Authenticating..."); + const authRes = await axios.post(`${BACKEND_URL}/auth/login`, { + username: ADMIN_USERNAME, + password: ADMIN_PASSWORD, + }); + const token = authRes.data.token; + const api = axios.create({ + baseURL: BACKEND_URL, + headers: { Authorization: `Bearer ${token}` } + }); + + const pages = [ + { + slug: 'about', title: 'About Us', isPublished: true, + sections: [ + { + type: 'HERO', order: 1, + payload: { tagline: 'Our Story', title: 'Born from a passion for stillness', description: 'HomAroma began in 2019 as a one-person studio in Bangkok, crafting small batches of botanical aroma blends for friends and family. What started as a personal journey toward calm became a philosophy — that our environment shapes how we feel, think, and rest.', align: 'center', bgImage: '', overlay: true } + }, + { + type: 'TEXT', order: 2, + payload: { tagline: 'Stats', title: 'Company Stats', content: '45+ Unique Scents\n5 Product Lines\nFounded 2019\n100% Natural Extracts', align: 'center' } + }, + { + type: 'EDITORIAL_TILE', order: 3, + payload: { tagline: 'Our Mission', title: 'Transforming spaces into sanctuaries of peace', content: 'We believe that scent is the fastest pathway to emotional transformation. A single breath of the right blend can dissolve anxiety, sharpen focus, or unlock creativity. Our mission is to make that transformation accessible — through products that are as beautiful as they are effective.\n\nEvery HomAroma product is designed with intention: the bottles are reusable, the packaging is recycled, and the formulas are written to be understood by anyone — not hidden behind chemical jargon.', imageSrc: '', imageAlt: 'HomAroma Studio, Bangkok', reverse: false } + }, + { + type: 'TEXT', order: 4, + payload: { tagline: 'What We Stand For', title: 'Three Pillars', content: '1. Pure Origins: Every extract is sourced directly from certified organic farms in Northern Thailand, Vietnam, and Southern France. We work exclusively with small-batch artisan growers.\n\n2. Artisan Craft: Each formula is cold-extracted and hand-blended in our Bangkok studio. No heat processing means every aromatic molecule remains intact and therapeutically potent.\n\n3. Zero Compromise: No synthetic fragrance. No parabens. No animal testing. Our commitment to clean formulation is absolute — what touches your senses should honour your wellbeing.', align: 'center' } + }, + { + type: 'BANNER', order: 5, + payload: { title: 'Ready to find your scent?', description: 'Let our Scent Guide help you discover the perfect blend for your moment.', buttonText: 'Take the Scent Guide', buttonLink: '/scent-guide' } + } + ] + }, + { + slug: 'faq', title: 'Frequently Asked Questions', isPublished: true, + sections: [ + { + type: 'TEXT', order: 1, + payload: { tagline: 'Support', title: 'Frequently Asked Questions', content: 'Everything you need to know about HomAroma products, shipping, and care.', align: 'center' } + }, + { + type: 'ACCORDION', order: 2, + payload: { categories: [{ name: 'Products', icon: '🌿', questions: [{ q: 'Are your products 100% natural?', a: 'Yes. All our products are formulated using 100% natural botanical extracts, pure essential oils, and plant-derived carriers. We never use synthetic fragrances or phthalates.' }, { q: 'Are your products pet-friendly?', a: 'While natural, some essential oils can be sensitive to certain pets (like cats and eucalyptus). Please consult your vet, and always ensure your pet can leave the room when a diffuser is running.' }] }, { name: 'Shipping', icon: '📦', questions: [{ q: 'Do you ship internationally?', a: 'Currently, we ship within Thailand and selected countries in Southeast Asia. International shipping expansion is planned for late 2026.' }, { q: 'How long does shipping take?', a: 'Standard domestic shipping within Thailand takes 2-3 business days. Express shipping takes 1-2 business days.' }] }] } + }, + { + type: 'BANNER', order: 3, + payload: { title: 'Still have questions?', description: 'Our support team is available Mon-Sat, 9am - 6pm.', buttonText: 'Contact Us', buttonLink: '/contact' } + } + ] + }, + { + slug: 'contact', title: 'Contact Us', isPublished: true, + sections: [ + { + type: 'TEXT', order: 1, + payload: { tagline: 'Get in Touch', title: 'We are here to help', content: 'Whether you need help selecting a scent or have questions about an order, our team is ready to assist you.', align: 'center' } + }, + { + type: 'CONTACT_INFO', order: 2, + payload: { address: 'HomAroma Studio\n123 Sukhumvit Road\nBangkok 10110, Thailand', email: 'hello@homaroma.shop', line: '@homaroma', hours: 'Mon-Sat: 9:00 AM - 6:00 PM' } + } + ] + } + ]; + + for (const page of pages) { + console.log(`Creating page: ${page.slug}`); + try { + const pageRes = await api.post('/pages', { slug: page.slug, title: page.title, isPublished: page.isPublished }); + const pageId = pageRes.data.id; + console.log(`Created page ${page.slug} with ID ${pageId}`); + for (const section of page.sections) { + console.log(` Adding section ${section.type}`); + await api.post(`/pages/${pageId}/sections`, { type: section.type, order: section.order, payload: section.payload, isActive: true }); + } + } catch (err: any) { + console.error(`Error on ${page.slug}:`, err.response?.data || err.message); + } + } + console.log("Migration to Production complete!"); +} + +main(); diff --git a/apps/backend/src/routes/pages.ts b/apps/backend/src/routes/pages.ts index 394b0eb..fac312e 100644 --- a/apps/backend/src/routes/pages.ts +++ b/apps/backend/src/routes/pages.ts @@ -11,8 +11,8 @@ import { adminOnly } from "../middleware/auth"; const RESERVED_SLUGS = [ "shop", "category", "products", "cart", "checkout", "account", "search", - "contact", "login", "admin", "wishlist", "track", "coupons", "scent-guide", - "faq", "about", "profile", "article", "pages", "orders", "customers", + "login", "admin", "wishlist", "track", "coupons", "scent-guide", + "profile", "article", "pages", "orders", "customers", "settings", "menus", "auth", "api" ];