diff --git a/openbas-front/src/admin/components/scenarios/scenario/Index.tsx b/openbas-front/src/admin/components/scenarios/scenario/Index.tsx
index 381f7dfd0b..3b544aef5d 100644
--- a/openbas-front/src/admin/components/scenarios/scenario/Index.tsx
+++ b/openbas-front/src/admin/components/scenarios/scenario/Index.tsx
@@ -137,8 +137,8 @@ const IndexScenarioComponent: FunctionComponent<{ scenario: ScenarioStore }> = (
{!cronExpression && (
-
-
+ setOpenScenarioRecurringFormDialog(true)} style={{ marginRight: 5 }}>
+
)}
{cronExpression && !scenario.scenario_recurrence && (
diff --git a/openbas-front/src/admin/components/scenarios/scenario/ScenarioHeader.tsx b/openbas-front/src/admin/components/scenarios/scenario/ScenarioHeader.tsx
index e5750d98c5..f592ed15a0 100644
--- a/openbas-front/src/admin/components/scenarios/scenario/ScenarioHeader.tsx
+++ b/openbas-front/src/admin/components/scenarios/scenario/ScenarioHeader.tsx
@@ -138,7 +138,7 @@ const ScenarioHeader = ({
size="small"
onClick={() => setOpenScenarioRecurringFormDialog(true)}
>
- {t('Simulate Now')}
+ {t('Launch')}
)}
diff --git a/openbas-front/src/admin/components/scenarios/scenario/ScenarioRecurringFormDialog.tsx b/openbas-front/src/admin/components/scenarios/scenario/ScenarioRecurringFormDialog.tsx
index 1cc856b7a5..d9cc69d772 100644
--- a/openbas-front/src/admin/components/scenarios/scenario/ScenarioRecurringFormDialog.tsx
+++ b/openbas-front/src/admin/components/scenarios/scenario/ScenarioRecurringFormDialog.tsx
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react';
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, FormControl, FormControlLabel, InputLabel, MenuItem, Select, Stack, Switch } from '@mui/material';
-import { DateTimePicker, TimePicker } from '@mui/x-date-pickers';
+import { TimePicker, DateTimePicker } from '@mui/x-date-pickers';
import { Controller, useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { z } from 'zod';
@@ -103,16 +103,31 @@ const ScenarioRecurringFormDialog: React.FC = ({ onSubmit, selectRecurrin
},
).refine(
(data) => {
- if (data.endDate) {
- return new Date(data.endDate).getTime() > new Date(data.startDate).getTime();
+ if (['daily', 'weekly', 'monthly'].includes(selectRecurring)) {
+ if (data.endDate) {
+ return new Date(data.endDate).getTime() > new Date(data.startDate).getTime();
+ }
}
+
return true;
},
{
message: t('End date need to be stricly after start date'),
path: ['endDate'],
},
- ),
+ )
+ .refine(
+ (data) => {
+ if (data.startDate) {
+ return new Date(data.startDate).getTime() >= new Date(new Date().setUTCHours(0, 0, 0, 0)).getTime();
+ }
+ return true;
+ },
+ {
+ message: t('Start date should be at least today'),
+ path: ['startDate'],
+ },
+ ),
),
});
@@ -137,6 +152,7 @@ const ScenarioRecurringFormDialog: React.FC = ({ onSubmit, selectRecurrin
reset(defaultFormValues());
setOpen(false);
};
+
return (