|
|
@@ -4,12 +4,11 @@ import { Button } from '@/client/components/ui/button';
|
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/client/components/ui/card';
|
|
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/client/components/ui/table';
|
|
|
import { DataTablePagination } from '../components/DataTablePagination';
|
|
|
-import { Plus, Edit, Trash2, Calendar, Search, Filter, Power } from 'lucide-react';
|
|
|
+import { Plus, Edit, Trash2, Calendar, Search, Power } from 'lucide-react';
|
|
|
import { useState, useCallback } from 'react';
|
|
|
import { activityClient } from '@/client/api';
|
|
|
import type { InferResponseType, InferRequestType } from 'hono/client';
|
|
|
import { Input } from '@/client/components/ui/input';
|
|
|
-import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/client/components/ui/select';
|
|
|
import { Badge } from '@/client/components/ui/badge';
|
|
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/client/components/ui/dialog';
|
|
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from '@/client/components/ui/alert-dialog';
|
|
|
@@ -49,7 +48,6 @@ export const ActivitiesPage: React.FC = () => {
|
|
|
const [page, setPage] = useState(1);
|
|
|
const [pageSize, setPageSize] = useState(20);
|
|
|
const [keyword, setKeyword] = useState('');
|
|
|
- const [typeFilter, setTypeFilter] = useState<string>('all');
|
|
|
const [locationFilter, setLocationFilter] = useState<number | undefined>(undefined);
|
|
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
|
|
const [editingActivity, setEditingActivity] = useState<ActivityResponse | null>(null);
|
|
|
@@ -69,7 +67,7 @@ export const ActivitiesPage: React.FC = () => {
|
|
|
|
|
|
// 获取活动列表 - 使用RPC客户端
|
|
|
const { data, isLoading, error } = useQuery({
|
|
|
- queryKey: ['activities', page, pageSize, keyword, typeFilter, locationFilter],
|
|
|
+ queryKey: ['activities', page, pageSize, keyword, locationFilter],
|
|
|
queryFn: async () => {
|
|
|
const query: any = {
|
|
|
page,
|
|
|
@@ -81,9 +79,6 @@ export const ActivitiesPage: React.FC = () => {
|
|
|
}
|
|
|
|
|
|
const filters: any = {};
|
|
|
- if (typeFilter !== 'all') {
|
|
|
- filters.type = typeFilter;
|
|
|
- }
|
|
|
if (locationFilter) {
|
|
|
filters.venueLocationId = locationFilter;
|
|
|
}
|
|
|
@@ -221,7 +216,7 @@ export const ActivitiesPage: React.FC = () => {
|
|
|
<div>
|
|
|
<h1 className="text-3xl font-bold tracking-tight" data-testid="activity-management-title">活动管理</h1>
|
|
|
<p className="text-muted-foreground">
|
|
|
- 管理旅行活动,包括去程和返程活动
|
|
|
+ 管理旅行活动
|
|
|
</p>
|
|
|
</div>
|
|
|
<Button onClick={handleCreate} data-testid="create-activity-button">
|
|
|
@@ -250,18 +245,6 @@ export const ActivitiesPage: React.FC = () => {
|
|
|
data-testid="activity-search-input"
|
|
|
/>
|
|
|
</div>
|
|
|
- {/* 类型筛选 */}
|
|
|
- <Select value={typeFilter} onValueChange={setTypeFilter}>
|
|
|
- <SelectTrigger className="w-32" data-testid="activity-type-filter">
|
|
|
- <Filter className="h-4 w-4 mr-2" />
|
|
|
- <SelectValue placeholder="类型" />
|
|
|
- </SelectTrigger>
|
|
|
- <SelectContent>
|
|
|
- <SelectItem value="all">全部类型</SelectItem>
|
|
|
- <SelectItem value="departure">去程</SelectItem>
|
|
|
- <SelectItem value="return">返程</SelectItem>
|
|
|
- </SelectContent>
|
|
|
- </Select>
|
|
|
{/* 地点筛选 */}
|
|
|
<LocationSelect
|
|
|
value={locationFilter}
|
|
|
@@ -273,7 +256,7 @@ export const ActivitiesPage: React.FC = () => {
|
|
|
</CardHeader>
|
|
|
<CardContent>
|
|
|
{/* 筛选标签 */}
|
|
|
- {(keyword || typeFilter !== 'all' || locationFilter) && (
|
|
|
+ {(keyword || locationFilter) && (
|
|
|
<div className="flex flex-wrap gap-2 mb-4">
|
|
|
{keyword && (
|
|
|
<Badge variant="secondary" className="flex items-center gap-1">
|
|
|
@@ -290,17 +273,6 @@ export const ActivitiesPage: React.FC = () => {
|
|
|
</button>
|
|
|
</Badge>
|
|
|
)}
|
|
|
- {typeFilter !== 'all' && (
|
|
|
- <Badge variant="secondary" className="flex items-center gap-1">
|
|
|
- 类型: {typeFilter === 'departure' ? '去程' : '返程'}
|
|
|
- <button
|
|
|
- onClick={() => setTypeFilter('all')}
|
|
|
- className="ml-1 hover:text-red-500"
|
|
|
- >
|
|
|
- ×
|
|
|
- </button>
|
|
|
- </Badge>
|
|
|
- )}
|
|
|
{locationFilter && (
|
|
|
<Badge variant="secondary" className="flex items-center gap-1">
|
|
|
地点: {data?.data?.find((a: ActivityResponse) => a.venueLocationId === locationFilter)?.venueLocation?.name || '未知地点'}
|
|
|
@@ -320,7 +292,6 @@ export const ActivitiesPage: React.FC = () => {
|
|
|
<TableHeader>
|
|
|
<TableRow>
|
|
|
<TableHead>活动名称</TableHead>
|
|
|
- <TableHead>类型</TableHead>
|
|
|
<TableHead>举办地点</TableHead>
|
|
|
<TableHead>开始时间</TableHead>
|
|
|
<TableHead>结束时间</TableHead>
|
|
|
@@ -344,15 +315,6 @@ export const ActivitiesPage: React.FC = () => {
|
|
|
<span>{activity.name}</span>
|
|
|
</div>
|
|
|
</TableCell>
|
|
|
- <TableCell>
|
|
|
- <span className={`px-2 py-1 rounded-full text-xs ${
|
|
|
- activity.type === 'departure'
|
|
|
- ? 'bg-blue-100 text-blue-800'
|
|
|
- : 'bg-green-100 text-green-800'
|
|
|
- }`}>
|
|
|
- {activity.type === 'departure' ? '去程' : '返程'}
|
|
|
- </span>
|
|
|
- </TableCell>
|
|
|
<TableCell>
|
|
|
{activity.venueLocation ? (
|
|
|
<div className="flex flex-col">
|
|
|
@@ -417,7 +379,7 @@ export const ActivitiesPage: React.FC = () => {
|
|
|
))
|
|
|
) : (
|
|
|
<TableRow>
|
|
|
- <TableCell colSpan={7} className="text-center py-4">
|
|
|
+ <TableCell colSpan={6} className="text-center py-4">
|
|
|
暂无活动数据
|
|
|
</TableCell>
|
|
|
</TableRow>
|
|
|
@@ -455,7 +417,6 @@ export const ActivitiesPage: React.FC = () => {
|
|
|
id: editingActivity.id,
|
|
|
name: editingActivity.name,
|
|
|
description: editingActivity.description,
|
|
|
- type: editingActivity.type,
|
|
|
startDate: new Date(editingActivity.startDate),
|
|
|
endDate: new Date(editingActivity.endDate),
|
|
|
venueLocationId: editingActivity.venueLocationId,
|