✨ feat(user): Integrate subscription list into user management, update request parameters and types
This commit is contained in:
parent
cf5c39cfe5
commit
8d49daca21
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
import { Display } from '@/components/display';
|
import { Display } from '@/components/display';
|
||||||
import { ProTable, ProTableActions } from '@/components/pro-table';
|
import { ProTable, ProTableActions } from '@/components/pro-table';
|
||||||
|
import { getSubscribeList } from '@/services/admin/subscribe';
|
||||||
import { createUser, deleteUser, getUserList, updateUserBasicInfo } from '@/services/admin/user';
|
import { createUser, deleteUser, getUserList, updateUserBasicInfo } from '@/services/admin/user';
|
||||||
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { Badge } from '@workspace/ui/components/badge';
|
import { Badge } from '@workspace/ui/components/badge';
|
||||||
import { Button } from '@workspace/ui/components/button';
|
import { Button } from '@workspace/ui/components/button';
|
||||||
import { Switch } from '@workspace/ui/components/switch';
|
import { Switch } from '@workspace/ui/components/switch';
|
||||||
@ -20,8 +22,19 @@ export default function Page() {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const ref = useRef<ProTableActions>(null);
|
const ref = useRef<ProTableActions>(null);
|
||||||
|
|
||||||
|
const { data: subscribeList } = useQuery({
|
||||||
|
queryKey: ['getSubscribeList', 'all'],
|
||||||
|
queryFn: async () => {
|
||||||
|
const { data } = await getSubscribeList({
|
||||||
|
page: 1,
|
||||||
|
size: 9999,
|
||||||
|
});
|
||||||
|
return data.data?.list as API.SubscribeGroup[];
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ProTable<API.User, Record<string, unknown>>
|
<ProTable<API.User, API.GetUserListParams>
|
||||||
action={ref}
|
action={ref}
|
||||||
header={{
|
header={{
|
||||||
title: t('userList'),
|
title: t('userList'),
|
||||||
@ -132,13 +145,38 @@ export default function Page() {
|
|||||||
cell: ({ row }) => formatDate(row.getValue('created_at')),
|
cell: ({ row }) => formatDate(row.getValue('created_at')),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
request={async (pagination) => {
|
request={async (pagination, filter) => {
|
||||||
const { data } = await getUserList(pagination);
|
const { data } = await getUserList({
|
||||||
|
...pagination,
|
||||||
|
...filter,
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
list: data.data?.list || [],
|
list: data.data?.list || [],
|
||||||
total: data.data?.total || 0,
|
total: data.data?.total || 0,
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
params={[
|
||||||
|
{
|
||||||
|
key: 'subscribe_id',
|
||||||
|
placeholder: t('subscription'),
|
||||||
|
options: subscribeList?.map((item) => ({
|
||||||
|
label: item.name,
|
||||||
|
value: String(item.id),
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'search',
|
||||||
|
placeholder: 'Search',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'user_id',
|
||||||
|
placeholder: t('userId'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'user_subscribe_id',
|
||||||
|
placeholder: t('subscriptionId'),
|
||||||
|
},
|
||||||
|
]}
|
||||||
actions={{
|
actions={{
|
||||||
render: (row) => {
|
render: (row) => {
|
||||||
return [
|
return [
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
||||||
// API 更新时间:
|
// API 更新时间:
|
||||||
// API 唯一标识:
|
// API 唯一标识:
|
||||||
import * as ads from './ads';
|
import * as ads from './ads';
|
||||||
|
|||||||
6
apps/admin/services/admin/typings.d.ts
vendored
6
apps/admin/services/admin/typings.d.ts
vendored
@ -745,12 +745,18 @@ declare namespace API {
|
|||||||
page: number;
|
page: number;
|
||||||
size: number;
|
size: number;
|
||||||
search?: string;
|
search?: string;
|
||||||
|
user_id?: number;
|
||||||
|
subscribe_id?: number;
|
||||||
|
user_subscribe_id?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type GetUserListRequest = {
|
type GetUserListRequest = {
|
||||||
page: number;
|
page: number;
|
||||||
size: number;
|
size: number;
|
||||||
search?: string;
|
search?: string;
|
||||||
|
user_id?: number;
|
||||||
|
subscribe_id?: number;
|
||||||
|
user_subscribe_id?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type GetUserListResponse = {
|
type GetUserListResponse = {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
||||||
// API 更新时间:
|
// API 更新时间:
|
||||||
// API 唯一标识:
|
// API 唯一标识:
|
||||||
import * as auth from './auth';
|
import * as auth from './auth';
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
||||||
// API 更新时间:
|
// API 更新时间:
|
||||||
// API 唯一标识:
|
// API 唯一标识:
|
||||||
import * as auth from './auth';
|
import * as auth from './auth';
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
||||||
// API 更新时间:
|
// API 更新时间:
|
||||||
// API 唯一标识:
|
// API 唯一标识:
|
||||||
import * as announcement from './announcement';
|
import * as announcement from './announcement';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user