From d6a0b8edb59b0ff571164c813cade510ae00aeb4 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 13 Mar 2026 02:00:47 +0000 Subject: [PATCH] version11 --- frontend/src/AdminLayout.tsx | 20 +++++----- frontend/src/App.tsx | 8 ++++ frontend/src/CategoryForm.tsx | 34 +++++++++++++++++ frontend/src/CategoryManagement.tsx | 14 ++++--- frontend/src/ProductForm.tsx | 30 ++++++++++----- frontend/src/ProductList.tsx | 26 +++++++++++-- frontend/src/SellerForm.tsx | 35 +++++++++++++++++ frontend/src/SellerManagement.tsx | 23 ++++++----- frontend/src/UserProfile.tsx | 59 +++++++++++++++++++++++++++++ frontend/src/index.css | 19 +++++++++- 10 files changed, 228 insertions(+), 40 deletions(-) create mode 100644 frontend/src/CategoryForm.tsx create mode 100644 frontend/src/SellerForm.tsx create mode 100644 frontend/src/UserProfile.tsx diff --git a/frontend/src/AdminLayout.tsx b/frontend/src/AdminLayout.tsx index 621c03f..ec4303c 100644 --- a/frontend/src/AdminLayout.tsx +++ b/frontend/src/AdminLayout.tsx @@ -1,22 +1,22 @@ import React from 'react'; -import { Link, Outlet } from 'react-router-dom'; +import { NavLink } from 'react-router-dom'; -const AdminLayout: React.FC = () => { +const AdminLayout: React.FC<{ children: React.ReactNode }> = ({ children }) => { return (
-
); }; -export default AdminLayout; +export default AdminLayout; \ No newline at end of file diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 1757990..927d49a 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -4,12 +4,15 @@ import LoginPage from './LoginPage'; import ProductList from './ProductList'; import ProductDetail from './ProductDetail'; import CartPage from './CartPage'; +import UserProfile from './UserProfile'; import AdminLayout from './AdminLayout'; import AdminRoute from './AdminRoute'; import ProductManagement from './ProductManagement'; import ProductForm from './ProductForm'; import SellerManagement from './SellerManagement'; +import SellerForm from './SellerForm'; import CategoryManagement from './CategoryManagement'; +import CategoryForm from './CategoryForm'; import { CartProvider } from './CartContext'; import { AuthProvider } from './AuthContext'; @@ -28,6 +31,7 @@ function App() { } /> } /> } /> + } /> @@ -38,7 +42,11 @@ function App() { } /> } /> } /> + } /> + } /> } /> + } /> + } /> diff --git a/frontend/src/CategoryForm.tsx b/frontend/src/CategoryForm.tsx new file mode 100644 index 0000000..cc96d74 --- /dev/null +++ b/frontend/src/CategoryForm.tsx @@ -0,0 +1,34 @@ +import React, { useState, useEffect } from 'react'; +import axios from 'axios'; +import { useNavigate, useParams } from 'react-router-dom'; + +const CategoryForm: React.FC = () => { + const { id } = useParams<{ id: string }>(); + const navigate = useNavigate(); + const [formData, setFormData] = useState({ name: '' }); + + useEffect(() => { + if (id) { + axios.get(`http://127.0.0.1:8000/categories/${id}/`) + .then(res => setFormData(res.data)); + } + }, [id]); + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + const action = id ? axios.put(`http://127.0.0.1:8000/categories/${id}/`, formData) : axios.post('http://127.0.0.1:8000/categories/', formData); + action.then(() => navigate('/admin/categories')); + }; + + return ( +
+

{id ? 'Edit' : 'Create'} Category

+
+ setFormData({...formData, name: e.target.value})} /> + +
+
+ ); +}; + +export default CategoryForm; diff --git a/frontend/src/CategoryManagement.tsx b/frontend/src/CategoryManagement.tsx index bdccb88..20c1071 100644 --- a/frontend/src/CategoryManagement.tsx +++ b/frontend/src/CategoryManagement.tsx @@ -1,10 +1,10 @@ import React, { useEffect, useState } from 'react'; import axios from 'axios'; +import { Link } from 'react-router-dom'; interface Category { id: number; name: string; - slug: string; } const CategoryManagement: React.FC = () => { @@ -39,13 +39,15 @@ const CategoryManagement: React.FC = () => { return (
-

Category Management

+
+

Category Management

+ Create Category +
- @@ -54,8 +56,8 @@ const CategoryManagement: React.FC = () => { - -
ID NameSlug Actions
{category.id} {category.name}{category.slug} + + Edit