From 1c6d6a16ef0a11fccc1e686dc3ee5b66c15d1257 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Tue, 26 Nov 2024 14:02:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E4=BE=9B=E5=BA=94=E5=95=86?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=88=97=E8=A1=A8=E5=A2=9E=E5=8A=A0=E5=88=86?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Conversations/Online/order/CustomerProfile.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/views/Conversations/Online/order/CustomerProfile.jsx b/src/views/Conversations/Online/order/CustomerProfile.jsx index 60df658..2534c52 100644 --- a/src/views/Conversations/Online/order/CustomerProfile.jsx +++ b/src/views/Conversations/Online/order/CustomerProfile.jsx @@ -211,6 +211,13 @@ const CustomerProfile = () => { ( Date: Tue, 26 Nov 2024 15:13:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E5=95=86=E4=B8=9A=E5=8F=B7=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=88=90=E5=8A=9F=E5=90=8E=E6=9B=B4=E6=96=B0=E5=88=B0?= =?UTF-8?q?=20store,=20storage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/AuthStore.js | 9 +++++- src/views/accounts/Profile.jsx | 55 +++++++++++++++++++++++----------- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/src/stores/AuthStore.js b/src/stores/AuthStore.js index b98e1a7..6325f46 100644 --- a/src/stores/AuthStore.js +++ b/src/stores/AuthStore.js @@ -173,6 +173,7 @@ const useAuthStore = create(devtools((set, get) => ({ }, setWhatsAppBusiness: async (userId, whatsAppBusiness) => { + const { loginUser, saveUserSession } = get() const postWABAUrl = `${API_HOST}/v2/set_whatsapp_info` const params = {opi_sn: userId, whatsapp_waba: whatsAppBusiness}; @@ -180,7 +181,13 @@ const useAuthStore = create(devtools((set, get) => ({ return fetchJSON(postWABAUrl, params) .then(json => { if (json.errcode === 0) { - console.info(json) + set(() => ({ + loginUser: { + ...loginUser, + whatsAppBusiness: whatsAppBusiness, + } + })) + saveUserSession() } else { throw new Error(json?.errmsg + ': ' + json.errcode) } diff --git a/src/views/accounts/Profile.jsx b/src/views/accounts/Profile.jsx index e121a28..bdc0875 100644 --- a/src/views/accounts/Profile.jsx +++ b/src/views/accounts/Profile.jsx @@ -1,9 +1,13 @@ -import { useEffect } from 'react' -import { Row, Col, Space, Descriptions, Avatar, Tag, Divider, List, Alert, Button, Flex, Select, Spin, Form, Typography, QRCode, Tooltip } from 'antd' +import { useEffect, useCallback } from 'react' +import { Row, Col, Space, Descriptions, Avatar, Tag, Divider, List, App, Button, Flex, Select, Spin, Form, Typography, QRCode, Tooltip } from 'antd' import { UserOutlined, InfoCircleOutlined, CloseCircleFilled, ReloadOutlined, CheckCircleFilled } from '@ant-design/icons' import useAuthStore from '@/stores/AuthStore' function Profile() { + + const { notification } = App.useApp() + const [wabaForm] = Form.useForm() + const [loginUser, setWhatsAppBusiness] = useAuthStore((state) => [state.loginUser, state.setWhatsAppBusiness]) useEffect(() => { @@ -12,6 +16,26 @@ function Profile() { // eslint-disable-next-line react-hooks/exhaustive-deps }, []) + const handelUpdateWABA = useCallback(() => { + console.info('handelUpdateWABA: %o', wabaForm.getFieldsValue()) + setWhatsAppBusiness(loginUser.userId, wabaForm.getFieldsValue().whatsAppBusiness) + .then(() => { + notification.info({ + message: 'Notification', + description: '商业号身份设置成功', + placement: 'top', + }) + }) + .catch(ex => { + notification.error({ + message: 'Notification', + description: ex.message, + placement: 'top', + duration: 4, + }) + }) + }, []) + const customStatusRender = (info) => { switch (info.status) { case 'expired': @@ -85,28 +109,27 @@ function Profile() { }>
- +