Admin Login Page, Instagram create and edit Route, Instagram management and Galley Image create and Edit route#227
Merged
wumibals merged 1 commit intoMar 29, 2026
Conversation
… page and Gallery Create and edt route
|
@RUKAYAT-CODER Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
wumibals
approved these changes
Mar 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
close #144
close #151
close #152
close #153
successfully implemented the Gallery create and edit routes following the specified requirements:
Files Created:
frontend/app/components/admin/gallery/GalleryForm.tsx - Complete gallery form component
frontend/app/components/admin/gallery/GalleryFormWrapper.tsx - Wrapper for mode-based functionality
frontend/app/(auth)/admin/gallery/new/page.tsx - Server component for creating new gallery images
frontend/app/(auth)/admin/gallery/[id]/page.tsx - Client component for editing existing gallery images
Features Implemented:
✅ GalleryForm Component:
Complete form with image upload, alt text, category selection, display order, and visibility toggle
Zod validation for all fields
React Hook Form integration
Responsive design with Tailwind CSS
Category dropdown with options: Food, Ambiance, Kitchen, Events, Drinks
✅ GalleryFormWrapper Component:
Handles both create and edit modes via mode prop
TanStack Query integration for data fetching
Loading and error states for edit mode
Proper navigation back to /admin/gallery after successful operations
Mutation handling with error feedback
✅ Create Route (/admin/gallery/new):
Server component with metadata: { title: "Add Gallery Image" }
Renders
Heading: "Add to Gallery"
Submit label: "Add to Gallery"
Role-based access protection
✅ Edit Route (/admin/gallery/[id]):
"use client" component as specified
Uses useParams to read the dynamic ID segment
Fetches gallery image by ID using TanStack Query (adminApi.getGalleryImage(id))
Renders
Shows loading state while fetching
Error handling for failed fetches
Heading: "Update Image"
Submit label: "Update Image"
Technical Implementation:
✅ Form Fields:
Image Upload: Required field with validation
Alt Text: Required for accessibility
Category: Dropdown with 5 predefined categories
Display Order: Numeric field for manual ordering
Visibility Toggle: Checkbox for show/hide functionality
✅ Data Flow:
Create mode: Calls adminApi.createGalleryImage()
Edit mode: Calls adminApi.updateGalleryImage()
Automatic redirect to /admin/gallery on success
Query invalidation for fresh data
✅ User Experience:
Loading skeletons during data fetch
Form validation with inline error messages
Disabled state during submission
Success/error feedback
Responsive design
API Integration:
Uses existing admin API functions from admin
Proper TypeScript typing throughout
Error handling for all API calls
Optimistic updates where appropriate
The implementation follows the same pattern as the Instagram routes and provides a complete CRUD interface for gallery management with proper authentication, validation, and user experience. Both routes are fully functional and ready for use.
Here's a comprehensive summary of the 4 implementations I completed:
📋 Implementation Summary
Admin Login Page
Files: frontend/app/(auth)/login/page.tsx & LoginClient.tsx
Purpose: Authentication entry point for admin users
Key Features:
Username/password form with Zod validation
React Hook Form integration
Password show/hide toggle with Lucide icons
Redirects authenticated users to /admin/dashboard
Inline error handling (no toasts)
Loading states during API calls
Conditional registration link based on NEXT_PUBLIC_ALLOW_REGISTRATION
Centered card layout with brand logo
API Integration: Added adminApi.login() function
Auth Flow: Uses Zustand store (useAuthStore) for token management
Instagram Create & Edit Routes
Files: frontend/app/(auth)/admin/instagram/new/page.tsx, [id]/page.tsx, & InstagramFormWrapper.tsx
Purpose: CRUD operations for Instagram posts
Key Features:
Create Route: Server component with metadata { title: "Add Instagram Post" }
Edit Route: Client component using useParams to fetch post by ID
TanStack Query for data fetching and caching
Loading and error states for edit mode
Automatic redirect to /admin/instagram after operations
API Integration: Added getById, create, update functions to Instagram API
Pattern: Mirrors gallery routes with mode-based wrapper component
Instagram Management Page
Files: frontend/app/(auth)/admin/instagram/page.tsx & InstagramClient.tsx
Purpose: Main dashboard for managing Instagram posts
Key Features:
3 Stat Cards: Total Posts, Visible, Hidden with animated entrance
Add Post Button: Links to /admin/instagram/new
Instagram Table: Toggle visibility (inline mutation) + delete (confirm dialog)
Loading Skeleton: Complete UI skeleton during data fetch
Error State: User-friendly error display with retry
Empty State: Beautiful empty state when no posts exist
Operations:
Toggle visibility via adminApi.toggleInstagramPostVisibility() (PATCH)
Delete via adminApi.deleteInstagramPost() with confirmation
Automatic query invalidation after successful operations
UI/UX: Framer Motion animations, toast notifications, responsive design
Gallery Create & Edit Routes
Files: frontend/app/(auth)/admin/gallery/new/page.tsx, [id]/page.tsx, GalleryForm.tsx, & GalleryFormWrapper.tsx
Purpose: CRUD operations for gallery images
Key Features:
Complete GalleryForm: Image upload, alt text, category dropdown, display order, visibility toggle
5 Categories: Food, Ambiance, Kitchen, Events, Drinks
Create Route: Server component with metadata { title: "Add Gallery Image" }
Edit Route: Client component fetching image by ID via TanStack Query
Headings: "Add to Gallery" for create, "Update Image" for edit
Validation: Zod schema with React Hook Form integration
API Integration: Uses existing admin API functions (createGalleryImage, updateGalleryImage)
Pattern: Same mode-based wrapper approach as Instagram routes
🔗 Common Patterns & Architecture
Shared Architecture:
Role Protection: All routes use RoleProtectedPage with proper role checks
API Integration: Consistent use of adminApi from admin
State Management: TanStack Query for server state, Zustand for auth
Form Handling: React Hook Form + Zod validation across all forms
UI Components: Consistent use of shared UI components (Button, Input, etc.)
Error Handling: Loading states, error boundaries, toast notifications
Navigation: Automatic redirects after successful operations
Technical Stack:
Framework: Next.js 15 App Router
Styling: Tailwind CSS with responsive design
Animations: Framer Motion for smooth transitions
Forms: React Hook Form + Zod validation
Data Fetching: TanStack Query
State Management: Zustand for auth
Icons: Lucide React
Notifications: React Hot Toast
File Structure:
frontend/app/(auth)/admin/
├── login/ # Admin authentication
├── instagram/
│ ├── page.tsx # Management dashboard
│ ├── new/page.tsx # Create post
│ └── [id]/page.tsx # Edit post
└── gallery/
├── new/page.tsx # Create image
└── [id]/page.tsx # Edit image
All implementations follow Next.js 15 conventions, TypeScript best practices, and provide complete CRUD functionality with proper authentication, validation, and user experience.