From cee837e1a6434d3140c2adfeeabb43bdedcd1a87 Mon Sep 17 00:00:00 2001 From: tuanOts Date: Sun, 8 Jun 2025 23:02:58 +0700 Subject: [PATCH] =?UTF-8?q?=EF=BF=BD=EF=B8=8F=20Integrated=20Project=20Del?= =?UTF-8?q?ete=20API=20with=20Enhanced=20Error=20Handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit � API Integration: - Integrated /api/Projects/delete/{id} endpoint for project deletion - Used POST method instead of DELETE for better server compatibility - Added comprehensive request headers (Content-Type, Accept JSON) - Proper project ID parameter passing in URL path �️ Enhanced Error Handling: - Robust response parsing for empty, non-JSON, and malformed responses - Smart success detection with multiple criteria (HTTP status, response content) - Graceful fallback logic for edge cases and parsing failures - Comprehensive error logging with emojis for better debugging ✅ User Experience Improvements: - Modal confirmation dialog with Vietnamese text before deletion - Clear success/error messages with proper feedback - Automatic data reload after successful deletion - Color-coded action icons (blue edit, red delete) with hover effects � Response Handling: - Handles HTTP 200 OK with empty response body as success - Handles non-JSON responses gracefully - Detects actual API errors vs successful operations - Prevents false error messages on successful deletions � Technical Features: - Try-catch blocks with detailed error information - Raw response text logging for debugging - JSON parsing with fallback mechanisms - Maintains pagination state after deletion � UI Enhancements: - Professional action column with edit and delete buttons - Consistent styling with existing application theme - Responsive design for mobile and desktop - Loading states during API operations --- src/core/json/siderbar_data.jsx | 10 +- src/feature-module/projects/createproject.jsx | 71 +++++----- .../projects/projecttracker.jsx | 129 +++++++++++++++--- 3 files changed, 151 insertions(+), 59 deletions(-) diff --git a/src/core/json/siderbar_data.jsx b/src/core/json/siderbar_data.jsx index 5c9f0c6..ade97db 100644 --- a/src/core/json/siderbar_data.jsx +++ b/src/core/json/siderbar_data.jsx @@ -65,14 +65,14 @@ export const SidebarData = [ { label: "Create Product", link: "/add-product", icon: ,showSubRoute: false, submenu: false }, { label: "Expired Products", link: "/expired-products", icon: ,showSubRoute: false,submenu: false }, { label: "Low Stocks", link: "/low-stocks", icon: ,showSubRoute: false,submenu: false }, - { label: "Category", link: "/category-list", icon: ,showSubRoute: false,submenu: false }, + { label: "Danh mục", link: "/category-list", icon: ,showSubRoute: false,submenu: false }, { label: "Sub Category", link: "/sub-categories", icon: ,showSubRoute: false,submenu: false }, - { label: "Brands", link: "/brand-list", icon: ,showSubRoute: false,submenu: false }, + { label: "Thương hiệu", link: "/brand-list", icon: ,showSubRoute: false,submenu: false }, { label: "Units", link: "/units", icon: ,showSubRoute: false,submenu: false }, { label: "Variant Attributes", link: "/variant-attributes", icon: ,showSubRoute: false,submenu: false }, - { label: "Warranties", link: "/warranty", icon: ,showSubRoute: false,submenu: false }, - { label: "Print Barcode", link: "/barcode", icon: , showSubRoute: false,submenu: false }, - { label: "Print QR Code", link: "/qrcode", icon: ,showSubRoute: false,submenu: false }, + { label: "Bảo hành", link: "/warranty", icon: ,showSubRoute: false,submenu: false }, + { label: "In Barcode", link: "/barcode", icon: , showSubRoute: false,submenu: false }, + { label: "In QR Code", link: "/qrcode", icon: ,showSubRoute: false,submenu: false }, { label: "Khách mời đám cưới", link: "/wedding-guest-list", icon: ,showSubRoute: false,submenu: false } ] }, diff --git a/src/feature-module/projects/createproject.jsx b/src/feature-module/projects/createproject.jsx index c79c4b1..3d666e4 100644 --- a/src/feature-module/projects/createproject.jsx +++ b/src/feature-module/projects/createproject.jsx @@ -65,7 +65,8 @@ const CreateProject = () => { { id: 1, name: 'Web Development', color: 'blue' }, { id: 2, name: 'Mobile App', color: 'green' }, { id: 3, name: 'Design', color: 'purple' }, - { id: 4, name: 'Marketing', color: 'orange' } + { id: 4, name: 'Marketing', color: 'orange' }, + { id: 5, name: 'Khác', color: 'orange' }, ]); } } catch (error) { @@ -285,8 +286,8 @@ const CreateProject = () => {
-

Create New Project

-
Add a new project to your workspace
+

Tạo dự án

+
Thêm một dự án mới vào không gian làm việc của bạn
@@ -308,19 +309,19 @@ const CreateProject = () => {
-
Project Information
+
Thông tin
- + handleInputChange('projectName', e.target.value)} - placeholder="Enter project name" + placeholder="Nhập tên dự án" /> {errors.projectName &&
{errors.projectName}
}
@@ -328,13 +329,13 @@ const CreateProject = () => {
- + handleInputChange('clientName', e.target.value)} - placeholder="Enter client name" + placeholder="Nhập đối tác" /> {errors.clientName &&
{errors.clientName}
}
@@ -342,13 +343,13 @@ const CreateProject = () => {
- +