|
1 | 1 | "use client"; |
2 | 2 |
|
3 | 3 | import { useReactTable, getCoreRowModel, getSortedRowModel, createColumnHelper } from "@tanstack/react-table"; |
| 4 | +import { useSearchParams } from "next/navigation"; |
4 | 5 | import { useMemo, useRef } from "react"; |
5 | 6 |
|
6 | 7 | import { WipeMyCalActionButton } from "@calcom/app-store/wipemycalother/components"; |
@@ -44,34 +45,6 @@ type RecurringInfo = { |
44 | 45 | bookings: { [key: string]: Date[] }; |
45 | 46 | }; |
46 | 47 |
|
47 | | -const tabs: (VerticalTabItemProps | HorizontalTabItemProps)[] = [ |
48 | | - { |
49 | | - name: "upcoming", |
50 | | - href: "/bookings/upcoming", |
51 | | - "data-testid": "upcoming", |
52 | | - }, |
53 | | - { |
54 | | - name: "unconfirmed", |
55 | | - href: "/bookings/unconfirmed", |
56 | | - "data-testid": "unconfirmed", |
57 | | - }, |
58 | | - { |
59 | | - name: "recurring", |
60 | | - href: "/bookings/recurring", |
61 | | - "data-testid": "recurring", |
62 | | - }, |
63 | | - { |
64 | | - name: "past", |
65 | | - href: "/bookings/past", |
66 | | - "data-testid": "past", |
67 | | - }, |
68 | | - { |
69 | | - name: "cancelled", |
70 | | - href: "/bookings/cancelled", |
71 | | - "data-testid": "cancelled", |
72 | | - }, |
73 | | -]; |
74 | | - |
75 | 48 | const descriptionByStatus: Record<BookingListingStatus, string> = { |
76 | 49 | upcoming: "upcoming_bookings", |
77 | 50 | recurring: "recurring_bookings", |
@@ -107,6 +80,46 @@ function BookingsContent({ status }: BookingsProps) { |
107 | 80 | const { t } = useLocale(); |
108 | 81 | const user = useMeQuery().data; |
109 | 82 | const tableContainerRef = useRef<HTMLDivElement>(null); |
| 83 | + const searchParams = useSearchParams(); |
| 84 | + |
| 85 | + // Generate dynamic tabs that preserve query parameters |
| 86 | + const tabs: (VerticalTabItemProps | HorizontalTabItemProps)[] = useMemo(() => { |
| 87 | + const queryString = searchParams?.toString() || ""; |
| 88 | + |
| 89 | + const baseTabConfigs = [ |
| 90 | + { |
| 91 | + name: "upcoming", |
| 92 | + path: "/bookings/upcoming", |
| 93 | + "data-testid": "upcoming", |
| 94 | + }, |
| 95 | + { |
| 96 | + name: "unconfirmed", |
| 97 | + path: "/bookings/unconfirmed", |
| 98 | + "data-testid": "unconfirmed", |
| 99 | + }, |
| 100 | + { |
| 101 | + name: "recurring", |
| 102 | + path: "/bookings/recurring", |
| 103 | + "data-testid": "recurring", |
| 104 | + }, |
| 105 | + { |
| 106 | + name: "past", |
| 107 | + path: "/bookings/past", |
| 108 | + "data-testid": "past", |
| 109 | + }, |
| 110 | + { |
| 111 | + name: "cancelled", |
| 112 | + path: "/bookings/cancelled", |
| 113 | + "data-testid": "cancelled", |
| 114 | + }, |
| 115 | + ]; |
| 116 | + |
| 117 | + return baseTabConfigs.map((tabConfig) => ({ |
| 118 | + name: tabConfig.name, |
| 119 | + href: queryString ? `${tabConfig.path}?${queryString}` : tabConfig.path, |
| 120 | + "data-testid": tabConfig["data-testid"], |
| 121 | + })); |
| 122 | + }, [searchParams?.toString()]); |
110 | 123 |
|
111 | 124 | const eventTypeIds = useFilterValue("eventTypeId", ZMultiSelectFilterValue)?.data as number[] | undefined; |
112 | 125 | const teamIds = useFilterValue("teamId", ZMultiSelectFilterValue)?.data as number[] | undefined; |
|
0 commit comments