|
|
@@ -4,7 +4,7 @@ import { Button } from '@d8d/shared-ui-components/components/ui/button';
|
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@d8d/shared-ui-components/components/ui/card';
|
|
|
import { Plus } from 'lucide-react';
|
|
|
import { useState } from 'react';
|
|
|
-import { areaClient } from '../api/areaClient';
|
|
|
+import { areaClient, areaClientManager } from '../api/areaClient';
|
|
|
import type { InferResponseType, InferRequestType } from 'hono/client';
|
|
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@d8d/shared-ui-components/components/ui/dialog';
|
|
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from '@d8d/shared-ui-components/components/ui/alert-dialog';
|
|
|
@@ -56,7 +56,7 @@ export const AreaManagement: React.FC = () => {
|
|
|
const { data: provinceData, isLoading: isProvinceLoading } = useQuery({
|
|
|
queryKey: ['areas-tree-province'],
|
|
|
queryFn: async () => {
|
|
|
- const res = await areaClient.index.$get({
|
|
|
+ const res = await areaClientManager.get().index.$get({
|
|
|
query: {
|
|
|
page: 1,
|
|
|
pageSize: 100 ,
|
|
|
@@ -77,7 +77,7 @@ export const AreaManagement: React.FC = () => {
|
|
|
const createMutation = useMutation({
|
|
|
mutationFn: async (data: CreateAreaRequest) => {
|
|
|
await handleOperation(async () => {
|
|
|
- const res = await areaClient.index.$post({ json: data });
|
|
|
+ const res = await areaClientManager.get().index.$post({ json: data });
|
|
|
if (res.status !== 201) throw new Error('创建省市区失败');
|
|
|
});
|
|
|
},
|
|
|
@@ -111,7 +111,7 @@ export const AreaManagement: React.FC = () => {
|
|
|
const updateMutation = useMutation({
|
|
|
mutationFn: async ({ id, data }: { id: number; data: UpdateAreaRequest }) => {
|
|
|
await handleOperation(async () => {
|
|
|
- const res = await areaClient[':id'].$put({
|
|
|
+ const res = await areaClientManager.get()[':id'].$put({
|
|
|
param: { id },
|
|
|
json: data
|
|
|
});
|
|
|
@@ -142,7 +142,7 @@ export const AreaManagement: React.FC = () => {
|
|
|
const deleteMutation = useMutation({
|
|
|
mutationFn: async (id: number) => {
|
|
|
await handleOperation(async () => {
|
|
|
- const res = await areaClient[':id'].$delete({
|
|
|
+ const res = await areaClientManager.get()[':id'].$delete({
|
|
|
param: { id }
|
|
|
});
|
|
|
if (res.status !== 204) throw new Error('删除省市区失败');
|
|
|
@@ -172,7 +172,7 @@ export const AreaManagement: React.FC = () => {
|
|
|
const toggleStatusMutation = useMutation({
|
|
|
mutationFn: async ({ id, isDisabled }: { id: number; isDisabled: number }) => {
|
|
|
await handleOperation(async () => {
|
|
|
- const res = await areaClient[':id'].$put({
|
|
|
+ const res = await areaClientManager.get()[':id'].$put({
|
|
|
param: { id },
|
|
|
json: { isDisabled }
|
|
|
});
|