feat(web): user info api update
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @Author: ZhaoYing
|
||||
* @Date: 2026-02-03 14:00:06
|
||||
* @Last Modified by: ZhaoYing
|
||||
* @Last Modified time: 2026-03-19 18:35:10
|
||||
* @Last Modified time: 2026-03-24 17:48:01
|
||||
*/
|
||||
import { request } from '@/utils/request'
|
||||
import type { AxiosRequestConfig } from 'axios'
|
||||
@@ -87,12 +87,13 @@ export const getUserSummary = (end_user_id: string) => {
|
||||
export const getNodeStatistics = (end_user_id: string) => {
|
||||
return request.get(`/memory-storage/analytics/node_statistics`, { end_user_id })
|
||||
}
|
||||
// Basic information
|
||||
export const getEndUserProfile = (end_user_id: string) => {
|
||||
return request.get(`/memory-storage/read_end_user/profile`, { end_user_id })
|
||||
// 查询用户别名及信息
|
||||
export const getEndUserInfo = (end_user_id: string) => {
|
||||
return request.get(`/memory-storage/end_user_info`, { end_user_id })
|
||||
}
|
||||
export const updatedEndUserProfile = (values: EndUser) => {
|
||||
return request.post(`/memory-storage/updated_end_user/profile`, values)
|
||||
// 更新用户别名及信息
|
||||
export const updatedEndUserInfo = (values: EndUser) => {
|
||||
return request.post(`/memory-storage/end_user_info/updated`, values)
|
||||
}
|
||||
// User Memory - Relationship network
|
||||
export const getMemorySearchEdges = (end_user_id: string, config?: AxiosRequestConfig) => {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: ZhaoYing
|
||||
* @Date: 2026-02-03 18:33:30
|
||||
* @Last Modified by: ZhaoYing
|
||||
* @Last Modified time: 2026-02-11 14:51:00
|
||||
* @Last Modified time: 2026-03-24 17:55:02
|
||||
*/
|
||||
/**
|
||||
* End User Profile Component
|
||||
@@ -18,7 +18,7 @@ import clsx from 'clsx'
|
||||
|
||||
import RbCard from '@/components/RbCard/Card'
|
||||
import {
|
||||
getEndUserProfile,
|
||||
getEndUserInfo,
|
||||
} from '@/api/memory'
|
||||
import EndUserProfileModal from './EndUserProfileModal'
|
||||
import type { EndUser, EndUserProfileModalRef, EndUserProfileRef } from '../types'
|
||||
@@ -31,7 +31,7 @@ interface EndUserProfileProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const EndUserProfile = forwardRef<EndUserProfileRef, EndUserProfileProps>(({ onDataLoaded, className }, ref) => {
|
||||
const EndUserProfile = forwardRef<EndUserProfileRef, EndUserProfileProps>(({ className }, ref) => {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams()
|
||||
const endUserProfileModalRef = useRef<EndUserProfileModalRef>(null)
|
||||
@@ -47,13 +47,9 @@ const EndUserProfile = forwardRef<EndUserProfileRef, EndUserProfileProps>(({ onD
|
||||
const getData = () => {
|
||||
if (!id) return
|
||||
setLoading(true)
|
||||
getEndUserProfile(id).then((res) => {
|
||||
getEndUserInfo(id).then((res) => {
|
||||
const userData = res as EndUser
|
||||
setData(userData)
|
||||
onDataLoaded?.({
|
||||
other_name: userData.other_name,
|
||||
id: userData.id
|
||||
})
|
||||
setLoading(false)
|
||||
})
|
||||
.finally(() => {
|
||||
@@ -62,10 +58,10 @@ const EndUserProfile = forwardRef<EndUserProfileRef, EndUserProfileProps>(({ onD
|
||||
}
|
||||
/** Format profile items for display */
|
||||
const formatItems = useCallback(() => {
|
||||
return ['other_name', 'position', 'department', 'contact', 'phone', 'hire_date'].map(key => ({
|
||||
return ['other_name'].map(key => ({
|
||||
key,
|
||||
label: t(`userMemory.${key}`),
|
||||
children: key === 'hire_date' && data?.[key] ? dayjs(data[key as keyof EndUser]).format('YYYY-MM-DD') : String(data?.[key as keyof EndUser] || '-'),
|
||||
children: String(data?.[key as keyof EndUser] || '-'),
|
||||
}))
|
||||
}, [data])
|
||||
/** Open edit modal */
|
||||
@@ -102,7 +98,7 @@ const EndUserProfile = forwardRef<EndUserProfileRef, EndUserProfileProps>(({ onD
|
||||
))}
|
||||
|
||||
<div className="rb:text-[#7B8085] rb:text-[12px] rb:leading-4.5">
|
||||
{t('userMemory.updated_at')}: {data?.updatetime_profile ? dayjs(data?.updatetime_profile).format('YYYY/MM/DD HH:mm:ss') : ''}
|
||||
{t('userMemory.updated_at')}: {data?.updated_at ? dayjs(data?.updated_at).format('YYYY/MM/DD HH:mm:ss') : ''}
|
||||
</div>
|
||||
</Flex>
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* @Author: ZhaoYing
|
||||
* @Date: 2026-02-03 18:33:21
|
||||
* @Last Modified by: ZhaoYing
|
||||
* @Last Modified time: 2026-02-03 18:33:21
|
||||
* @Last Modified by: ZhaoYing
|
||||
* @Last Modified time: 2026-03-24 17:58:43
|
||||
*/
|
||||
/**
|
||||
* End User Profile Modal
|
||||
@@ -10,13 +10,12 @@
|
||||
*/
|
||||
|
||||
import { forwardRef, useImperativeHandle, useState } from 'react';
|
||||
import { Form, Input, App, DatePicker } from 'antd';
|
||||
import { Form, Input, App } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import type { EndUser, EndUserProfileModalRef } from '../types'
|
||||
import RbModal from '@/components/RbModal'
|
||||
import { updatedEndUserProfile, } from '@/api/memory'
|
||||
import { updatedEndUserInfo } from '@/api/memory'
|
||||
|
||||
const FormItem = Form.Item;
|
||||
|
||||
@@ -35,6 +34,7 @@ const EndUserProfileModal = forwardRef<EndUserProfileModalRef, EndUserProfileMod
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [form] = Form.useForm<EndUser>();
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [editVo, setEditVo] = useState<EndUser | null>(null)
|
||||
|
||||
const values = Form.useWatch([], form);
|
||||
|
||||
@@ -47,11 +47,8 @@ const EndUserProfileModal = forwardRef<EndUserProfileModalRef, EndUserProfileMod
|
||||
|
||||
/** Open modal with user data */
|
||||
const handleOpen = (user: EndUser) => {
|
||||
form.setFieldsValue({
|
||||
...user,
|
||||
end_user_id: user.id,
|
||||
hire_date: user.hire_date ? dayjs(user.hire_date) : undefined
|
||||
});
|
||||
setEditVo(user)
|
||||
form.setFieldsValue(user);
|
||||
setVisible(true);
|
||||
};
|
||||
/** Save profile changes */
|
||||
@@ -60,9 +57,10 @@ const EndUserProfileModal = forwardRef<EndUserProfileModalRef, EndUserProfileMod
|
||||
.validateFields()
|
||||
.then(() => {
|
||||
setLoading(true)
|
||||
updatedEndUserProfile({
|
||||
updatedEndUserInfo({
|
||||
...editVo,
|
||||
...values,
|
||||
hire_date: values.hire_date?.valueOf() || null
|
||||
// hire_date: values.hire_date?.valueOf() || null
|
||||
})
|
||||
.then(() => {
|
||||
setLoading(false)
|
||||
@@ -105,7 +103,7 @@ const EndUserProfileModal = forwardRef<EndUserProfileModalRef, EndUserProfileMod
|
||||
>
|
||||
<Input placeholder={t('common.enter')} />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
{/* <FormItem
|
||||
name="position"
|
||||
label={t('userMemory.position')}
|
||||
>
|
||||
@@ -134,7 +132,7 @@ const EndUserProfileModal = forwardRef<EndUserProfileModalRef, EndUserProfileMod
|
||||
label={t('userMemory.hire_date')}
|
||||
>
|
||||
<DatePicker className="rb:w-full" allowClear />
|
||||
</FormItem>
|
||||
</FormItem> */}
|
||||
</Form>
|
||||
</RbModal>
|
||||
);
|
||||
|
||||
@@ -2,15 +2,13 @@
|
||||
* @Author: ZhaoYing
|
||||
* @Date: 2026-02-03 17:57:15
|
||||
* @Last Modified by: ZhaoYing
|
||||
* @Last Modified time: 2026-03-13 11:49:52
|
||||
* @Last Modified time: 2026-03-24 17:58:54
|
||||
*/
|
||||
/**
|
||||
* User Memory Detail Types
|
||||
* Type definitions for user memory detail views including nodes, edges, and statistics
|
||||
*/
|
||||
|
||||
import type { Dayjs } from "dayjs";
|
||||
|
||||
/**
|
||||
* User memory data structure
|
||||
*/
|
||||
@@ -171,15 +169,13 @@ export interface NodeStatisticsItem {
|
||||
* End user profile
|
||||
*/
|
||||
export interface EndUser {
|
||||
end_user_id: string;
|
||||
id: string;
|
||||
other_name: string;
|
||||
position: string;
|
||||
department: string;
|
||||
contact: string;
|
||||
phone: string;
|
||||
hire_date: string | number | Dayjs | null;
|
||||
updatetime_profile?: number;
|
||||
aliases: string | null;
|
||||
meta_data: Record<string, string>;
|
||||
end_user_info_id: string;
|
||||
end_user_id: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
/**
|
||||
* End user profile modal ref
|
||||
|
||||
Reference in New Issue
Block a user