Skip to content

Commit

Permalink
Reduce creation proposal time
Browse files Browse the repository at this point in the history
  • Loading branch information
emmdim committed Feb 1, 2024
1 parent dad748d commit 26c79c3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 34 deletions.
8 changes: 4 additions & 4 deletions src/containers/configureCommunity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const ConfigureCommunity: React.FC<ConfigureCommunityProps> = ({
setValue('durationHours', '0');
setValue('durationMinutes', '0');
} else if (value === 0 && durationHours === '0') {
setValue('durationHours', MIN_DURATION_HOURS.toString());
// setValue('durationHours', MIN_DURATION_HOURS.toString());
}
trigger(['durationMinutes', 'durationHours', 'durationDays']);
onChange(e);
Expand All @@ -92,9 +92,9 @@ const ConfigureCommunity: React.FC<ConfigureCommunityProps> = ({
);
}
} else if (value === 0 && durationDays === '0') {
setValue('durationHours', MIN_DURATION_HOURS.toString());
setValue('durationMinutes', '0');
e.target.value = MIN_DURATION_HOURS.toString();
// setValue('durationHours', MIN_DURATION_HOURS.toString());
// setValue('durationMinutes', '0');
// e.target.value = MIN_DURATION_HOURS.toString();
}
trigger(['durationMinutes', 'durationHours', 'durationDays']);
onChange(e);
Expand Down
13 changes: 6 additions & 7 deletions src/containers/dateTimeSelector/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {DateInput, DropdownInput} from '@aragon/ods-old';
import {toDate} from 'date-fns-tz';
import format from 'date-fns/format';
import React, {useCallback, useMemo} from 'react';
import {Controller, useFormContext, useWatch} from 'react-hook-form';
import {useTranslation} from 'react-i18next';
Expand Down Expand Up @@ -148,19 +147,19 @@ const DateTimeSelector: React.FC<Props> = ({

validationTimeout = setTimeout(() => {
// automatically correct the end date to minimum
setValue('endDate', format(minEndDateTimeMills, 'yyyy-MM-dd'));
setValue('endTime', format(minEndDateTimeMills, 'HH:mm'));
setValue('endUtc', currTimezone);
// setValue('endDate', format(minEndDateTimeMills, 'yyyy-MM-dd'));
// setValue('endTime', format(minEndDateTimeMills, 'HH:mm'));
// setValue('endUtc', currTimezone);
}, CORRECTION_DELAY);
}

// end date past maximum duration
if (maxDurationMills !== 0 && endMills > maxEndDateTimeMills) {
validationTimeout = setTimeout(() => {
// automatically correct the end date to maximum
setValue('endDate', format(maxEndDateTimeMills, 'yyyy-MM-dd'));
setValue('endTime', format(maxEndDateTimeMills, 'HH:mm'));
setValue('endUtc', currTimezone);
// setValue('endDate', format(maxEndDateTimeMills, 'yyyy-MM-dd'));
// setValue('endTime', format(maxEndDateTimeMills, 'HH:mm'));
// setValue('endUtc', currTimezone);
}, CORRECTION_DELAY);
}

Expand Down
32 changes: 9 additions & 23 deletions src/containers/duration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const Duration: React.FC<Props> = ({
[daoMinDurationMills]
);

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const resetToMinDuration = useCallback(() => {
setValue('durationDays', minimums.days);
setValue('durationHours', minimums.hours);
Expand Down Expand Up @@ -97,8 +98,8 @@ const Duration: React.FC<Props> = ({
setValue('durationHours', '0');
setValue('durationMinutes', '0');
} else if (value <= minimums.days && durationLTMinimum(formDuration)) {
resetToMinDuration();
e.target.value = minimums.days.toString();
// resetToMinDuration();
// e.target.value = minimums.days.toString();
}
trigger(['durationMinutes', 'durationHours', 'durationDays']);
onChange(e);
Expand All @@ -108,7 +109,6 @@ const Duration: React.FC<Props> = ({
getValues,
maxDurationDays,
minimums.days,
resetToMinDuration,
setValue,
trigger,
]
Expand Down Expand Up @@ -143,20 +143,13 @@ const Duration: React.FC<Props> = ({
);
}
} else if (value <= minimums.hours && durationLTMinimum(formDuration)) {
resetToMinDuration();
e.target.value = minimums.hours.toString();
// resetToMinDuration();
// e.target.value = minimums.hours.toString();
}
trigger(['durationMinutes', 'durationHours', 'durationDays']);
onChange(e);
},
[
durationLTMinimum,
getValues,
minimums.hours,
resetToMinDuration,
setValue,
trigger,
]
[durationLTMinimum, getValues, minimums.hours, setValue, trigger]
);

const handleMinutesChanged = useCallback(
Expand Down Expand Up @@ -191,20 +184,13 @@ const Duration: React.FC<Props> = ({
setValue('durationHours', hours.toString());
e.target.value = mins.toString();
} else if (value <= minimums.minutes && durationLTMinimum(formDuration)) {
resetToMinDuration();
e.target.value = minimums.minutes.toString();
// resetToMinDuration();
// e.target.value = minimums.minutes.toString();
}
trigger(['durationMinutes', 'durationHours', 'durationDays']);
onChange(e);
},
[
durationLTMinimum,
getValues,
minimums.minutes,
resetToMinDuration,
setValue,
trigger,
]
[durationLTMinimum, getValues, minimums.minutes, setValue, trigger]
);

/*************************************************
Expand Down

0 comments on commit 26c79c3

Please sign in to comment.