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/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 = () => { ( [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() { }>
- +