Skip to content

Commit

Permalink
Merge pull request #5279 from lovishduggal/fix/editor-workflow-digets…
Browse files Browse the repository at this point in the history
…-bug

fix: Fixed Visual Bug in Workflow Editor with Digests
  • Loading branch information
LetItRock authored Mar 18, 2024
2 parents bc338f9 + 77fb92c commit be23aa3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { DigestUnitEnum, MonthlyTypeEnum } from '@novu/shared';

import { colors } from '@novu/design-system';
import { pluralizeTime } from '../../../../utils';
import { useStepFormPath } from '../../hooks/useStepFormPath';

const Highlight = ({ children, isHighlight }) => {
const { colorScheme } = useMantineColorScheme();
Expand Down Expand Up @@ -61,13 +60,12 @@ const sortWeekdays = (weekdays: string[]): string[] => {
return weekdays.sort((a, b) => WEEKDAYS_ORDER.indexOf(a) - WEEKDAYS_ORDER.indexOf(b));
};

export const TimedDigestWillBeSentHeader = ({ isHighlight = true }: { isHighlight?: boolean }) => {
export const TimedDigestWillBeSentHeader = ({ path, isHighlight = true }: { path: string; isHighlight?: boolean }) => {
const { watch } = useFormContext();
const stepFormPath = useStepFormPath();

const unit = watch(`${stepFormPath}.digestMetadata.timed.unit`);
const unit = watch(`${path}.digestMetadata.timed.unit`);
if (unit == DigestUnitEnum.MINUTES) {
const amount = watch(`${stepFormPath}.digestMetadata.timed.minutes.amount`);
const amount = watch(`${path}.digestMetadata.timed.minutes.amount`);

return (
<>
Expand All @@ -77,7 +75,7 @@ export const TimedDigestWillBeSentHeader = ({ isHighlight = true }: { isHighligh
}

if (unit == DigestUnitEnum.HOURS) {
const amount = watch(`${stepFormPath}.digestMetadata.timed.hours.amount`);
const amount = watch(`${path}.digestMetadata.timed.hours.amount`);

return (
<>
Expand All @@ -87,8 +85,8 @@ export const TimedDigestWillBeSentHeader = ({ isHighlight = true }: { isHighligh
}

if (unit === DigestUnitEnum.DAYS) {
const amount = watch(`${stepFormPath}.digestMetadata.timed.days.amount`);
const atTime = watch(`${stepFormPath}.digestMetadata.timed.days.atTime`);
const amount = watch(`${path}.digestMetadata.timed.days.amount`);
const atTime = watch(`${path}.digestMetadata.timed.days.atTime`);

if (amount !== '' && amount !== '1') {
return (
Expand Down Expand Up @@ -118,9 +116,9 @@ export const TimedDigestWillBeSentHeader = ({ isHighlight = true }: { isHighligh
}

if (unit === DigestUnitEnum.WEEKS) {
const amount = watch(`${stepFormPath}.digestMetadata.timed.weeks.amount`);
const atTime = watch(`${stepFormPath}.digestMetadata.timed.weeks.atTime`);
const weekDays = watch(`${stepFormPath}.digestMetadata.timed.weeks.weekDays`) || [];
const amount = watch(`${path}.digestMetadata.timed.weeks.amount`);
const atTime = watch(`${path}.digestMetadata.timed.weeks.atTime`);
const weekDays = watch(`${path}.digestMetadata.timed.weeks.weekDays`) || [];

const weekDaysString =
weekDays?.length > 2
Expand Down Expand Up @@ -162,14 +160,14 @@ export const TimedDigestWillBeSentHeader = ({ isHighlight = true }: { isHighligh
);
}

const amount = watch(`${stepFormPath}.digestMetadata.timed.months.amount`);
const monthlyType = watch(`${stepFormPath}.digestMetadata.timed.months.monthlyType`);
const atTime = watch(`${stepFormPath}.digestMetadata.timed.months.atTime`);
const monthDays = watch(`${stepFormPath}.digestMetadata.timed.months.monthDays`) || [];
const amount = watch(`${path}.digestMetadata.timed.months.amount`);
const monthlyType = watch(`${path}.digestMetadata.timed.months.monthlyType`);
const atTime = watch(`${path}.digestMetadata.timed.months.atTime`);
const monthDays = watch(`${path}.digestMetadata.timed.months.monthDays`) || [];

if (monthlyType === MonthlyTypeEnum.ON) {
const ordinal = watch(`${stepFormPath}.digestMetadata.timed.months.ordinal`);
const ordinalValue = watch(`${stepFormPath}.digestMetadata.timed.months.ordinalValue`);
const ordinal = watch(`${path}.digestMetadata.timed.months.ordinal`);
const ordinalValue = watch(`${path}.digestMetadata.timed.months.ordinalValue`);

if (!ordinal || !ordinalValue) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const WillBeSentHeader = ({ path, isHighlight = true }: { path: string; i
const type = watch(`${path}.digestMetadata.type`);

if (type === DigestTypeEnum.TIMED) {
return <TimedDigestWillBeSentHeader isHighlight={isHighlight} />;
return <TimedDigestWillBeSentHeader path={path} isHighlight={isHighlight} />;
}

const unit = watch(`${path}.digestMetadata.regular.unit`);
Expand Down

0 comments on commit be23aa3

Please sign in to comment.