Files
WooNooW/customer-spa/src/hooks/usePageTitle.ts
Dwindi Ramadhana d7b132d9d9 fix: dbDelta separate tables, add SEOHead for page titles
1. License table creation:
   - dbDelta requires separate calls per CREATE TABLE
   - Split into sql_licenses and sql_activations
   - Added 'PRIMARY KEY  (id)' with two spaces (dbDelta requirement)

2. Page titles:
   - Added SEOHead to Cart page (title: Shopping Cart)
   - Added SEOHead to Checkout page (title: Checkout)
   - Shop already had SEOHead

3. usePageTitle hook created (alternative to SEOHead for non-Helmet usage)
2026-01-07 22:40:45 +07:00

23 lines
719 B
TypeScript

import { useEffect } from 'react';
/**
* Hook to set the document title dynamically
* @param title - The page title to set
* @param suffix - Optional suffix (default: store name from settings)
*/
export function usePageTitle(title: string, suffix?: string) {
useEffect(() => {
const storeName = (window as any).woonoowCustomer?.storeName || 'Store';
const finalSuffix = suffix ?? storeName;
document.title = title ? `${title} | ${finalSuffix}` : finalSuffix;
// Cleanup: restore original title when component unmounts
return () => {
// Don't restore - let the next page set its own title
};
}, [title, suffix]);
}
export default usePageTitle;