diff --git a/.agents/skills/orchestrator/SKILL.md b/.agents/skills/orchestrator/SKILL.md index c61b54f..58a85bf 100644 --- a/.agents/skills/orchestrator/SKILL.md +++ b/.agents/skills/orchestrator/SKILL.md @@ -62,6 +62,10 @@ description: Main Agent / Multi-Agent Orchestrator ทำหน้าที่ > **RULE #9: System Halt Trigger (กฎการหยุดฉุกเฉิน)** > หากคุณพยายามเรียกใช้ MCP Tool แล้วพบว่าผลลัพธ์ตีกลับมาเป็นว่างเปล่า (`[]`) หรือเกิด Error ที่ผิดปกติ (โดยเฉพาะหลังจากเพิ่งแก้ไขโค้ด MCP Server) **ห้ามคิดพยายามแก้ปัญหาด้วยการสร้างทางลัดหรือรันสคริปต์แก้ไขเด็ดขาด!** ให้คุณหยุดทำงานทันที และพิมพ์คำสั่ง **`[SYSTEM HALT: REQUIRE MCP RESTART]`** ลงในคำตอบ เพื่อแจ้งให้ User ทราบทันทีว่ากระบวนการ MCP Server ค้างอยู่และต้องการการรีสตาร์ทเพื่อโหลด Schema ใหม่ +> [!IMPORTANT] +> **RULE #10: ห้ามเขียนหรือแก้ไขโค้ดเองเด็ดขาด (Strict Code Delegation)** +> หากมีงานที่เกี่ยวข้องกับการเขียน แก้ไข หรือลบโค้ด ห้ามคุณเข้าไปยุ่งกับโค้ดด้วยตัวเองเด็ดขาด! คุณต้องมีหน้าที่เพียงวางแผนและเรียกใช้ (Invoke) Sub Agent ที่ตรงสายงาน (เช่น `frontend-lead` หรือ `backend-mcp-lead`) ให้ทำงานแทนเสมอ หน้าที่ของคุณคือการจ่ายงานและตรวจสอบความเรียบร้อยของผลลัพธ์เท่านั้น + --- ## 🔄 Task Delegation Workflow (ขั้นตอนการทำงาน) diff --git a/apps/admin/src/pages/MenuManagerPage.tsx b/apps/admin/src/pages/MenuManagerPage.tsx index 3182a84..3a08a69 100644 --- a/apps/admin/src/pages/MenuManagerPage.tsx +++ b/apps/admin/src/pages/MenuManagerPage.tsx @@ -81,7 +81,7 @@ export default function MenuManagerPage() {
- {['main', 'footer-explore'].map(name => ( + {['main', 'footer-explore', 'footer-support'].map(name => ( ))}
@@ -117,26 +117,59 @@ export default function MenuManagerPage() {
-
-
- - handleUpdateItem(idx, 'label', e.target.value)} - className="admin-input w-full" - placeholder="e.g. Shop All" - /> +
+
+
+ + handleUpdateItem(idx, 'label', e.target.value)} + className="admin-input w-full" + placeholder="e.g. Shop All" + /> +
+
+ + handleUpdateItem(idx, 'url', e.target.value)} + className="admin-input w-full" + placeholder="e.g. /shop" + /> +
-
- - handleUpdateItem(idx, 'url', e.target.value)} - className="admin-input w-full" - placeholder="e.g. /shop" - /> + + {/* Translations */} +
+ +
+ {['th', 'ja', 'zh', 'vi', 'ko'].map(lang => { + const transVal = item.translations?.find((t: any) => t.langCode === lang)?.label || '' + return ( +
+ {lang} + { + const newTranslations = [...(item.translations || [])] + const tIdx = newTranslations.findIndex((t: any) => t.langCode === lang) + if (tIdx >= 0) { + newTranslations[tIdx] = { ...newTranslations[tIdx], label: e.target.value } + } else { + newTranslations.push({ langCode: lang, label: e.target.value }) + } + handleUpdateItem(idx, 'translations', newTranslations as any) + }} + className="admin-input w-full text-xs py-1 px-2" + placeholder={`Label in ${lang}`} + /> +
+ ) + })} +
diff --git a/apps/admin/src/pages/SystemSettingsPage.tsx b/apps/admin/src/pages/SystemSettingsPage.tsx index 3faa346..9fec061 100644 --- a/apps/admin/src/pages/SystemSettingsPage.tsx +++ b/apps/admin/src/pages/SystemSettingsPage.tsx @@ -21,6 +21,9 @@ export default function SystemSettingsPage() { const [newsletterDescription, setNewsletterDescription] = useState('') const [newsletterPlaceholder, setNewsletterPlaceholder] = useState('') const [newsletterButtonText, setNewsletterButtonText] = useState('') + + const [footerSupportHeading, setFooterSupportHeading] = useState('') + const [footerCopyrightText, setFooterCopyrightText] = useState('') useEffect(() => { fetch(`${API_BASE}/settings`) @@ -39,6 +42,8 @@ export default function SystemSettingsPage() { setNewsletterDescription(data.newsletterDescription || '') setNewsletterPlaceholder(data.newsletterPlaceholder || '') setNewsletterButtonText(data.newsletterButtonText || '') + setFooterSupportHeading(data.footerSupportHeading || '') + setFooterCopyrightText(data.footerCopyrightText || '') }) .catch(console.error) .finally(() => setLoading(false)) @@ -65,7 +70,9 @@ export default function SystemSettingsPage() { newsletterTitle, newsletterDescription, newsletterPlaceholder, - newsletterButtonText + newsletterButtonText, + footerSupportHeading, + footerCopyrightText }) }) if (res.ok) alert('Settings saved successfully!') @@ -243,6 +250,29 @@ export default function SystemSettingsPage() { />
+ +
+
+ + setFooterSupportHeading(e.target.value)} + className="admin-input w-full" + placeholder="Support & Legal" + /> +
+
+ + setFooterCopyrightText(e.target.value)} + className="admin-input w-full" + placeholder="© 2026 HomAroma. All rights reserved." + /> +
+
diff --git a/apps/backend/check_cat.ts b/apps/backend/check_cat.ts new file mode 100644 index 0000000..cc7e5a2 --- /dev/null +++ b/apps/backend/check_cat.ts @@ -0,0 +1,9 @@ +import { PrismaClient } from '@prisma/client' +const prisma = new PrismaClient() +async function main() { + const cats = await prisma.category.findMany({ + include: { translations: true } + }) + console.log(JSON.stringify(cats, null, 2)) +} +main() diff --git a/apps/backend/prisma/schema.prisma b/apps/backend/prisma/schema.prisma index 4b4f399..8897e78 100644 --- a/apps/backend/prisma/schema.prisma +++ b/apps/backend/prisma/schema.prisma @@ -220,6 +220,8 @@ model StoreSettings { newsletterDescription String? newsletterPlaceholder String? newsletterButtonText String? + footerSupportHeading Json? + footerCopyrightText Json? translations StoreSettingsTranslation[] updatedAt DateTime @updatedAt } diff --git a/apps/backend/prisma/seed.cjs b/apps/backend/prisma/seed.cjs index 03a2b9c..0150e8d 100644 --- a/apps/backend/prisma/seed.cjs +++ b/apps/backend/prisma/seed.cjs @@ -98,6 +98,29 @@ async function main() { }); process.stdout.write('✅ Seeded Admin User (admin / homaroma123).\n'); + // 0.5 Seed Core Menus + const coreMenus = [ + { name: "main", items: [{ id: 1, label: "Home", url: "/", order: 1 }, { id: 2, label: "Shop", url: "/shop", order: 2 }, { id: 3, label: "Scent Guide", url: "/scent-guide", order: 3 }, { id: 4, label: "About Us", url: "/about", order: 4 }] }, + { name: "footer-explore", items: [{ id: 5, label: "Home", url: "/", order: 1 }, { id: 6, label: "Shop", url: "/shop", order: 2 }, { id: 7, label: "Scent Guide", url: "/scent-guide", order: 3 }, { id: 8, label: "About Us", url: "/about", order: 4 }] }, + { name: "footer-support", items: [{ id: 9, label: "Track Order", url: "/track-order", order: 1 }, { id: 10, label: "FAQ", url: "/faq", order: 2 }, { id: 11, label: "Contact Us", url: "/contact", order: 3 }, { id: 12, label: "Delivery & Returns", url: "/delivery", order: 4 }] } + ]; + + for (const menu of coreMenus) { + const m = await prisma.menu.upsert({ + where: { name: menu.name }, + update: {}, + create: { name: menu.name } + }); + for (const item of menu.items) { + await prisma.menuItem.upsert({ + where: { id: item.id }, + update: { label: item.label, url: item.url, order: item.order, menuId: m.id }, + create: { id: item.id, label: item.label, url: item.url, order: item.order, menuId: m.id } + }); + } + } + process.stdout.write('✅ Seeded Core Menus.\n'); + // 1. Seed Scents & Categories const scents = []; for (const name of scentNames) { @@ -215,6 +238,11 @@ async function main() { process.stdout.write(` - Categories: ${categories.length}\n`); process.stdout.write(` - Products: ${productCount}\n`); process.stdout.write(` - Variants: ${variantCount}\n`); + // Fix PostgreSQL sequence desync for tables where we hardcoded IDs + process.stdout.write('🔄 Resetting sequences for hardcoded ID tables...\n'); + await prisma.$executeRawUnsafe(`SELECT setval('"MenuItem_id_seq"', COALESCE((SELECT MAX(id) FROM "MenuItem") + 1, 1), false);`); + await prisma.$executeRawUnsafe(`SELECT setval('"ProductImage_id_seq"', COALESCE((SELECT MAX(id) FROM "ProductImage") + 1, 1), false);`); + process.stdout.write('✅ Sequences reset successfully.\n'); } main() diff --git a/apps/backend/scripts/migrate-pages.ts b/apps/backend/scripts/migrate-pages.ts new file mode 100644 index 0000000..6f20396 --- /dev/null +++ b/apps/backend/scripts/migrate-pages.ts @@ -0,0 +1,215 @@ +import prisma from '../src/lib/prisma'; + +async function main() { + // 1. Create About Page + await prisma.page.upsert({ + where: { slug: 'about' }, + update: {}, + create: { + slug: 'about', + title: 'About Us', + isPublished: true, + sections: { + create: [ + { + 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' + } + } + ] + } + } + }); + + // 2. Create FAQ Page + await prisma.page.upsert({ + where: { slug: 'faq' }, + update: {}, + create: { + slug: 'faq', + title: 'Frequently Asked Questions', + isPublished: true, + sections: { + create: [ + { + 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: '🌿', + items: [ + { q: 'What are the ingredients in your aroma products?', a: 'All HomAroma products are crafted from 100% natural botanical extracts, pure essential oils, and pharmaceutical-grade carrier bases. We never use synthetic fragrances, parabens, or harmful chemicals. Each product label lists full ingredient transparency.' }, + { q: 'How long does each product last?', a: 'Our Reed Diffusers last 4–8 weeks depending on room size and airflow. Aroma Oils (30ml) last approximately 3–4 months with normal use. Room Sprays (100ml) provide 60–80 uses. Car Diffusers cartridges last up to 45 days.' }, + { q: 'Are your products suitable for sensitive skin or allergies?', a: 'We recommend patch testing before topical use. Our Aroma Oils are formulated for diffuser use primarily. If you have known fragrance allergies, consult our scent guide or contact us with your specific concerns — we are happy to help identify suitable options.' }, + { q: 'What is the difference between Aroma Oil and Oil Ozone?', a: 'Aroma Oils are pure essential oil blends designed for aromatherapy diffusers and therapeutic use. Oil Ozone is our premium line featuring ozone-infused botanical extracts — designed for air purification and deeper space transformation, ideal for large rooms and commercial spaces.' }, + ] + }, + { + name: 'Usage', + icon: '💡', + items: [ + { q: 'How do I use a Reed Diffuser?', a: 'Remove the stopper, place the reeds into the bottle, and let them absorb the oil for 1 hour before flipping. For optimal fragrance, flip the reeds every 2–3 days. Keep away from direct sunlight and air conditioning vents for longest lasting performance.' }, + { q: 'Can I mix different scents?', a: 'Yes! Blending scents is an art form we encourage. A general rule: combine no more than 3 scents at a time, using one dominant (60%), one supporting (30%), and one accent (10%). Our Scent Guide can help you find complementary combinations.' }, + { q: 'How long should I run my aroma diffuser?', a: 'For best results and to avoid olfactory fatigue, we recommend 30–60 minute sessions with 30-minute breaks in between. This also extends product life and prevents overwhelming fragrance build-up in small spaces.' }, + ] + }, + { + name: 'Shipping & Orders', + icon: '📦', + items: [ + { q: 'How long does shipping take?', a: 'Standard delivery within Bangkok takes 1–2 business days. Provincial orders take 2–4 business days. Express same-day delivery is available in Bangkok for orders placed before 12:00 PM.' }, + { q: 'Do you ship internationally?', a: 'Currently we ship within Thailand only. International shipping is planned for late 2025. Sign up for our newsletter to be notified when we expand to your region.' }, + { q: 'What is your return policy?', a: 'We accept returns within 14 days of purchase for unopened, undamaged products in original packaging. For defective or damaged products, we offer full replacement at no cost. Contact us at hello@homaroma.shop with your order number.' }, + ] + }, + { + name: 'Scent Guide', + icon: '🧪', + items: [ + { q: 'How do I choose the right scent for my space?', a: 'Consider the function of the space first. Bedrooms benefit from calming scents like lavender and chamomile. Living rooms work well with warm, welcoming notes like sandalwood and vanilla. Home offices pair best with focus-enhancing eucalyptus and citrus. Use our interactive Scent Guide for personalized recommendations.' }, + { q: 'Can I request custom scent blending?', a: 'Yes! Our bespoke blending service is available for orders of 6 units or more. Contact us at least 10 business days before your desired delivery date. Custom blending fees start at ฿500 per unique formula.' }, + ] + } + ] + } + }, + { + type: 'BANNER', + order: 3, + payload: { + title: 'Still have questions?', + description: 'Our team is here to help — usually responds within 2 hours.', + buttonText: 'Contact Us', + buttonLink: '/contact' + } + } + ] + } + } + }); + + // 3. Create Contact Page + await prisma.page.upsert({ + where: { slug: 'contact' }, + update: {}, + create: { + slug: 'contact', + title: 'Contact Us', + isPublished: true, + sections: { + create: [ + { + type: 'TEXT', + order: 1, + payload: { + tagline: 'Get in Touch', + title: 'Contact Us', + content: 'Have a question, custom request, or partnership idea? We\'d love to hear from you.', + align: 'center' + } + }, + { + type: 'CONTACT_INFO', + order: 2, + payload: { + title: 'Reach Us Directly', + items: [ + { icon: '📧', label: 'Email', value: 'hello@homaroma.shop', href: 'mailto:hello@homaroma.shop' }, + { icon: '📱', label: 'LINE Official', value: '@homaroma', href: '#' }, + { icon: '📸', label: 'Instagram', value: '@homaroma', href: '#' }, + { icon: '📍', label: 'Studio', value: 'Bangkok, Thailand', href: '#' }, + ], + responseTime: { + title: 'Response Time', + email: '~2 hours', + line: '~30 minutes', + instagram: '~4 hours', + hours: 'Mon–Sat, 9:00–18:00 (ICT)' + } + } + }, + { + type: 'CONTACT_FORM', + order: 3, + payload: { + subjects: ['Product Inquiry', 'Order Support', 'Custom Blending', 'Wholesale', 'Partnership', 'Other'], + buttonText: 'Send Message' + } + } + ] + } + } + }); + + console.log('Pages created successfully.'); +} + +main() + .catch((e) => { + console.error(e); + process.exit(1); + }) + .finally(async () => { + await prisma.$disconnect(); + }); diff --git a/apps/backend/src/routes/menus.ts b/apps/backend/src/routes/menus.ts index f46e864..406939c 100644 --- a/apps/backend/src/routes/menus.ts +++ b/apps/backend/src/routes/menus.ts @@ -7,7 +7,8 @@ export const menusRoute = new Elysia({ prefix: "/menus" }) return await prisma.menu.findMany({ include: { items: { - orderBy: { order: "asc" } + orderBy: { order: "asc" }, + include: { translations: true } } } }); @@ -17,19 +18,12 @@ export const menusRoute = new Elysia({ prefix: "/menus" }) where: { name }, include: { items: { - orderBy: { order: "asc" } + orderBy: { order: "asc" }, + include: { translations: true } } } }); if (!menu) { - // Return fallback defaults instead of 404 to prevent frontend breakage - if (name === "main") { - return { name, items: [{ id: 1, label: "Home", url: "/", order: 1 }, { id: 2, label: "Shop", url: "/shop", order: 2 }, { id: 3, label: "Scent Guide", url: "/scent-guide", order: 3 }, { id: 4, label: "About Us", url: "/about", order: 4 }] }; - } else if (name === "footer-explore") { - return { name, items: [{ id: 5, label: "Home", url: "/", order: 1 }, { id: 6, label: "Shop", url: "/shop", order: 2 }, { id: 7, label: "Scent Guide", url: "/scent-guide", order: 3 }, { id: 8, label: "About Us", url: "/about", order: 4 }] }; - } else if (name === "footer-support") { - return { name, items: [{ id: 9, label: "Track Order", url: "/track-order", order: 1 }, { id: 10, label: "FAQ", url: "/faq", order: 2 }, { id: 11, label: "Contact Us", url: "/contact", order: 3 }, { id: 12, label: "Delivery & Returns", url: "/delivery", order: 4 }] }; - } return { name, items: [] }; } return menu; @@ -65,28 +59,60 @@ export const menusRoute = new Elysia({ prefix: "/menus" }) }) .put("/:name", async ({ params: { name }, body, set }) => { try { - const { items } = body as { items: { id?: number; label: string; url: string; order: number }[] }; + const { items } = body as { items: { id?: number; label: string; url: string; order: number; translations?: { langCode: string; label: string }[] }[] }; let menu = await prisma.menu.findUnique({ where: { name } }); if (!menu) { menu = await prisma.menu.create({ data: { name } }); } - await prisma.$transaction([ - prisma.menuItem.deleteMany({ where: { menuId: menu.id } }), - prisma.menuItem.createMany({ - data: items.map(item => ({ - menuId: menu.id, - label: item.label, - url: item.url, - order: item.order - })) - }) - ]); + await prisma.$transaction(async (tx: any) => { + const existingItems = await tx.menuItem.findMany({ where: { menuId: menu!.id } }); + const existingItemIds = existingItems.map((i: any) => i.id); + const payloadItemIds = items.map(i => i.id).filter(id => id != null); + const itemsToDelete = existingItemIds.filter((id: number) => !payloadItemIds.includes(id)); + + if (itemsToDelete.length > 0) { + await tx.menuItem.deleteMany({ where: { id: { in: itemsToDelete } } }); + } + + for (const item of items) { + if (item.id && existingItemIds.includes(item.id)) { + await tx.menuItem.update({ + where: { id: item.id }, + data: { label: item.label, url: item.url, order: item.order } + }); + if (item.translations?.length) { + for (const t of item.translations) { + await tx.menuItemTranslation.upsert({ + where: { menuItemId_langCode: { menuItemId: item.id, langCode: t.langCode } }, + update: { label: t.label }, + create: { menuItemId: item.id, langCode: t.langCode, label: t.label } + }); + } + } + } else { + await tx.menuItem.create({ + data: { + menuId: menu!.id, + label: item.label, + url: item.url, + order: item.order, + translations: item.translations?.length ? { + create: item.translations.map(t => ({ + langCode: t.langCode, + label: t.label + })) + } : undefined + } + }); + } + } + }); return await prisma.menu.findUnique({ where: { name }, - include: { items: { orderBy: { order: "asc" } } } + include: { items: { orderBy: { order: "asc" }, include: { translations: true } } } }); } catch (err) { console.error(err); @@ -99,7 +125,11 @@ export const menusRoute = new Elysia({ prefix: "/menus" }) id: t.Optional(t.Number()), label: t.String(), url: t.String(), - order: t.Number() + order: t.Number(), + translations: t.Optional(t.Array(t.Object({ + langCode: t.String(), + label: t.String() + }))) })) }) }) @@ -110,6 +140,12 @@ export const menusRoute = new Elysia({ prefix: "/menus" }) return { error: "Invalid menu item ID" }; } + const menuItem = await prisma.menuItem.findUnique({ where: { id } }); + if (!menuItem) { + set.status = 404; + return { error: "Menu item not found. Please ensure database is seeded or the item exists." }; + } + const payload = body as any; const results: any[] = []; const LANGS = ['th', 'en', 'ja', 'zh', 'vi', 'ko']; diff --git a/apps/backend/src/routes/settings.ts b/apps/backend/src/routes/settings.ts index 310f865..bf7df6f 100644 --- a/apps/backend/src/routes/settings.ts +++ b/apps/backend/src/routes/settings.ts @@ -51,7 +51,9 @@ export const settingsRoute = new Elysia({ prefix: "/settings" }) newsletterTitle: t.Optional(t.String()), newsletterDescription: t.Optional(t.String()), newsletterPlaceholder: t.Optional(t.String()), - newsletterButtonText: t.Optional(t.String()) + newsletterButtonText: t.Optional(t.String()), + footerSupportHeading: t.Optional(t.Any()), + footerCopyrightText: t.Optional(t.Any()) }) }) .patch("/translations", async ({ body, set }) => { diff --git a/apps/mcp-server/index.ts b/apps/mcp-server/index.ts index 9233d13..b388454 100644 --- a/apps/mcp-server/index.ts +++ b/apps/mcp-server/index.ts @@ -69,6 +69,53 @@ server.setRequestHandler(ListToolsRequestSchema, async () => { required: ["env"] } }, + { + name: "get_menu", + description: "Fetch a specific menu and its items (including translations)", + inputSchema: { + type: "object", + properties: { + name: { type: "string", description: "Name of the menu (e.g. main, footer-explore)" } + }, + required: ["name"] + } + }, + { + name: "upsert_menu", + description: "Update or create a complete menu by replacing its items. Uses proper diff & sync for translations.", + inputSchema: { + type: "object", + properties: { + name: { type: "string", description: "Name of the menu (e.g. main, footer-explore)" }, + items: { + type: "array", + description: "Array of menu items", + items: { + type: "object", + properties: { + id: { type: "number", description: "ID of existing item (optional)" }, + label: { type: "string", description: "Label of the menu item" }, + url: { type: "string", description: "URL of the menu item" }, + order: { type: "number", description: "Order sequence" }, + translations: { + type: "array", + description: "Optional array of translations", + items: { + type: "object", + properties: { + langCode: { type: "string" }, + label: { type: "string" } + } + } + } + }, + required: ["label", "url", "order"] + } + } + }, + required: ["name", "items"] + } + }, { name: "ping_backend", description: "Ping the backend to verify connection and authentication", @@ -466,6 +513,14 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => { const res = await api.get("/products?limit=1"); return { content: [{ type: "text", text: `Connection successful!` }] }; } + case "get_menu": { + const res = await api.get(`/menus/${params.name}`); + return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] }; + } + case "upsert_menu": { + const res = await api.put(`/menus/${params.name}`, { items: params.items }); + return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] }; + } case "search_products": { const search = params.search ? `&search=${encodeURIComponent(params.search)}` : ""; const limit = params.limit ? `&limit=${params.limit}` : "&limit=10"; diff --git a/apps/spa/src/App.tsx b/apps/spa/src/App.tsx index 654f3d8..f396b97 100644 --- a/apps/spa/src/App.tsx +++ b/apps/spa/src/App.tsx @@ -8,11 +8,8 @@ import ShopPage from './pages/ShopPage' import CategoryPage from './pages/CategoryPage' import ProductDetailPage from './pages/ProductDetailPage' import SearchPage from './pages/SearchPage' -import FaqPage from './pages/FaqPage' import ScentGuidePage from './pages/ScentGuidePage' import ArticleReaderPage from './pages/ArticleReaderPage' -import ContactPage from './pages/ContactPage' -import AboutPage from './pages/AboutPage' import NotFoundPage from './pages/NotFoundPage' import CheckoutPage from './pages/CheckoutPage' import CouponsPage from './pages/CouponsPage' @@ -64,11 +61,11 @@ function App() { } /> } /> } /> - } /> + } /> } /> } /> - } /> - } /> + } /> + } /> } /> } /> } /> diff --git a/apps/spa/src/components/Footer.tsx b/apps/spa/src/components/Footer.tsx index 9c266e1..e49e041 100644 --- a/apps/spa/src/components/Footer.tsx +++ b/apps/spa/src/components/Footer.tsx @@ -12,7 +12,15 @@ export default function Footer({ categories = [] }: FooterProps) { const [supportMenu, setSupportMenu] = useState([]) const [settings, setSettings] = useState(null) - const translateMenuLabel = (label: string) => { + const translateMenuLabel = (item: MenuItem) => { + const lang = localStorage.getItem('homaroma_lang') || 'en' + if (lang !== 'en' && item.translations && item.translations.length > 0) { + const trans = item.translations.find((t: any) => t.langCode === lang) + if (trans && trans.label) { + return trans.label + } + } + const map: Record = { 'Home': 'nav.home', 'Shop': 'nav.shop', @@ -25,7 +33,7 @@ export default function Footer({ categories = [] }: FooterProps) { 'Track Order': 'nav.trackOrder', 'Delivery & Returns': 'nav.delivery' } - return map[label] ? t(map[label]) : label + return map[item.label] ? t(map[item.label]) : item.label } useEffect(() => { @@ -89,7 +97,7 @@ export default function Footer({ categories = [] }: FooterProps) {
{exploreMenu.length > 0 ? ( exploreMenu.map(item => ( - {translateMenuLabel(item.label)} + {translateMenuLabel(item)} )) ) : ( <> @@ -116,16 +124,18 @@ export default function Footer({ categories = [] }: FooterProps) {
-

{t('footer.support', 'Support & Legal')}

+

+ {settings?.footerSupportHeading || t('footer.support', 'Support & Legal')} +

{supportMenu.map(item => ( - {translateMenuLabel(item.label)} + {translateMenuLabel(item)} ))}

- © {new Date().getFullYear()} HomAroma. {t('footer.rights')} + {settings?.footerCopyrightText || `© ${new Date().getFullYear()} HomAroma. ${t('footer.rights')}`}

diff --git a/apps/spa/src/components/Navbar.tsx b/apps/spa/src/components/Navbar.tsx index a2b838e..3a0f45b 100644 --- a/apps/spa/src/components/Navbar.tsx +++ b/apps/spa/src/components/Navbar.tsx @@ -45,7 +45,15 @@ export default function Navbar({ categories = [], topOffsetClassName = 'top-0' } setLangSheetOpen(false) } - const translateMenuLabel = (label: string) => { + const translateMenuLabel = (item: MenuItem) => { + const lang = localStorage.getItem('homaroma_lang') || 'en' + if (lang !== 'en' && item.translations && item.translations.length > 0) { + const trans = item.translations.find((t: any) => t.langCode === lang) + if (trans && trans.label) { + return trans.label + } + } + const map: Record = { 'Home': 'nav.home', 'Shop': 'nav.shop', @@ -57,7 +65,7 @@ export default function Navbar({ categories = [], topOffsetClassName = 'top-0' } 'Track Order': 'nav.trackOrder', 'Delivery & Returns': 'nav.delivery' } - return map[label] ? t(map[label]) : label + return map[item.label] ? t(map[item.label]) : item.label } // Detect scroll and announcement bar presence useEffect(() => { @@ -145,7 +153,7 @@ export default function Navbar({ categories = [], topOffsetClassName = 'top-0' } {menuItems.length > 0 ? ( menuItems.map(item => ( - {translateMenuLabel(item.label)} + {translateMenuLabel(item)} )) ) : ( @@ -433,7 +441,7 @@ export default function Navbar({ categories = [], topOffsetClassName = 'top-0' } {/* Drawer Nav Links */}
{(menuItems.length > 0 ? [ - ...menuItems.map(item => ({ to: item.url, label: translateMenuLabel(item.label), end: item.url === '/' })), + ...menuItems.map(item => ({ to: item.url, label: translateMenuLabel(item), end: item.url === '/' })), ...(customer ? [{ to: '/profile', label: `👤 ${t('nav.profile') || 'My Profile'}` }] : []), ] : [ { to: '/', label: t('nav.home'), end: true }, diff --git a/apps/spa/src/locales/en/translation.json b/apps/spa/src/locales/en/translation.json index 85c1a1c..ee9102c 100644 --- a/apps/spa/src/locales/en/translation.json +++ b/apps/spa/src/locales/en/translation.json @@ -20,7 +20,9 @@ "placeholder": "Search scents, categories...", "quickLinks": "Quick Links", "allProducts": "All Products" - } + }, + "trackOrder": "Track Order", + "delivery": "Delivery & Returns" }, "cart": { "title": "Your Sanctuary", diff --git a/apps/spa/src/locales/ja/translation.json b/apps/spa/src/locales/ja/translation.json index 5902926..cd7752e 100644 --- a/apps/spa/src/locales/ja/translation.json +++ b/apps/spa/src/locales/ja/translation.json @@ -17,7 +17,9 @@ "placeholder": "香りを検索...", "quickLinks": "クイックリンク", "allProducts": "すべての商品" - } + }, + "trackOrder": "注文追跡", + "delivery": "配送と返品" }, "cart": { "title": "カート", @@ -56,4 +58,4 @@ "reviews": "レビュー", "viewDetails": "詳細を見る →" } -} \ No newline at end of file +} diff --git a/apps/spa/src/locales/ko/translation.json b/apps/spa/src/locales/ko/translation.json index 562cfe1..8673611 100644 --- a/apps/spa/src/locales/ko/translation.json +++ b/apps/spa/src/locales/ko/translation.json @@ -17,7 +17,9 @@ "placeholder": "향기 검색...", "quickLinks": "빠른 링크", "allProducts": "모든 제품" - } + }, + "trackOrder": "주문 배송조회", + "delivery": "배송 및 반품" }, "cart": { "title": "장바구니", @@ -56,4 +58,4 @@ "reviews": "리뷰", "viewDetails": "상세 보기 →" } -} \ No newline at end of file +} diff --git a/apps/spa/src/locales/th/translation.json b/apps/spa/src/locales/th/translation.json index 16e68fa..ebc74c1 100644 --- a/apps/spa/src/locales/th/translation.json +++ b/apps/spa/src/locales/th/translation.json @@ -20,7 +20,9 @@ "placeholder": "ค้นหากลิ่น, คอลเลกชัน...", "quickLinks": "ลิงก์ด่วน", "allProducts": "สินค้าทั้งหมด" - } + }, + "trackOrder": "ติดตามสถานะสินค้า", + "delivery": "การจัดส่งและการคืนสินค้า" }, "cart": { "title": "ตะกร้าสินค้า", diff --git a/apps/spa/src/locales/vi/translation.json b/apps/spa/src/locales/vi/translation.json index 488dbc5..12a757e 100644 --- a/apps/spa/src/locales/vi/translation.json +++ b/apps/spa/src/locales/vi/translation.json @@ -17,7 +17,9 @@ "placeholder": "Tìm mùi hương...", "quickLinks": "Liên kết nhanh", "allProducts": "Tất cả sản phẩm" - } + }, + "trackOrder": "Theo dõi đơn hàng", + "delivery": "Giao hàng & Hoàn trả" }, "cart": { "title": "Giỏ hàng", @@ -56,4 +58,4 @@ "reviews": "Đánh giá", "viewDetails": "Xem chi tiết →" } -} \ No newline at end of file +} diff --git a/apps/spa/src/locales/zh/translation.json b/apps/spa/src/locales/zh/translation.json index e1eae6d..d19e23e 100644 --- a/apps/spa/src/locales/zh/translation.json +++ b/apps/spa/src/locales/zh/translation.json @@ -17,7 +17,9 @@ "placeholder": "搜索香气...", "quickLinks": "快速链接", "allProducts": "所有商品" - } + }, + "trackOrder": "追踪订单", + "delivery": "配送与退货" }, "cart": { "title": "购物车", @@ -56,4 +58,4 @@ "reviews": "评价", "viewDetails": "查看详情 →" } -} \ No newline at end of file +} diff --git a/apps/spa/src/pages/AboutPage.tsx b/apps/spa/src/pages/AboutPage.tsx deleted file mode 100644 index dac0d69..0000000 --- a/apps/spa/src/pages/AboutPage.tsx +++ /dev/null @@ -1,144 +0,0 @@ -import { useEffect, useState } from 'react' -import { Link } from 'react-router-dom' -import Navbar from '../components/Navbar' -import Footer from '../components/Footer' -import { API_BASE, type Category } from '../types' - -const PILLARS = [ - { - icon: '🌱', - title: 'Pure Origins', - desc: 'Every extract is sourced directly from certified organic farms in Northern Thailand, Vietnam, and Southern France. We work exclusively with small-batch artisan growers.', - }, - { - icon: '⚗️', - title: 'Artisan Craft', - desc: 'Each formula is cold-extracted and hand-blended in our Bangkok studio. No heat processing means every aromatic molecule remains intact and therapeutically potent.', - }, - { - icon: '♾️', - title: 'Zero Compromise', - desc: 'No synthetic fragrance. No parabens. No animal testing. Our commitment to clean formulation is absolute — what touches your senses should honour your wellbeing.', - }, -] - -const STATS = [ - { value: '45+', label: 'Unique Scents' }, - { value: '5', label: 'Product Lines' }, - { value: '2019', label: 'Founded' }, - { value: '100%', label: 'Natural Extracts' }, -] - -export default function AboutPage() { - const [categories, setCategories] = useState([]) - - useEffect(() => { - fetch(`${API_BASE}/categories`).then(r => r.json()).then(setCategories).catch(console.error) - }, []) - - return ( -
- - - {/* Hero */} -
-
-
-
-

Our Story

-

- Born from a passion for stillness -

-

- 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. -

-
-
- - {/* Stats Band */} -
-
- {STATS.map(s => ( -
-
{s.value}
-
{s.label}
-
- ))} -
-
- - {/* Mission Section */} -
-
-
-

Our Mission

-

- Transforming spaces into sanctuaries of peace -

-

- 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. -

-

- Every HomAroma product is designed with intention: the bg-white shadow-sm border border-spa-stone/10 bottles are reusable, the packaging is recycled, and the formulas are written to be understood by anyone — not hidden behind chemical jargon. -

-
-
-
-
-
-
🌿
-

HomAroma Studio, Bangkok

-
-
-
-
-
- - {/* Three Pillars */} -
-
-
-

What We Stand For

-

Three Pillars

-
-
-
- {PILLARS.map(p => ( -
-
{p.icon}
-

{p.title}

-

{p.desc}

-
- ))} -
-
-
- - {/* CTA */} -
-

Ready to find your scent?

-

- Let our Scent Guide help you discover the perfect blend for your moment. -

-
- - Take the Scent Guide - - - Shop All Products - -
-
- -
-
- ) -} diff --git a/apps/spa/src/pages/ArticleReaderPage.tsx b/apps/spa/src/pages/ArticleReaderPage.tsx index f03a751..33a0f8e 100644 --- a/apps/spa/src/pages/ArticleReaderPage.tsx +++ b/apps/spa/src/pages/ArticleReaderPage.tsx @@ -1,5 +1,6 @@ import { useState, useEffect } from 'react' import { useParams, Link } from 'react-router-dom' +import { useTranslation } from 'react-i18next' import { API_BASE, type Article, type Category } from '../types' import Navbar from '../components/Navbar' import Footer from '../components/Footer' @@ -7,12 +8,13 @@ import { ArrowLeft, Loader2 } from 'lucide-react' export default function ArticleReaderPage() { const { slug } = useParams() + const { i18n } = useTranslation() const [article, setArticle] = useState
(null) const [categories, setCategories] = useState([]) const [loading, setLoading] = useState(true) useEffect(() => { - fetch(`${API_BASE}/categories`).then(r => r.json()).then(setCategories).catch(console.error) + fetch(`${API_BASE}/categories?lang=${i18n.language}`).then(r => r.json()).then(setCategories).catch(console.error) fetch(`${API_BASE}/articles/${slug}`) .then(res => { if (!res.ok) throw new Error() @@ -21,7 +23,7 @@ export default function ArticleReaderPage() { .then(setArticle) .catch(() => setArticle(null)) .finally(() => setLoading(false)) - }, [slug]) + }, [slug, i18n.language]) if (loading) return (
diff --git a/apps/spa/src/pages/CheckoutPage.tsx b/apps/spa/src/pages/CheckoutPage.tsx index 85601fa..b610f1a 100644 --- a/apps/spa/src/pages/CheckoutPage.tsx +++ b/apps/spa/src/pages/CheckoutPage.tsx @@ -9,7 +9,7 @@ import { Loader2 } from 'lucide-react' import { useTranslation } from 'react-i18next' export default function CheckoutPage() { - const { t } = useTranslation() + const { t, i18n } = useTranslation() const navigate = useNavigate() const { items, getCartTotal, clearCart } = useCartStore() const { customer } = useAuthStore() @@ -108,7 +108,7 @@ export default function CheckoutPage() { .catch(err => console.error("Could not load settings:", err)) .finally(() => setLoadingSettings(false)) - fetch(`${API_BASE}/categories`) + fetch(`${API_BASE}/categories?lang=${i18n.language}`) .then(res => res.json()) .then(setCategories) @@ -127,7 +127,7 @@ export default function CheckoutPage() { // So we'll handle this in another effect or let the user click apply if needed. // Better yet, we can validate it immediately if subtotal is available. } - }, []) + }, [i18n.language]) // Kick out if cart empty useEffect(() => { diff --git a/apps/spa/src/pages/ContactPage.tsx b/apps/spa/src/pages/ContactPage.tsx deleted file mode 100644 index bdbfa98..0000000 --- a/apps/spa/src/pages/ContactPage.tsx +++ /dev/null @@ -1,231 +0,0 @@ -import { useState, useEffect } from 'react' -import Navbar from '../components/Navbar' -import Footer from '../components/Footer' -import DynamicPageRenderer from '../components/DynamicPageRenderer' -import { API_BASE, type Category, type PageSection } from '../types' - -type FormState = { name: string; email: string; subject: string; message: string } -type Status = 'idle' | 'sending' | 'sent' | 'error' - -const SUBJECTS = ['Product Inquiry', 'Order Support', 'Custom Blending', 'Wholesale', 'Partnership', 'Other'] - -export default function ContactPage() { - const [categories, setCategories] = useState([]) - const [form, setForm] = useState({ name: '', email: '', subject: '', message: '' }) - const [status, setStatus] = useState('idle') - const [cmsSections, setCmsSections] = useState([]) - - useEffect(() => { - fetch(`${API_BASE}/categories`).then(r => r.json()).then(setCategories).catch(console.error) - }, []) - - useEffect(() => { - fetch(`${API_BASE}/pages/contact-layout`) - .then((r) => { - if (!r.ok) throw new Error('Page not found'); - return r.json(); - }) - .then((data) => { - if (data && data.sections) { - setCmsSections(data.sections); - } - }) - .catch((err) => { - console.log('Contact dynamic layout sections not loaded:', err.message); - }); - }, []) - - const handleChange = (e: React.ChangeEvent) => { - setForm(prev => ({ ...prev, [e.target.name]: e.target.value })) - } - - const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault() - setStatus('sending') - // Simulate API call (replace with real endpoint later) - await new Promise(r => setTimeout(r, 1500)) - setStatus('sent') - setForm({ name: '', email: '', subject: '', message: '' }) - } - - const announcementSections = cmsSections.filter(s => s.isActive && s.type.toUpperCase() === 'ANNOUNCEMENT_BAR'); - const heroSections = cmsSections.filter(s => s.isActive && (s.type.toUpperCase() === 'HERO' || s.type.toUpperCase() === 'BANNER')); - const bottomSections = cmsSections.filter(s => s.isActive && s.type.toUpperCase() !== 'ANNOUNCEMENT_BAR' && s.type.toUpperCase() !== 'HERO' && s.type.toUpperCase() !== 'BANNER'); - - return ( -
- {announcementSections.length > 0 && ( - - )} - - - - {/* Header */} - {heroSections.length > 0 ? ( -
- -
- ) : ( -
-

Get in Touch

-

Contact Us

-

- Have a question, custom request, or partnership idea? We'd love to hear from you. -

-
- )} - -
- {/* Contact Info */} -
-
-

Reach Us Directly

-
- {[ - { icon: '📧', label: 'Email', value: 'hello@homaroma.shop', href: 'mailto:hello@homaroma.shop' }, - { icon: '📱', label: 'LINE Official', value: '@homaroma', href: '#' }, - { icon: '📸', label: 'Instagram', value: '@homaroma', href: '#' }, - { icon: '📍', label: 'Studio', value: 'Bangkok, Thailand', href: '#' }, - ].map(item => ( - -
- {item.icon} -
-
-

{item.label}

-

{item.value}

-
-
- ))} -
-
- -
-

Response Time

-
-
- Email - ~2 hours -
-
- LINE - ~30 minutes -
-
- Instagram DM - ~4 hours -
-
-

Mon–Sat, 9:00–18:00 (ICT)

-
-
- - {/* Contact Form */} -
- {status === 'sent' ? ( -
-
-
✉️
-

Message Sent!

-

Thank you for reaching out. We'll get back to you within 2 hours.

- -
-
- ) : ( -
-
-
- - -
-
- - -
-
-
- - -
-
- -