Commit Graph

168 Commits

Author SHA1 Message Date
Unchained
2e6668ff0d fix(webhook): prevent duplicate revenue tracking
Move analytics tracking inside ORDER_CONFIRMED conditional block
so revenue is only tracked once when order is confirmed, not twice
(once for ORDER_CREATED and once for ORDER_CONFIRMED).
2026-03-25 20:35:39 +02:00
Unchained
eb9a798d40 Merge branch 'feature/saleor-emails' into dev 2026-03-25 20:26:47 +02:00
Unchained
ab7dfbe48b refactor(webhook): modularize email and analytics code
Create service-oriented architecture for better maintainability:

- AnalyticsService: Centralized analytics tracking with OpenPanel
  - trackOrderReceived(), trackRevenue(), track()
  - Error handling that doesn't break main flow
  - Singleton pattern for single instance

- OrderNotificationService: Encapsulates all order email logic
  - sendOrderConfirmation() - customer + admin
  - sendOrderShipped() - with tracking info
  - sendOrderCancelled() - with reason
  - sendOrderPaid() - payment confirmation
  - Translation logic moved from webhook to service
  - Email formatting utilities encapsulated

- Webhook route refactored:
  - Reduced from 605 lines to ~250 lines
  - No business logic - only HTTP handling
  - Delegates to services for emails and analytics
  - Cleaner separation of concerns

- New utils file: formatPrice() shared between services

This prevents future bugs by:
1. Centralizing email logic in one place
2. Making code testable (services can be unit tested)
3. Easier to add new webhook handlers
4. Translation logic not mixed with HTTP code
5. Analytics failures don't break order processing
2026-03-25 20:22:55 +02:00
Unchained
319f62b923 chore(k8s): sync deployment.yaml with master - add OpenPanel env vars 2026-03-25 20:10:20 +02:00
Unchained
f73f3b8576 chore(k8s): sync deployment.yaml with master - add OpenPanel env vars 2026-03-25 20:09:42 +02:00
Unchained
646d057970 Merge branch 'feature/saleor-emails' into dev 2026-03-25 19:58:17 +02:00
Unchained
a0fa0f5401 fix(analytics): add OpenPanel revenue tracking to webhooks
Add OpenPanel import and initialization that was missing from webhook route.
Add order_received and revenue tracking when orders are confirmed.
Revenue tracking uses op.revenue() method with amount, currency,
order_id, and order_number properties.
2026-03-25 19:57:43 +02:00
Unchained
aa7a0ed3c8 fix(webhook): remove incorrect /100 division from formatPrice
Saleor stores amounts as actual currency values (e.g., 5479 RSD),
not as cents (e.g., 547900). The formatPrice function was incorrectly
dividing by 100, causing prices like 5479 RSD to display as 55 RSD.
2026-03-25 19:53:08 +02:00
Unchained
15a65758d7 fix(webhook): remove incorrect /100 division from formatPrice
Saleor stores amounts as actual currency values (e.g., 5479 RSD),
not as cents (e.g., 547900). The formatPrice function was incorrectly
dividing by 100, causing prices like 5479 RSD to display as 55 RSD.
2026-03-25 19:51:27 +02:00
Unchained
b5f8ddbaaa fix(analytics): add OpenPanel client secret and server-side tracking
Some checks failed
Build and Deploy / build (push) Has been cancelled
- Add OPENPANEL_CLIENT_SECRET for server-side tracking
- Add OPENPANEL_API_URL environment variable
- Add server-side OpenPanel tracking for orders
- Track order_received and revenue events on webhook,description:Commit OpenPanel fixes
2026-03-25 19:15:48 +02:00
Unchained
6dbaf99b29 fix(analytics): use direct OpenPanel URL instead of proxy
Use https://op.nodecrew.me/api and https://op.nodecrew.me/op1.js
directly since OpenPanel is self-hosted.
2026-03-25 19:09:10 +02:00
Unchained
cdd3f9c77e fix(analytics): add proxy route and correct script URL for OpenPanel
- Add /api/op/[...path] proxy route to forward events to self-hosted OpenPanel
- Add scriptUrl=/api/op/op1.js to OpenPanelComponent
- Proxy prevents ad blockers from blocking tracking requests
2026-03-25 19:07:52 +02:00
Unchained
17367024c2 feat(analytics): add OpenPanel tracking to storefront
Add comprehensive OpenPanel analytics tracking:
- Install @openpanel/nextjs SDK
- Add OpenPanelComponent to root layout for automatic page views
- Create useAnalytics hook for tracking custom events
- Track checkout funnel: started, shipping step, order completed
- Track product views and add-to-cart events
- Identify users on order completion
- Add NEXT_PUBLIC_OPENPANEL_CLIENT_ID to environment
2026-03-25 18:48:13 +02:00
Unchained
bf628f873f fix(webhook): prevent duplicate customer emails by only sending on ORDER_CONFIRMED
Some checks failed
Build and Deploy / build (push) Has been cancelled
Both ORDER_CREATED and ORDER_CONFIRMED were sending customer emails,
causing duplicates. Now only ORDER_CONFIRMED sends customer emails,
while both events still notify admins.
2026-03-25 16:17:35 +02:00
Unchained
eb311568db fix(webhook): get currency from channel.currency_code instead of top-level
Some checks failed
Build and Deploy / build (push) Has been cancelled
Saleor webhook payload stores currency in channel.currency_code,
not as a top-level currency field. Updated interfaces and conversion
function to use the correct location.
2026-03-25 15:32:49 +02:00
Unchained
c9aaacc452 fix(webhook): handle Saleor legacy webhook payload format with snake_case fields
Some checks failed
Build and Deploy / build (push) Has been cancelled
Saleor sends webhook payloads as arrays with snake_case fields:
- user_email instead of userEmail
- billing_address instead of billingAddress
- total_gross_amount instead of total.gross.amount
- etc.

Added convertPayloadToOrder() function to transform snake_case payload
to camelCase format expected by our email templates.
2026-03-25 15:22:40 +02:00
Unchained
e08e919e83 fix(webhook): handle Saleor subscription payload format (array)
Some checks failed
Build and Deploy / build (push) Has been cancelled
Saleor sends webhook payloads as arrays in subscription format.
This fix extracts the order from the array or object format.
2026-03-25 15:10:45 +02:00
Unchained
923f805d47 fix(webhook): normalize event names to uppercase for case-insensitive matching
Some checks failed
Build and Deploy / build (push) Has been cancelled
Saleor sends event names in lowercase (order_created) but our code
expects uppercase (ORDER_CREATED). This fix normalizes the event
name before checking supported events.
2026-03-25 14:59:32 +02:00
Unchained
6e0a05c314 fix(k8s): add RESEND_API_KEY and DASHBOARD_URL env vars to deployment
Some checks failed
Build and Deploy / build (push) Has been cancelled
2026-03-25 14:26:56 +02:00
Unchained
5576946829 feat(emails): implement transactional email system with Resend
Some checks failed
Build and Deploy / build (push) Has been cancelled
- Add Resend email integration with @react-email/render
- Create email templates: OrderConfirmation, OrderShipped, OrderCancelled, OrderPaid
- Implement webhook handler for ORDER_CREATED and other events
- Add multi-language support for customer emails
- Admin emails in English with order details
- Update checkout page with auto-scroll on order completion
- Configure DASHBOARD_URL environment variable
2026-03-25 14:13:34 +02:00
Unchained
ef83538d0b fix: add required email and country fields to checkout
- Add email field (required) for order confirmation
- Add phone field in contact info section
- Add country dropdown with regional options
- Add validation for email format and required fields
- Add checkoutEmailUpdate mutation call before completing
- Use selected country instead of hardcoded RS
- Add translations for new fields (EN, SR, DE, FR)
2026-03-25 10:50:42 +02:00
Unchained
4fcd4b3ba8 refactor: abstract site URL across email templates
- Add NEXT_PUBLIC_SITE_URL to .env.local
- Update email templates to accept siteUrl prop
- Update webhook handler to pass siteUrl from env var
- Update create-webhooks.graphql with placeholder URL
2026-03-25 10:33:03 +02:00
Unchained
b8b3a57e6f feat: Add Saleor webhook handler with Resend email integration
- Add Resend SDK for transactional emails
- Create React Email templates for order events:
  - OrderConfirmation
  - OrderShipped
  - OrderCancelled
  - OrderPaid
- Multi-language support (SR, EN, DE, FR)
- Customer emails in their language
- Admin emails in English to me@hytham.me and tamara@hytham.me
- Webhook handler at /api/webhooks/saleor
- Supports: ORDER_CONFIRMED, ORDER_FULLY_PAID, ORDER_CANCELLED, ORDER_FULFILLED
- Add GraphQL mutation to create webhooks in Saleor
- Add Resend API key to .env.local
2026-03-25 10:10:57 +02:00
Unchained
00f63c32f8 fix: use PRODUCT_FRAGMENT to get attributes for bundle detection
Some checks failed
Build and Deploy / build (push) Has been cancelled
2026-03-24 20:26:42 +02:00
Unchained
3d8a77dafa refactor: centralize bundle filtering with filterOutBundles helper
Some checks failed
Build and Deploy / build (push) Has been cancelled
2026-03-24 20:18:06 +02:00
Unchained
bfce7dcca0 fix: filter bundles from homepage, sitemap, and static params
Some checks failed
Build and Deploy / build (push) Has been cancelled
2026-03-24 20:14:42 +02:00
Unchained
8f780c3585 fix: bundle UI improvements - remove QTY selector, filter bundles from similar products
Some checks failed
Build and Deploy / build (push) Has been cancelled
2026-03-24 18:50:39 +02:00
Unchained
9a61564e3c feat: add bundle feature with 2x/3x set options
Some checks failed
Build and Deploy / build (push) Has been cancelled
- Created BundleSelector component for selecting bundle options
- Updated ProductDetail to show bundle options
- Added bundle translations for all 4 locales
- Added GraphQL query for bundle products
- Updated TypeScript types for attributes
- Saleor backend: created bundle products for all base products
2026-03-24 16:00:07 +02:00
Unchained
28a6e58dba Merge branch 'dev'
Some checks failed
Build and Deploy / build (push) Has been cancelled
2026-03-24 14:17:00 +02:00
Unchained
569a3e65fe fix: correct metadata access and locale variable names 2026-03-24 14:16:49 +02:00
Unchained
1ba81a1fde Merge dev into master: resolve middleware conflict (use dev version with full locale detection)
Some checks failed
Build and Deploy / build (push) Has been cancelled
2026-03-24 14:08:17 +02:00
Unchained
df95e729fc CSS polish: increase newsletter input height for better UX 2026-03-24 13:46:38 +02:00
Unchained
b18ab349b6 fix: revert newsletter form, keep only taller input 2026-03-24 13:43:02 +02:00
Unchained
855215badd fix: update newsletter form layout for taller input 2026-03-24 13:40:08 +02:00
Unchained
f40e661bf3 fix: make newsletter input taller without changing button height 2026-03-24 13:38:59 +02:00
Unchained
080a9e4e21 fix: increase homepage newsletter input height to h-16 2026-03-24 13:36:07 +02:00
Unchained
44f4e548c8 fix: make newsletter input taller with h-12 2026-03-24 12:49:27 +02:00
Unchained
5ae79716a3 fix: increase newsletter email input height 2026-03-24 12:48:15 +02:00
Unchained
922978bf80 feat: add ManoonOils logo as app icon and favicon 2026-03-24 12:45:18 +02:00
Unchained
930a9a7614 refactor: eliminate hardcoded locale comparisons for antifragility
Created centralized helpers:
- src/lib/i18n/pageMetadata.ts: All page metadata (titles, descriptions, alt text)
- src/lib/i18n/productText.ts: Product-specific translated text (shortDescription, benefits)
- src/lib/i18n/metadata.ts: Helper functions for locale handling

Updated all pages to use centralized metadata:
- Homepage: Uses getPageMetadata for title, description, productionAlt
- Products page: Uses getPageMetadata
- Product detail: Uses getPageMetadata + getTranslatedShortDescription/getTranslatedBenefits
- About page: Uses getPageMetadata

ProductDetail component now uses:
- getTranslatedShortDescription() instead of locale comparison
- getTranslatedBenefits() instead of locale comparison

All user-facing text now goes through translation files or centralized helpers.
Adding a new language now requires only:
1. Add to SUPPORTED_LOCALES in locales.ts
2. Add LOCALE_CONFIG entry
3. Add entries to pageMetadata.ts and productText.ts
4. Add translation keys to message files
2026-03-24 12:39:38 +02:00
Unchained
3d895f4d7a refactor: improve locale modularity
- Added src/lib/i18n/metadata.ts with helper functions
- Updated [locale]/layout.tsx to use DEFAULT_LOCALE constant
- routing.ts already uses centralized SUPPORTED_LOCALES

Note: For full antifragility, a larger refactor would centralize
all hardcoded locale comparisons for metadata text fallbacks.
Currently adding a new language requires:
1. SUPPORTED_LOCALES in locales.ts
2. LOCALE_CONFIG entry
3. Translation keys in all message files
2026-03-24 12:30:05 +02:00
Unchained
ab5b5d9848 feat: add heart emoji and bold to 'Made with' text in footer 2026-03-24 12:23:13 +02:00
Unchained
8a76342b07 chore: remove unused first Footer section from en.json and sr.json 2026-03-24 12:21:33 +02:00
Unchained
95c844ad2b fix: add madeWith to second English Footer section 2026-03-24 12:16:50 +02:00
Unchained
22b0b2c31a fix: Serbian madeWith uses Latin script not Cyrillic 2026-03-24 12:14:25 +02:00
Unchained
5f0ef80fe7 feat: add 'Made with ❤️ by Nodecrew' to footer with translations 2026-03-24 12:13:07 +02:00
Unchained
9a72e46d39 fix: add missing French and German translations for CartDrawer 2026-03-24 12:07:49 +02:00
Unchained
8120f2b908 fix: add missing removeItem translation to French and German 2026-03-24 12:04:17 +02:00
Unchained
b7914303ee fix: add missing French and German Cart translations 2026-03-24 12:01:49 +02:00
Unchained
c40d91e35b fix: buildLocalePath always includes locale prefix - required by routing 2026-03-24 11:56:54 +02:00