diff --git a/src/pages/BrandsDetail.jsx b/src/pages/BrandsDetail.jsx index ba1f642..692ff2b 100644 --- a/src/pages/BrandsDetail.jsx +++ b/src/pages/BrandsDetail.jsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from 'react'; import SearchBar from '../components/SearchBar'; import { Alert, Button, Form, Modal } from 'react-bootstrap'; -import { Folders, Hash, LinkIcon, Plus, Users } from 'lucide-react'; +import { Folders, Hash, LinkIcon, Plus, Users, X } from 'lucide-react'; import { useDispatch, useSelector } from 'react-redux'; import { Link, useParams } from 'react-router-dom'; import CampaignList from '../components/CampaignList'; @@ -18,6 +18,7 @@ import ProductDetail from '../components/ProductDetail'; import { CAMPAIGN_SERVICES, CREATOR_CATEGORIES, CREATOR_LEVELS, CREATOR_TYPES, GMV_RANGES } from '../lib/constant'; import RangeSlider from '../components/RangeSlider'; import SpinningComponent from '../components/Spinning'; +import { setNotificationBarMessage } from '../store/slices/notificationBarSlice'; export default function BrandsDetail() { const { id } = useParams(); @@ -26,6 +27,7 @@ export default function BrandsDetail() { const { selectedBrand } = useSelector((state) => state.brands); const [showProductDetail, setShowProductDetail] = useState(false); const [showAddCampaignModal, setShowAddCampaignModal] = useState(false); + const [showAddProductModal, setShowAddProductModal] = useState(false); useEffect(() => { if (id) { @@ -52,7 +54,7 @@ export default function BrandsDetail() { )} {activeTab === 'products' && ( - @@ -149,6 +151,7 @@ export default function BrandsDetail() { )} setShowAddCampaignModal(false)} /> + setShowAddProductModal(false)} /> ) ); @@ -218,7 +221,7 @@ export function AddCampaignModal({ show, onHide }) { }; return ( - + Add Campaign @@ -368,3 +371,111 @@ export function AddCampaignModal({ show, onHide }) { ); } + +export function AddProductModal({ show, onHide }) { + const dispatch = useDispatch(); + const [productIds, setProductIds] = useState({ + 0: '', + }); + + const addProduct = () => { + const newIndex = Object.keys(productIds).length; + console.log(newIndex); + + setProductIds((prev) => ({ + ...prev, + [newIndex]: '', + })); + }; + + const handleChange = (e) => { + const { name, value } = e.target; + setProductIds((prev) => ({ + ...prev, + [name]: value, + })); + }; + + const handleClose = () => { + setProductIds([]); + onHide(); + }; + + const handleSubmit = (e) => { + e.preventDefault(); + dispatch( + setNotificationBarMessage({ + message: '这个接口是哪一个?', + variant: 'info', + }) + ); + const form = document.getElementById('addProductForm'); + if (form.checkValidity() === false) { + e.preventDefault(); + e.stopPropagation(); + setValidated(true); + return; + } + console.log(productIds); + }; + + const removeProduct = (index) => { + if (Object.keys(productIds).length === 1) { + return; + } + setProductIds((prev) => { + const updated = { ...prev }; + delete updated[index]; + return updated; + }); + }; + + useEffect(() => { + if (show) { + setProductIds({ + 0: '', + }); + } + }, [show]); + + return ( + + + Add Product + +
+ + {Object.entries(productIds).map(([index, productId]) => ( + + Product {Number(index) + 1} PID +
+ + +
+
+ ))} + +
+ + + + +
+
+ ); +} diff --git a/src/styles/Brands.scss b/src/styles/Brands.scss index 0eaf72b..798c9b6 100644 --- a/src/styles/Brands.scss +++ b/src/styles/Brands.scss @@ -411,3 +411,12 @@ } } } + +#addProductForm { + .modal-body { + width: 400px; + display: flex; + flex-flow: column nowrap; + gap: 1rem; + } +}