mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 02:32:57 +00:00
3.5 KiB
3.5 KiB
Clothing System Implementation
Summary
A comprehensive clothing/merchandise system has been implemented with the following features:
Features
-
Database & Backend
- New
clothingtable with fields: title, description, price, currency, image_url, url, is_active, display_order - Full CRUD API endpoints (public & admin)
- Soft delete support
- New
-
Admin Management (
/admin/obleceni)- Create, update, delete clothing items
- Fields:
- Title (required)
- Description (optional)
- Price (optional, with currency field)
- Image URL (required)
- Shop URL (optional)
- Display Order (for sorting)
- Active/Inactive toggle
- Individual save buttons for each item
- Real-time validation
-
Public Pages
- Homepage (
/): Shows 5 newest clothing items in the MerchSection - Clothing Page (
/obleceni): Shows all active items in a grid layout - Displays price badges when available
- Links to e-shop URLs (external links)
- "View All" button on homepage to navigate to full clothing page
- Homepage (
-
Design
- Responsive grid layout
- Price badges for items with pricing
- Image placeholders for missing images
- Hover effects and smooth transitions
- External link indicators
Files Created
Backend
database/migrations/20251012000001_create_clothing_table.up.sqldatabase/migrations/20251012000001_create_clothing_table.down.sqlinternal/models/clothing.gointernal/controllers/clothing_controller.go
Frontend
frontend/src/services/clothing.tsfrontend/src/pages/ClothingPage.tsx
Modified Files
internal/routes/routes.go- Added clothing routesmain.go- Added Clothing model to AutoMigratefrontend/src/App.tsx- Added /obleceni routefrontend/src/pages/admin/AdminMerchPage.tsx- Complete rewrite with price field and proper CRUDfrontend/src/components/home/MerchSection.tsx- Updated to fetch from API and show 5 newest items
API Endpoints
Public
GET /api/v1/clothing- Get all active clothing items
Admin (requires authentication)
GET /api/v1/admin/clothing- Get all clothing items (including inactive)GET /api/v1/admin/clothing/:id- Get single clothing itemPOST /api/v1/admin/clothing- Create new clothing itemPUT /api/v1/admin/clothing/:id- Update clothing itemDELETE /api/v1/admin/clothing/:id- Delete clothing item (soft delete)POST /api/v1/admin/clothing/reorder- Update display order
Database Schema
CREATE TABLE clothing (
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
description TEXT,
price DECIMAL(10, 2),
currency VARCHAR(10) DEFAULT 'Kč',
image_url VARCHAR(500),
url VARCHAR(500),
is_active BOOLEAN DEFAULT true,
display_order INT DEFAULT 0,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP
);
Usage
- Add Items: Navigate to
/admin/obleceniand click "Přidat položku" - Fill Details: Add title, image URL, price (optional), and shop link
- Save: Click the "Uložit" button for each item
- View Public: Items appear on homepage (5 newest) and
/obleceni(all items)
Next Steps (Optional Enhancements)
- Add image upload functionality instead of URL-only
- Add categories/tags for clothing items
- Add size/color variants
- Add stock tracking
- Add multi-image support for each item
- Add sorting options on public page (price, newest, etc.)