Skip to content
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

Nv 2239 validation minmax and default values for #3380

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions apps/web/src/pages/templates/workflow/DigestMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { WillBeSentHeader } from './digest/WillBeSentHeader';
import { ScheduleMonthlyFields } from './digest/ScheduleMonthlyFields';
import { useEffect } from 'react';
import { RegularInfo } from './digest/RegularInfo';
import { format } from 'date-fns';

const convertUnitToLabel = (unit: DigestUnitEnum) => {
switch (unit) {
Expand Down Expand Up @@ -275,12 +276,12 @@ export const DigestMetadata = ({ control, index, readonly }) => {
<Controller
control={control}
name={`steps.${index}.metadata.amount`}
defaultValue=""
defaultValue={1}
render={({ field, fieldState }) => {
return (
<Input
{...field}
value={field.value || '1'}
value={field.value}
error={showErrors && fieldState.error?.message}
min={1}
max={100}
Expand All @@ -305,7 +306,7 @@ export const DigestMetadata = ({ control, index, readonly }) => {
<Controller
control={control}
name={`steps.${index}.metadata.timed.atTime`}
defaultValue=""
defaultValue={format(new Date(), 'HH:mm')}
render={({ field, fieldState }) => {
return (
<Input
Expand Down Expand Up @@ -336,7 +337,7 @@ export const DigestMetadata = ({ control, index, readonly }) => {
<Controller
control={control}
name={`steps.${index}.metadata.timed.weekDays`}
defaultValue=""
defaultValue={[format(new Date(), 'EEEE').toLowerCase()]}
render={({ field }) => {
return (
<WeekDaySelect
Expand All @@ -359,7 +360,7 @@ export const DigestMetadata = ({ control, index, readonly }) => {
<Controller
control={control}
name={`steps.${index}.metadata.amount`}
defaultValue=""
defaultValue={5}
render={({ field, fieldState }) => {
return (
<Input
Expand Down
10 changes: 9 additions & 1 deletion apps/web/src/pages/templates/workflow/digest/IntervalSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ const options = [
{ value: DigestUnitEnum.DAYS, label: 'day (s)' },
];

export const IntervalSelect = ({ control, name, showErrors, readonly, testId = 'time-unit' }) => {
export const IntervalSelect = ({
control,
name,
showErrors,
readonly,
testId = 'time-unit',
defaultValue = DigestUnitEnum.MINUTES,
}) => {
return (
<Controller
control={control}
name={name}
defaultValue={defaultValue}
render={({ field, fieldState }) => {
return (
<Select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DigestUnitEnum, OrdinalEnum, OrdinalValueEnum, MonthlyTypeEnum } from '
import { When } from '../../../../components/utils/When';
import { colors, Select } from '../../../../design-system';
import { DaySelect } from './DaySelect';
import { format } from 'date-fns';

export const ScheduleMonthlyFields = ({ index, control, readonly }) => {
const { watch, trigger } = useFormContext();
Expand Down Expand Up @@ -33,7 +34,7 @@ export const ScheduleMonthlyFields = ({ index, control, readonly }) => {
<Controller
control={control}
name={`steps.${index}.metadata.timed.monthDays`}
defaultValue=""
defaultValue={[new Date().getDay()]}
render={({ field }) => {
return (
<DaySelect
Expand Down