Skip to content

Commit

Permalink
web/satellite: prevent setting past expiration date in create AG flow
Browse files Browse the repository at this point in the history
Added logic to handle possible user error when they try to set past expiration date in create AG flow.

Change-Id: Idceb36d6492299c2092afcc32fb2ce507ae983b4
  • Loading branch information
VitaliiShpital authored and Storj Robot committed Apr 16, 2024
1 parent 60353b1 commit 9585685
Showing 1 changed file with 17 additions and 1 deletion.
Expand Up @@ -215,9 +215,13 @@ import { AccessGrantEndDate, Permission } from '@/types/createAccessGrant';
import { useBucketsStore } from '@/store/modules/bucketsStore';
import { SHORT_MONTHS_NAMES } from '@/utils/constants/date';
import { ValidationRule, RequiredRule, DialogStepComponent } from '@/types/common';
import { AnalyticsErrorEventSource } from '@/utils/constants/analyticsEventNames';
import { useNotify } from '@/utils/hooks';
type EndDateListItem = AccessGrantEndDate | { divider: true };
const notify = useNotify();
const allPermissions: Permission[] = [
Permission.Read,
Permission.Write,
Expand Down Expand Up @@ -323,9 +327,21 @@ function onDatePickerSubmit(): void {
if (!datePickerModel.value) return;
const date = datePickerModel.value;
const submitted = new Date(
date.getFullYear(),
date.getMonth(),
date.getDate(),
11, 59, 59,
);
if (submitted.getTime() < new Date().getTime()) {
notify.error('Please select future date', AnalyticsErrorEventSource.CREATE_AG_MODAL);
return;
}
endDate.value = {
title: `${date.getDate()} ${SHORT_MONTHS_NAMES[date.getMonth()]} ${date.getFullYear()}`,
date: new Date(date.getFullYear(), date.getMonth(), date.getDate(), 11, 59, 59),
date: submitted,
};
isDatePicker.value = false;
Expand Down

0 comments on commit 9585685

Please sign in to comment.