feat: implement product categories with tabbed filtering and admin configuration

This commit is contained in:
DanielS
2026-05-01 00:52:40 +02:00
parent 9c0164c4fe
commit 316d9510a8
9 changed files with 948 additions and 29 deletions

View File

@@ -0,0 +1,28 @@
-- Categories Table
CREATE TABLE IF NOT EXISTS public.categories (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
name TEXT NOT NULL,
description TEXT,
icon TEXT, -- Lucide icon name or similar
created_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now()) NOT NULL
);
-- Add category_id to products
ALTER TABLE public.products ADD COLUMN IF NOT EXISTS category_id UUID REFERENCES public.categories(id) ON DELETE SET NULL;
-- Enable RLS
ALTER TABLE public.categories ENABLE ROW LEVEL SECURITY;
-- Policies
CREATE POLICY "Allow public read access on categories" ON public.categories FOR SELECT USING (true);
-- Seed Categories
INSERT INTO public.categories (id, name, description, icon)
VALUES
('c1a1a1a1-a1a1-a1a1-a1a1-a1a1a1a1a1a1', 'Cloud Software', 'Modulare Cloud-Lösungen für den modernen Handel.', 'Cloud'),
('c2a2a2a2-a2a2-a2a2-a2a2-a2a2a2a2a2a2', 'Gastronomie', 'Kassensysteme und Management für Restaurants und Cafés.', 'Utensils'),
('c3a3a3a3-a3a3-a3a3-a3a3-a3a3a3a3a3a3', 'Hardware', 'Kassenterminals, Drucker und Zubehör.', 'HardDrive');
-- Update existing products with categories
UPDATE public.products SET category_id = 'c1a1a1a1-a1a1-a1a1-a1a1-a1a1a1a1a1a1' WHERE name LIKE '%Cloud%';
UPDATE public.products SET category_id = 'c2a2a2a2-a2a2-a2a2-a2a2-a2a2a2a2a2a2' WHERE name LIKE '%Gastro%';