From 0083f0311aeb2153b4516f0f721a780e1b29f3d0 Mon Sep 17 00:00:00 2001 From: suyiiyii Date: Sun, 22 Sep 2024 17:59:01 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=94=AF=E6=8C=81=E5=88=A0?= =?UTF-8?q?=E9=99=A4=20CookieTarget?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CookieTargetManager.tsx | 53 +++++++++---------- .../cookieTargetManager/CookieTargetModal.tsx | 21 ++++---- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/admin-frontend/src/features/cookieTargetManager/CookieTargetManager.tsx b/admin-frontend/src/features/cookieTargetManager/CookieTargetManager.tsx index c3b2296..c632f2f 100644 --- a/admin-frontend/src/features/cookieTargetManager/CookieTargetManager.tsx +++ b/admin-frontend/src/features/cookieTargetManager/CookieTargetManager.tsx @@ -1,7 +1,7 @@ import React, { useState } from 'react'; import { useParams } from 'react-router-dom'; import { - Button, Empty, Space, Table, Typography, + Button, Space, Table, Typography, } from '@arco-design/web-react'; import { useDeleteCookieTargetMutation, useGetCookieTargetsQuery } from '../cookieManager/cookieConfigSlice'; import { CookieTarget } from '../../utils/type'; @@ -11,11 +11,12 @@ export default function () { const { cookieId } = useParams(); const { data: cookieTargets } = useGetCookieTargetsQuery(cookieId); - console.log(cookieTargets); const [showModal, setShowModal] = useState(false); const [deleteCookieTarget] = useDeleteCookieTargetMutation(); const handleAdd = () => { + console.log('before', showModal); setShowModal(true); + console.log('after', showModal); }; const handleDelete = (record: CookieTarget) => () => { deleteCookieTarget({ @@ -49,31 +50,25 @@ export default function () { }, ]; - if (cookieId) { - return ( - <> - - {`Cookie ${cookieId}`} - - - `${record.target.platform_name}-${record.target.target}`} - scroll={{ x: true }} - /> - { - cookieTargets && cookieTargets.length > 0 - && ( - - ) - } - - ); - } - return ; + + return ( + <> + + {`Cookie ${cookieId}`} + + +
`${record.target.platform_name}-${record.target.target}`} + scroll={{ x: true }} + /> + + + ); } diff --git a/admin-frontend/src/features/cookieTargetManager/CookieTargetModal.tsx b/admin-frontend/src/features/cookieTargetManager/CookieTargetModal.tsx index 607ed66..18ebef6 100644 --- a/admin-frontend/src/features/cookieTargetManager/CookieTargetModal.tsx +++ b/admin-frontend/src/features/cookieTargetManager/CookieTargetModal.tsx @@ -1,22 +1,25 @@ import React from 'react'; import { Modal, Select } from '@arco-design/web-react'; -import { SubscribeGroupDetail } from '../../utils/type'; +import { SubscribeConfig, SubscribeGroupDetail } from '../../utils/type'; import { useNewCookieTargetMutation } from '../cookieManager/cookieConfigSlice'; import { useGetSubsQuery } from '../subsribeConfigManager/subscribeConfigSlice'; interface SubscribeModalProp { + cookieId: number; visible: boolean; setVisible: (arg0: boolean) => void; - cookieId: number; } -export default function ({ visible, setVisible, cookieId }: SubscribeModalProp) { +export default function ({ cookieId, visible, setVisible }: SubscribeModalProp) { const [newCookieTarget] = useNewCookieTargetMutation(); const { data: subs } = useGetSubsQuery(); - const pureSubs = subs ? Object.values(subs) - .reduce((pv:Array, cv:SubscribeGroupDetail) => pv.concat(cv.subscribes), []) : []; + const pureSubs:SubscribeConfig[] = subs ? Object.values(subs) + .reduce(( + pv:Array, + cv:SubscribeGroupDetail, + ) => pv.concat(cv.subscribes), []) : []; const [index, setIndex] = React.useState(-1); const handleSubmit = (idx:number) => { const postPromise: ReturnType = newCookieTarget({ @@ -40,18 +43,16 @@ export default function ({ visible, setVisible, cookieId }: SubscribeModalProp) placeholder="选择要关联的 target" style={{ width: '100%' }} onChange={setIndex} - > - { - pureSubs.map((sub, idx) => ( + {pureSubs.length + && pureSubs.map((sub, idx) => ( - )) - } + ))}