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)
This commit is contained in:
22
customer-spa/src/hooks/usePageTitle.ts
Normal file
22
customer-spa/src/hooks/usePageTitle.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
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;
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import Container from '@/components/Layout/Container';
|
||||
import SEOHead from '@/components/SEOHead';
|
||||
import { formatPrice } from '@/lib/currency';
|
||||
import { Trash2, Plus, Minus, ShoppingBag, ArrowLeft, Loader2, X, Tag } from 'lucide-react';
|
||||
import { toast } from 'sonner';
|
||||
@@ -155,6 +156,7 @@ export default function Cart() {
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<SEOHead title="Shopping Cart" description="Review your shopping cart" />
|
||||
<div className={`py-8 ${layout.style === 'boxed' ? 'max-w-5xl mx-auto' : ''}`}>
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between mb-8">
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useCartStore } from '@/lib/cart/store';
|
||||
import { useCheckoutSettings } from '@/hooks/useAppearanceSettings';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import Container from '@/components/Layout/Container';
|
||||
import SEOHead from '@/components/SEOHead';
|
||||
import { formatPrice } from '@/lib/currency';
|
||||
import { ArrowLeft, ShoppingBag, MapPin, Check, Edit2, Loader2, X, Tag } from 'lucide-react';
|
||||
import { toast } from 'sonner';
|
||||
@@ -339,6 +340,7 @@ export default function Checkout() {
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<SEOHead title="Checkout" description="Complete your purchase" />
|
||||
<div className="py-8">
|
||||
{/* Header */}
|
||||
<div className="mb-8">
|
||||
|
||||
Reference in New Issue
Block a user