-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(api,worker): skip sending messages outside of the subscribers schedule fixes NV-6618 #9126
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
LetItRock
merged 24 commits into
next
from
nv-6618-skip-messages-outside-of-the-subscribers-schedule
Sep 15, 2025
Merged
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
1039b96
feat(api-service): subscribers schedule api
LetItRock 8cc0e4a
Merge branch 'next' into nv-6614-subscribers-schedule-api
LetItRock 6b6a5ff
chore(api-service): remove unused import
LetItRock 4faf036
chore(api-service): fix function name
LetItRock fc0191a
feat(js): schedule sub module
LetItRock d9b463c
Merge branch 'next' into nv-6614-subscribers-schedule-api
LetItRock 592725e
chore(api-service): fixed failing unit tests
LetItRock f8f2a6d
Merge branch 'nv-6614-subscribers-schedule-api' into nv-6615-inbox-js…
LetItRock ae05b01
Merge branch 'next' into nv-6615-inbox-js-global-preference-schedule
LetItRock 4a3cd91
feat(js): inbox subscribers schedule
LetItRock 2ea98ee
Merge branch 'next' into nv-6615-inbox-js-global-preference-schedule
LetItRock fdd6624
Merge branch 'nv-6615-inbox-js-global-preference-schedule' into nv-66…
LetItRock 50414a9
chore(root): satisfy cspell
LetItRock d49cb44
feat(react,js): default schedule and useSchedule hook
LetItRock ee09c0f
feat(dashboard): allow updating subscribers schedule
LetItRock 1377585
Merge branch 'next' into nv-6616-inbox-schedule
LetItRock a19b983
Merge branch 'nv-6616-inbox-schedule' into nv-6616-react-use-schedule…
LetItRock 90f7cc7
Merge branch 'nv-6616-react-use-schedule-and-default-schedule' into n…
LetItRock cf683a8
chore(dashboard): remove console.log
LetItRock 02969f9
Merge branch 'next' into nv-6617-dashboard-subscribers-schedule
LetItRock c277fb9
chore(dashboard): suggestions from the pr
LetItRock a3e2d61
feat(api,worker): skip sending messages outside of the subscribers sc…
LetItRock 81ea9d0
Merge branch 'next' into nv-6617-dashboard-subscribers-schedule
LetItRock 7bbd110
Merge branch 'nv-6617-dashboard-subscribers-schedule' into nv-6618-sk…
LetItRock 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
120 changes: 120 additions & 0 deletions
120
apps/dashboard/src/components/subscribers/preferences/day-schedule-copy.tsx
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,120 @@ | ||
| import { ScheduleDto } from '@novu/api/models/components'; | ||
| import { Schedule, WeeklySchedule } from '@novu/shared'; | ||
| import { useCallback, useMemo, useState } from 'react'; | ||
| import { RiFileCopyLine } from 'react-icons/ri'; | ||
| import { Button } from '@/components/primitives/button'; | ||
| import { Checkbox } from '@/components/primitives/checkbox'; | ||
| import { Popover, PopoverContent, PopoverTrigger } from '@/components/primitives/popover'; | ||
| import { capitalize } from '@/utils/string'; | ||
| import { cn } from '@/utils/ui'; | ||
| import { Tooltip, TooltipContent, TooltipTrigger } from '../../primitives/tooltip'; | ||
| import { weekDays } from './utils'; | ||
|
|
||
| type DayScheduleCopyProps = { | ||
| onScheduleUpdate: (schedule: ScheduleDto) => Promise<void>; | ||
| day: keyof WeeklySchedule; | ||
| schedule?: Schedule | undefined; | ||
| disabled?: boolean; | ||
| }; | ||
|
|
||
| export const DayScheduleCopy = ({ day, schedule, disabled, onScheduleUpdate }: DayScheduleCopyProps) => { | ||
| const [isOpen, setIsOpen] = useState<boolean>(false); | ||
| const [selectedDays, setSelectedDays] = useState<Array<keyof WeeklySchedule>>([day]); | ||
| const [isAllSelected, setIsAllSelected] = useState<boolean>(false); | ||
| const allWeekDaysSelected = useMemo(() => selectedDays.length === weekDays.length, [selectedDays]); | ||
| const reset = useCallback(() => { | ||
| setSelectedDays([day]); | ||
| setIsAllSelected(false); | ||
| setIsOpen(false); | ||
| }, [day]); | ||
| const onOpenChange = useCallback( | ||
| (isOpen: boolean) => { | ||
| if (!isOpen) { | ||
| reset(); | ||
| } else { | ||
| setIsOpen(isOpen); | ||
| } | ||
| }, | ||
| [reset] | ||
| ); | ||
|
|
||
| return ( | ||
| <Tooltip> | ||
| <TooltipTrigger disabled={disabled}> | ||
| <Popover modal open={isOpen} onOpenChange={onOpenChange}> | ||
| <PopoverTrigger disabled={disabled} className="w-full flex items-center justify-center"> | ||
| <RiFileCopyLine | ||
| className={cn( | ||
| 'text-foreground-alpha-600 size-3.5 group-hover:opacity-100 opacity-0 transition-opacity duration-200', | ||
| { | ||
| 'group-hover:opacity-0': disabled, | ||
| } | ||
| )} | ||
| /> | ||
| </PopoverTrigger> | ||
| <PopoverContent | ||
| side="right" | ||
| sideOffset={0} | ||
| align="center" | ||
| className="rounded-md min-w-[220px] max-w-[220px] p-1" | ||
| onClick={(e) => { | ||
| e.preventDefault(); | ||
| e.stopPropagation(); | ||
| }} | ||
| > | ||
| <p className="text-sm text-neutral-600 mb-3 text-left">Copy times to:</p> | ||
| <span className="flex items-center gap-2 text-sm text-neutral-600 mb-2"> | ||
| <Checkbox | ||
| checked={isAllSelected || allWeekDaysSelected} | ||
| onCheckedChange={(checked) => { | ||
| if (typeof checked !== 'boolean') return; | ||
| setIsAllSelected(checked); | ||
| setSelectedDays(checked ? weekDays : [day]); | ||
| }} | ||
| /> | ||
| Select all | ||
| </span> | ||
| {weekDays.map((weekDay) => ( | ||
| <span key={weekDay} className="flex items-center gap-2 text-sm text-neutral-600 mb-2"> | ||
| <Checkbox | ||
| checked={selectedDays.includes(weekDay) || weekDay === day} | ||
| onCheckedChange={(value) => | ||
| setSelectedDays(value ? [...selectedDays, weekDay] : selectedDays.filter((d) => d !== weekDay)) | ||
| } | ||
| disabled={weekDay === day} | ||
| /> | ||
| {capitalize(weekDay)} | ||
| </span> | ||
| ))} | ||
| <div className="flex justify-end border-t border-neutral-alpha-100 pt-2"> | ||
| <Button | ||
| onClick={async () => { | ||
| const currentDay = day; | ||
| const daysToCopy = selectedDays.filter((day) => day !== currentDay); | ||
| const dayToCopy = schedule?.weeklySchedule?.[currentDay]; | ||
| if (dayToCopy) { | ||
| const updatedWeeklySchedule = { | ||
| ...schedule?.weeklySchedule, | ||
| ...daysToCopy.reduce((acc, day) => { | ||
| acc[day] = dayToCopy; | ||
| return acc; | ||
| }, {} as WeeklySchedule), | ||
| }; | ||
| await onScheduleUpdate({ | ||
| isEnabled: schedule?.isEnabled ?? false, | ||
| weeklySchedule: updatedWeeklySchedule, | ||
| }); | ||
| } | ||
| reset(); | ||
| }} | ||
| > | ||
| Apply | ||
| </Button> | ||
| </div> | ||
| </PopoverContent> | ||
| </Popover> | ||
| </TooltipTrigger> | ||
| <TooltipContent>Copy times to</TooltipContent> | ||
| </Tooltip> | ||
| ); | ||
| }; |
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
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.
moved to the application-generic