-
Notifications
You must be signed in to change notification settings - Fork 12k
feat: allow to choose dateTarget for /insights (startTime by default) #23752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
40667a9
feat: allow to choose dateTarget for /insights (startTime by default)
eunjae-lee 12c3716
feat: add timestamp selector for insights date filtering
devin-ai-integration[bot] 0b37a6d
refactor: rename TimestampFilter to DateTargetSelector with nuqs URL …
devin-ai-integration[bot] 6ec24e3
update styles
eunjae-lee 3496840
fix inconsistency
eunjae-lee d5658f3
feat: replace Select with Command component and rename filter ID
devin-ai-integration[bot] 3c74364
fix: revert routing components to use createdAt filter ID
devin-ai-integration[bot] af86d1f
update styles
eunjae-lee f7ad9ba
fix trpc router
eunjae-lee 1e68d15
refactor timestamp column for insights booking service
eunjae-lee 81c502e
Merge branch 'main' into feat/date-target-insights
eunjae-lee 1766e1a
fix
eunjae-lee 711a6fa
update text
eunjae-lee 8430ba3
rename and clean up
eunjae-lee 474020f
Merge branch 'main' into feat/date-target-insights
eunjae-lee 6c737c5
fix endDate in DateRangeFilter
eunjae-lee 40edfb6
fix type errors
eunjae-lee 725123c
Merge branch 'main' into feat/date-target-insights
eunjae-lee a9be43a
fix startTime filter and type errors
eunjae-lee 29abbb2
provide default date range
eunjae-lee ad9955c
add completed to getMembersStatsWithCount
eunjae-lee c4074c9
Merge branch 'main' into feat/date-target-insights
eunjae-lee bdc0573
add unit tests
eunjae-lee b604ce5
Merge branch 'main' into feat/date-target-insights
eunjae-lee 5d195b7
fix type error
eunjae-lee 5b234b2
address feedback
eunjae-lee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 4 additions & 12 deletions
16
packages/features/data-table/hooks/useChangeTimeZoneWithPreservedLocalTime.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,20 @@ | ||
| import { useMemo } from "react"; | ||
|
|
||
| import dayjs from "@calcom/dayjs"; | ||
| import { CURRENT_TIMEZONE } from "@calcom/lib/timezoneConstants"; | ||
|
|
||
| import { preserveLocalTime } from "../lib/preserveLocalTime"; | ||
| import { useDataTable } from "./useDataTable"; | ||
|
|
||
| /** | ||
| * Converts a timestamp to maintain the same local time in a different timezone. | ||
| * | ||
| * For example, if it's midnight (00:00) in Paris time: | ||
| * - Input : "2025-05-22T22:00:00.000Z" (Midnight/00:00 in Paris) | ||
| * - Output: "2025-05-22T15:00:00.000Z" (Midnight/00:00 in Seoul) | ||
| * | ||
| * This ensures that times like midnight (00:00) or end of day (23:59) | ||
| * remain at those exact local times when converting between timezones. | ||
| * The output timestamp is based on the timezone in the user's profile settings. | ||
| * Fore more info, read packages/features/data-table/lib/preserveLocalTime.ts | ||
| */ | ||
| export function useChangeTimeZoneWithPreservedLocalTime(isoString: string) { | ||
| const { timeZone: profileTimeZone } = useDataTable(); | ||
| return useMemo(() => { | ||
| const currentTimeZone = dayjs.tz.guess(); | ||
| if (!profileTimeZone || currentTimeZone === profileTimeZone) { | ||
| if (!profileTimeZone || CURRENT_TIMEZONE === profileTimeZone) { | ||
| return isoString; | ||
| } | ||
| return preserveLocalTime(isoString, currentTimeZone, profileTimeZone); | ||
| return preserveLocalTime(isoString, CURRENT_TIMEZONE, profileTimeZone); | ||
| }, [isoString, profileTimeZone]); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import { useState } from "react"; | ||
|
|
||
| import { useLocale } from "@calcom/lib/hooks/useLocale"; | ||
| import { Button } from "@calcom/ui/components/button"; | ||
| import { Command, CommandList, CommandItem } from "@calcom/ui/components/command"; | ||
| import { Icon } from "@calcom/ui/components/icon"; | ||
| import { Popover, PopoverTrigger, PopoverContent } from "@calcom/ui/components/popover"; | ||
|
|
||
| export type DateTarget = "startTime" | "createdAt"; | ||
|
|
||
| interface DateTargetOption { | ||
| label: string; | ||
| description: string; | ||
| value: DateTarget; | ||
| } | ||
|
|
||
| interface DateTargetSelectorProps { | ||
| value: DateTarget; | ||
| onChange: (value: DateTarget) => void; | ||
| } | ||
|
|
||
| export const DateTargetSelector = ({ value, onChange }: DateTargetSelectorProps) => { | ||
| const { t } = useLocale(); | ||
| const [open, setOpen] = useState(false); | ||
|
|
||
| const options: DateTargetOption[] = [ | ||
| { | ||
| label: t("booking_time_option"), | ||
| description: t("booking_time_option_description"), | ||
| value: "startTime", | ||
| }, | ||
| { | ||
| label: t("created_at_option"), | ||
| description: t("created_at_option_description"), | ||
| value: "createdAt", | ||
| }, | ||
| ]; | ||
|
|
||
| const selectedOption = options.find((option) => option.value === value) || options[0]; | ||
|
|
||
| return ( | ||
| <Popover open={open} onOpenChange={setOpen}> | ||
| <PopoverTrigger asChild> | ||
| <Button | ||
| variant="icon" | ||
| color="secondary" | ||
| StartIcon="sliders-horizontal" | ||
| role="combobox" | ||
| aria-expanded={open}> | ||
| <span className="sr-only">{selectedOption.label}</span> | ||
| </Button> | ||
| </PopoverTrigger> | ||
| <PopoverContent className="w-64 p-0" align="end"> | ||
| <Command> | ||
| <CommandList> | ||
| {options.map((option) => ( | ||
| <CommandItem | ||
| key={option.value} | ||
| onSelect={() => { | ||
| onChange(option.value); | ||
| setOpen(false); | ||
| }} | ||
| className="flex items-center gap-2 px-4 py-3"> | ||
| <div> | ||
| <div className="font-medium">{option.label}</div> | ||
| <div className="text-muted-foreground text-sm">{option.description}</div> | ||
| </div> | ||
| {selectedOption.label === option.label && ( | ||
| <Icon name="check" className="text-primary-foreground h-4 w-4" /> | ||
| )} | ||
| </CommandItem> | ||
| ))} | ||
| </CommandList> | ||
| </Command> | ||
| </PopoverContent> | ||
| </Popover> | ||
| ); | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would value comparision make more sense here?