Merge remote-tracking branch 'origin/main'

2.0/email-builder
Lei OT 10 months ago
commit 38e3120d47

@ -173,6 +173,7 @@ const useAuthStore = create(devtools((set, get) => ({
}, },
setWhatsAppBusiness: async (userId, whatsAppBusiness) => { setWhatsAppBusiness: async (userId, whatsAppBusiness) => {
const { loginUser, saveUserSession } = get()
const postWABAUrl = `${API_HOST}/v2/set_whatsapp_info` const postWABAUrl = `${API_HOST}/v2/set_whatsapp_info`
const params = {opi_sn: userId, whatsapp_waba: whatsAppBusiness}; const params = {opi_sn: userId, whatsapp_waba: whatsAppBusiness};
@ -180,7 +181,13 @@ const useAuthStore = create(devtools((set, get) => ({
return fetchJSON(postWABAUrl, params) return fetchJSON(postWABAUrl, params)
.then(json => { .then(json => {
if (json.errcode === 0) { if (json.errcode === 0) {
console.info(json) set(() => ({
loginUser: {
...loginUser,
whatsAppBusiness: whatsAppBusiness,
}
}))
saveUserSession()
} else { } else {
throw new Error(json?.errmsg + ': ' + json.errcode) throw new Error(json?.errmsg + ': ' + json.errcode)
} }

@ -211,6 +211,13 @@ const CustomerProfile = () => {
<List <List
dataSource={otherEmailList} dataSource={otherEmailList}
pagination={
{
pageSize: 2,
showLessItems: true,
size: 'small'
}
}
renderItem={(email) => ( renderItem={(email) => (
<List.Item <List.Item
className='hover:bg-stone-50' className='hover:bg-stone-50'

@ -1,9 +1,13 @@
import { useEffect } from 'react' import { useEffect, useCallback } from 'react'
import { Row, Col, Space, Descriptions, Avatar, Tag, Divider, List, Alert, Button, Flex, Select, Spin, Form, Typography, QRCode, Tooltip } from 'antd' 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 { UserOutlined, InfoCircleOutlined, CloseCircleFilled, ReloadOutlined, CheckCircleFilled } from '@ant-design/icons'
import useAuthStore from '@/stores/AuthStore' import useAuthStore from '@/stores/AuthStore'
function Profile() { function Profile() {
const { notification } = App.useApp()
const [wabaForm] = Form.useForm()
const [loginUser, setWhatsAppBusiness] = useAuthStore((state) => [state.loginUser, state.setWhatsAppBusiness]) const [loginUser, setWhatsAppBusiness] = useAuthStore((state) => [state.loginUser, state.setWhatsAppBusiness])
useEffect(() => { useEffect(() => {
@ -12,6 +16,26 @@ function Profile() {
// eslint-disable-next-line react-hooks/exhaustive-deps // 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) => { const customStatusRender = (info) => {
switch (info.status) { switch (info.status) {
case 'expired': case 'expired':
@ -85,28 +109,27 @@ function Profile() {
}> }>
<Form <Form
layout='vertical' layout='vertical'
// form={form} form={wabaForm}
initialValues={{whatsAppBusiness: loginUser.whatsAppBusiness}}
> >
<Form.Item> <Form.Item name='whatsAppBusiness'>
<Select <Select
defaultValue='8617607730395'
options={[ options={[
{ {
value: '8618174165365', value: '+8617607730395',
label: 'GH 客服(8618174165365)', label: 'GH 顾问(+8617607730395)',
}, },
{ {
value: '8617607730395', value: '+8618174165365',
label: 'GH 顾问(8617607730395)', label: '国际事业部(+8618174165365)',
}, },
{ {
value: '191477856351', value: 'GH 客运',
label: 'GH 客运(191477856351)', label: 'GH 客运()',
}, },
{ {
value: '国际事业部', value: 'GH 客服',
label: '国际事业部(无)', label: 'GH 客服(无)',
disabled: true,
}, },
{ {
value: 'CT 事业部', value: 'CT 事业部',
@ -124,9 +147,7 @@ function Profile() {
<Form.Item> <Form.Item>
<Button <Button
type='primary' type='primary'
onClick={() => { onClick={handelUpdateWABA}>
setWhatsAppBusiness(383, 8617607730395)
}}>
保存 保存
</Button> </Button>
</Form.Item> </Form.Item>

Loading…
Cancel
Save