mirror of
https://github.com/baptisteArno/typebot.io.git
synced 2026-06-19 21:04:33 +08:00
🚸 Persist time filter state in URL in results tab
This commit is contained in:
parent
8ea15d5bb8
commit
39a1408ffb
@ -29,22 +29,31 @@
|
||||
"@trpc/next": "10.45.2",
|
||||
"@trpc/react-query": "10.45.2",
|
||||
"@trpc/server": "10.45.2",
|
||||
"@typebot.io/blocks-bubbles": "workspace:*",
|
||||
"@typebot.io/blocks-core": "workspace:*",
|
||||
"@typebot.io/blocks-inputs": "workspace:*",
|
||||
"@typebot.io/blocks-integrations": "workspace:*",
|
||||
"@typebot.io/blocks-logic": "workspace:*",
|
||||
"@typebot.io/bot-engine": "workspace:*",
|
||||
"@typebot.io/chat-session": "workspace:*",
|
||||
"@typebot.io/conditions": "workspace:*",
|
||||
"@typebot.io/credentials": "workspace:*",
|
||||
"@typebot.io/emails": "workspace:*",
|
||||
"@typebot.io/env": "workspace:*",
|
||||
"@typebot.io/events": "workspace:*",
|
||||
"@typebot.io/groups": "workspace:*",
|
||||
"@typebot.io/js": "workspace:*",
|
||||
"@typebot.io/logs": "workspace:*",
|
||||
"@typebot.io/nextjs": "workspace:*",
|
||||
"@typebot.io/settings": "workspace:*",
|
||||
"@typebot.io/theme": "workspace:*",
|
||||
"@typebot.io/transactional": "workspace:*",
|
||||
"@typebot.io/trpc-openapi": "workspace:*",
|
||||
"@typebot.io/typebot": "workspace:*",
|
||||
"@typebot.io/whatsapp": "workspace:*",
|
||||
"@typebot.io/ui": "workspace:*",
|
||||
"@typebot.io/chat-session": "workspace:*",
|
||||
"@typebot.io/logs": "workspace:*",
|
||||
"@typebot.io/whatsapp": "workspace:*",
|
||||
"@typebot.io/workspaces": "workspace:*",
|
||||
"@typebot.io/zod": "workspace:*",
|
||||
"@udecode/plate-basic-marks": "30.5.3",
|
||||
"@udecode/plate-common": "30.4.5",
|
||||
"@udecode/plate-core": "30.4.5",
|
||||
@ -56,9 +65,12 @@
|
||||
"@uiw/react-codemirror": "4.21.24",
|
||||
"@upstash/ratelimit": "0.4.3",
|
||||
"@use-gesture/react": "10.2.27",
|
||||
"ai": "4.1.15",
|
||||
"browser-image-compression": "2.0.2",
|
||||
"canvas-confetti": "1.6.0",
|
||||
"codemirror": "6.0.1",
|
||||
"date-fns": "2.30.0",
|
||||
"date-fns-tz": "2.0.0",
|
||||
"deep-object-diff": "1.1.9",
|
||||
"dequal": "2.0.3",
|
||||
"emojilib": "3.0.10",
|
||||
@ -75,7 +87,7 @@
|
||||
"nextjs-cors": "2.1.2",
|
||||
"nodemailer": "6.9.15",
|
||||
"nprogress": "0.2.0",
|
||||
"nuqs": "^1.19.3",
|
||||
"nuqs": "^2.3.2",
|
||||
"openai": "4.81.0",
|
||||
"papaparse": "5.4.1",
|
||||
"partysocket": "1.0.2",
|
||||
@ -93,21 +105,9 @@
|
||||
"tinycolor2": "1.6.0",
|
||||
"unsplash-js": "7.0.18",
|
||||
"use-debounce": "9.0.4",
|
||||
"zod-validation-error": "3.4.0",
|
||||
"zustand": "4.5.0",
|
||||
"@typebot.io/workspaces": "workspace:*",
|
||||
"@typebot.io/blocks-integrations": "workspace:*",
|
||||
"@typebot.io/groups": "workspace:*",
|
||||
"@typebot.io/zod": "workspace:*",
|
||||
"@typebot.io/settings": "workspace:*",
|
||||
"@typebot.io/js": "workspace:*",
|
||||
"@typebot.io/conditions": "workspace:*",
|
||||
"@typebot.io/blocks-bubbles": "workspace:*",
|
||||
"@typebot.io/events": "workspace:*",
|
||||
"zod": "3.23.8",
|
||||
"ai": "4.1.15",
|
||||
"date-fns": "2.30.0",
|
||||
"date-fns-tz": "2.0.0"
|
||||
"zod-validation-error": "3.4.0",
|
||||
"zustand": "4.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "1.45.2",
|
||||
|
||||
@ -2,7 +2,7 @@ import { Seo } from "@/components/Seo";
|
||||
import { AnalyticsGraphContainer } from "@/features/analytics/components/AnalyticsGraphContainer";
|
||||
import {
|
||||
defaultTimeFilter,
|
||||
type timeFilterValues,
|
||||
timeFilterValues,
|
||||
} from "@/features/analytics/constants";
|
||||
import { TypebotHeader } from "@/features/editor/components/TypebotHeader";
|
||||
import { TypebotNotFoundPage } from "@/features/editor/components/TypebotNotFoundPage";
|
||||
@ -20,7 +20,8 @@ import {
|
||||
} from "@chakra-ui/react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useQueryState } from "nuqs";
|
||||
import { useMemo } from "react";
|
||||
import { ResultsProvider } from "../ResultsProvider";
|
||||
import { ResultsTableContainer } from "./ResultsTableContainer";
|
||||
|
||||
@ -38,8 +39,16 @@ export const ResultsPage = () => {
|
||||
router.pathname.endsWith("analytics") ? "#f4f5f8" : "white",
|
||||
router.pathname.endsWith("analytics") ? "gray.900" : "gray.950",
|
||||
);
|
||||
const [timeFilter, setTimeFilter] =
|
||||
useState<(typeof timeFilterValues)[number]>(defaultTimeFilter);
|
||||
const [timeFilter, setTimeFilter] = useQueryState<
|
||||
(typeof timeFilterValues)[number]
|
||||
>("timeFilter", {
|
||||
defaultValue: defaultTimeFilter,
|
||||
parse: (val) => {
|
||||
if (timeFilterValues.includes(val as (typeof timeFilterValues)[number]))
|
||||
return val as (typeof timeFilterValues)[number];
|
||||
return null;
|
||||
},
|
||||
});
|
||||
|
||||
const {
|
||||
data: { stats } = {},
|
||||
@ -91,7 +100,16 @@ export const ResultsPage = () => {
|
||||
colorScheme={!isAnalytics ? "orange" : "gray"}
|
||||
variant={!isAnalytics ? "outline" : "ghost"}
|
||||
size="sm"
|
||||
href={`/typebots/${typebot?.id}/results`}
|
||||
href={{
|
||||
pathname: "/typebots/[typebotId]/results",
|
||||
query: {
|
||||
typebotId: publishedTypebot?.typebotId,
|
||||
timeFilter:
|
||||
timeFilter && timeFilter !== defaultTimeFilter
|
||||
? timeFilter
|
||||
: undefined,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Text>Submissions</Text>
|
||||
{(stats?.totalStarts ?? 0) > 0 && (
|
||||
@ -104,7 +122,16 @@ export const ResultsPage = () => {
|
||||
as={Link}
|
||||
colorScheme={isAnalytics ? "orange" : "gray"}
|
||||
variant={isAnalytics ? "outline" : "ghost"}
|
||||
href={`/typebots/${typebot?.id}/results/analytics`}
|
||||
href={{
|
||||
pathname: "/typebots/[typebotId]/results/analytics",
|
||||
query: {
|
||||
typebotId: publishedTypebot?.typebotId,
|
||||
timeFilter:
|
||||
timeFilter && timeFilter !== defaultTimeFilter
|
||||
? timeFilter
|
||||
: undefined,
|
||||
},
|
||||
}}
|
||||
size="sm"
|
||||
>
|
||||
Analytics
|
||||
|
||||
@ -19,6 +19,7 @@ import "@/assets/styles/routerProgressBar.css";
|
||||
import "@/assets/styles/plate.css";
|
||||
import "@/assets/styles/resultsTable.css";
|
||||
import "@/assets/styles/custom.css";
|
||||
import { NuqsAdapter } from "nuqs/adapters/next/pages";
|
||||
import { Toaster } from "sonner";
|
||||
|
||||
const { ToastContainer, toast } = createStandaloneToast(customTheme);
|
||||
@ -57,22 +58,23 @@ const App = ({ Component, pageProps }: AppProps) => {
|
||||
|
||||
return (
|
||||
<TolgeeProvider tolgee={ssrTolgee}>
|
||||
<ToastContainer />
|
||||
<ChakraProvider theme={customTheme}>
|
||||
<Toaster offset={24} position="top-right" />
|
||||
<SessionProvider session={pageProps.session}>
|
||||
<UserProvider>
|
||||
<TypebotProvider typebotId={typebotId}>
|
||||
<WorkspaceProvider typebotId={typebotId}>
|
||||
<Component {...pageProps} />
|
||||
{!router.pathname.endsWith("edit") && isCloudProdInstance() && (
|
||||
<SupportBubble />
|
||||
)}
|
||||
</WorkspaceProvider>
|
||||
</TypebotProvider>
|
||||
</UserProvider>
|
||||
</SessionProvider>
|
||||
</ChakraProvider>
|
||||
<NuqsAdapter>
|
||||
<ToastContainer />
|
||||
<ChakraProvider theme={customTheme}>
|
||||
<Toaster offset={24} position="top-right" />
|
||||
<SessionProvider session={pageProps.session}>
|
||||
<UserProvider>
|
||||
<TypebotProvider typebotId={typebotId}>
|
||||
<WorkspaceProvider typebotId={typebotId}>
|
||||
<Component {...pageProps} />
|
||||
{!router.pathname.endsWith("edit") &&
|
||||
isCloudProdInstance() && <SupportBubble />}
|
||||
</WorkspaceProvider>
|
||||
</TypebotProvider>
|
||||
</UserProvider>
|
||||
</SessionProvider>
|
||||
</ChakraProvider>
|
||||
</NuqsAdapter>
|
||||
</TolgeeProvider>
|
||||
);
|
||||
};
|
||||
|
||||
16
yarn.lock
16
yarn.lock
@ -1,6 +1,6 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
# bun ./bun.lockb --hash: 9466C2599366FAA0-5dd6468fb1f960db-DB649CF63EAF77B7-e209365ef5d5cce2
|
||||
# bun ./bun.lockb --hash: 60076E2239452BF7-501ca8e3a13d16c9-77427B9CE7857D67-376434de1d26e1ae
|
||||
|
||||
|
||||
"@ai-sdk/anthropic@1.1.6":
|
||||
@ -10548,7 +10548,7 @@ buffer-from@^1.0.0:
|
||||
nextjs-cors "2.1.2"
|
||||
nodemailer "6.9.15"
|
||||
nprogress "0.2.0"
|
||||
nuqs "^1.19.3"
|
||||
nuqs "^2.3.2"
|
||||
openai "4.81.0"
|
||||
papaparse "5.4.1"
|
||||
partysocket "1.0.2"
|
||||
@ -17855,7 +17855,7 @@ netmask@^2.0.2:
|
||||
resolved "https://registry.npmjs.org/netmask/-/netmask-2.0.2.tgz"
|
||||
integrity sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==
|
||||
|
||||
"next@12.x || 13.x || 14.x", next@14.2.13, "next@>=13.4 <14.0.2 || ^14.0.3", "next@^12.2.5 || ^13 || ^14":
|
||||
"next@12.x || 13.x || 14.x", next@14.2.13, "next@^12.2.5 || ^13 || ^14":
|
||||
version "14.2.13"
|
||||
resolved "https://registry.npmjs.org/next/-/next-14.2.13.tgz"
|
||||
integrity sha512-BseY9YNw8QJSwLYD7hlZzl6QVDoSFHL/URN5K64kVEVpCsSOWeyjbIGK+dZUaRViHTaMQX8aqmnn0PHBbGZezg==
|
||||
@ -18152,10 +18152,10 @@ nth-check@^2.0.0, nth-check@^2.0.1:
|
||||
dependencies:
|
||||
boolbase "^1.0.0"
|
||||
|
||||
nuqs@^1.19.3:
|
||||
version "1.20.0"
|
||||
resolved "https://registry.npmjs.org/nuqs/-/nuqs-1.20.0.tgz"
|
||||
integrity sha512-nGVfv7eWMNxAzOJ9n8ARTo6ObqeEr1ETYZ+dIMCg/VfGUoZoPrqyTOndIvQIgUzK3pIC41mTXg10JJxh9ziEhw==
|
||||
nuqs@^2.3.2:
|
||||
version "2.3.2"
|
||||
resolved "https://registry.npmjs.org/nuqs/-/nuqs-2.3.2.tgz"
|
||||
integrity sha512-WeG78r8e3a30JY3P8npldvNiAZwGIk499lnpeRs3UYA3PpSvs2/PLunKGgjuF/JMw4BOowD3K2xgGEOZ3PeODA==
|
||||
dependencies:
|
||||
mitt "^3.0.1"
|
||||
|
||||
@ -19276,7 +19276,7 @@ rc9@^2.1.2:
|
||||
defu "^6.1.4"
|
||||
destr "^2.0.3"
|
||||
|
||||
react@*, "react@16.10.2 - 18", react@18.2.0, react@18.x, "react@>= 16.8.0", "react@>= 16.8.0 || 17.x.x || ^18.0.0-0", "react@>= 16.8.0 || 17.x.x || ^18.0.0-0 || ^19.0.0-0", "react@>= 18", react@>=16, react@>=16.14.0, react@>=16.6.0, react@>=16.8, react@>=16.8.1, "react@>=16.x <=18.x", react@>=18, "react@>=18.0.0 || >=19.0.0", react@>=18.2.0, "react@^15.5.4 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react@^16.0.0 || ^17.0.0 || ^18.0.0", "react@^16.11.0 || ^17.0.0 || ^18.0.0", "react@^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react@^16.14.0 || 17.x || 18.x || 19.x", "react@^16.14.0 || ^17.0.1 || ^18.1.0", "react@^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react@^16.8.0 || ^17.0.0 || ^18.0.0", "react@^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react@^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc", "react@^16.8.4 || ^17.0.0 || ^18.0.0", "react@^17.0.2 || ^18", "react@^18.0 || ^19.0 || ^19.0.0-rc", react@^18.2.0, "react@^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0":
|
||||
react@*, "react@16.10.2 - 18", react@18.2.0, react@18.x, "react@>= 16.8.0", "react@>= 16.8.0 || 17.x.x || ^18.0.0-0", "react@>= 16.8.0 || 17.x.x || ^18.0.0-0 || ^19.0.0-0", "react@>= 18", react@>=16, react@>=16.14.0, react@>=16.6.0, react@>=16.8, react@>=16.8.1, "react@>=16.x <=18.x", react@>=18, "react@>=18.0.0 || >=19.0.0", react@>=18.2.0, "react@>=18.2.0 || ^19.0.0-0", "react@^15.5.4 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react@^16.0.0 || ^17.0.0 || ^18.0.0", "react@^16.11.0 || ^17.0.0 || ^18.0.0", "react@^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react@^16.14.0 || 17.x || 18.x || 19.x", "react@^16.14.0 || ^17.0.1 || ^18.1.0", "react@^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react@^16.8.0 || ^17.0.0 || ^18.0.0", "react@^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react@^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc", "react@^16.8.4 || ^17.0.0 || ^18.0.0", "react@^17.0.2 || ^18", "react@^18.0 || ^19.0 || ^19.0.0-rc", react@^18.2.0, "react@^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0":
|
||||
version "18.2.0"
|
||||
resolved "https://registry.npmjs.org/react/-/react-18.2.0.tgz"
|
||||
integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==
|
||||
|
||||
Loading…
Reference in New Issue
Block a user