|
3 | 3 | import { useFormState } from "react-dom";
|
4 | 4 | import { useFlags } from "flagsmith/react";
|
5 | 5 |
|
6 |
| -import config from "@/config/app.json"; |
7 | 6 | import { saveSettings } from "./action";
|
8 | 7 | import { SubmitButton } from "@/components/forms/SubmitButton";
|
9 | 8 | import Input from "@/components/forms/Input";
|
10 | 9 | import Checkbox from "@/components/forms/Checkbox";
|
| 10 | +import Select from "@/components/forms/Select"; |
11 | 11 |
|
12 | 12 | const initialState = {
|
13 |
| - data: undefined, |
| 13 | + ignore: undefined, |
14 | 14 | success: undefined,
|
15 | 15 | errors: undefined,
|
16 | 16 | };
|
17 | 17 |
|
18 |
| -export default function Form({ id, data, disabled = false }) { |
| 18 | +export default function Form({ id, ignore, schedule, disabled = false }) { |
19 | 19 | let { optionalchecks } = useFlags(["optionalchecks"]);
|
20 | 20 | optionalchecks = JSON.parse(optionalchecks.value);
|
21 | 21 | const [state, formAction] = useFormState(saveSettings, initialState);
|
22 | 22 |
|
23 | 23 | return (
|
24 | 24 | <form action={formAction}>
|
25 | 25 | <Input type="hidden" id="id" name="id" value={id} />
|
26 |
| - <div className="space-y-12"> |
27 |
| - <div className="border-b border-gray-900/10 pb-12"> |
| 26 | + |
| 27 | + <div className="border-b border-gray-700 pb-12 pt-4"> |
| 28 | + <div className="border-b border-gray-900/10"> |
28 | 29 | <p className="mt-1 text-sm leading-6 text-gray-300">
|
29 |
| - Hide any checks you wish to ignore. |
| 30 | + What checks do you wish to ignore from your report? |
30 | 31 | </p>
|
31 | 32 | </div>
|
| 33 | + |
| 34 | + <fieldset> |
| 35 | + <legend className="text-sm font-semibold leading-6"> |
| 36 | + Hide these checks |
| 37 | + </legend> |
| 38 | + {optionalchecks?.map((option) => ( |
| 39 | + <div className="mt-2" key={option.id}> |
| 40 | + <Checkbox |
| 41 | + id={option.id} |
| 42 | + name={option.id} |
| 43 | + text={option.name} |
| 44 | + value={true} |
| 45 | + disabled={disabled} |
| 46 | + defaultChecked={ignore.includes(option.id)} |
| 47 | + /> |
| 48 | + </div> |
| 49 | + ))} |
| 50 | + </fieldset> |
32 | 51 | </div>
|
33 | 52 |
|
34 |
| - <fieldset> |
35 |
| - <legend className="text-sm font-semibold leading-6">Checks</legend> |
36 |
| - {optionalchecks?.map((option) => ( |
37 |
| - <div className="mt-6 space-y-6" key={option.id}> |
| 53 | + <div className="border-b border-gray-700 pb-12 pt-4"> |
| 54 | + <fieldset className="mb-6"> |
| 55 | + <legend className="text-sm font-semibold leading-6">Automate</legend> |
| 56 | + <div className="mt-2"> |
38 | 57 | <Checkbox
|
39 |
| - id={option.id} |
40 |
| - name={option.id} |
41 |
| - text={option.name} |
| 58 | + id="schedule" |
| 59 | + name="schedule" |
| 60 | + text="Schedule" |
42 | 61 | value={true}
|
43 |
| - disabled={disabled} |
44 |
| - defaultChecked={data.includes(option.id)} |
| 62 | + disabled={true} |
| 63 | + defaultChecked={true} |
45 | 64 | />
|
46 | 65 | </div>
|
47 |
| - ))} |
48 |
| - </fieldset> |
| 66 | + </fieldset> |
| 67 | + <fieldset> |
| 68 | + <legend className="text-sm font-semibold leading-6">Frequency</legend> |
| 69 | + <div className="mt-2"> |
| 70 | + <Select |
| 71 | + id="schedule" |
| 72 | + name="schedule" |
| 73 | + text="How often to perform these checks? (days)" |
| 74 | + options={[ |
| 75 | + { text: "1 day", value: 1 }, |
| 76 | + { text: "7 days", value: 7 }, |
| 77 | + { text: "30 days", value: 30 }, |
| 78 | + ]} |
| 79 | + value={7} |
| 80 | + disabled={true} |
| 81 | + // defaultChecked={schedule} |
| 82 | + classNameSelect="max-w-32" |
| 83 | + /> |
| 84 | + </div> |
| 85 | + </fieldset> |
| 86 | + </div> |
49 | 87 |
|
50 | 88 | <div className="mt-6 flex items-center justify-end gap-x-6">
|
51 | 89 | <SubmitButton text="SAVE" />
|
|
0 commit comments