Skip to content

Commit 335cd7d

Browse files
committed
[fix] Refactors event forms to improve title field handling
Updates the `EventEditor` and `NewForm` components by moving the title input field to a consistent position within the forms. The title field is now rendered after the type dropdown in the `NewForm`, enhancing user experience by maintaining a clear structure. Redundant code for the type dropdown in `EventEditor` has been removed to streamline the component.
1 parent c13a38d commit 335cd7d

2 files changed

Lines changed: 25 additions & 23 deletions

File tree

src/Components/Event/EventEditor.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@ export function EventEditor({ Event }: { Event: Models.IEvent }) {
4040
class="absolute"
4141
onScale-before-close={(e) => e.preventDefault()}
4242
>
43+
44+
<ScaleDropdownSelect
45+
label="Type"
46+
value={State.type}
47+
disabled={!IsIncident(Event.Type)}
48+
onScale-change={(e) => Actions.setType(e.target.value as EventType)}
49+
invalid={!!Validation.type}
50+
helperText={Validation.type}
51+
>
52+
{Object.values(EventType).slice(2, 5).map((type, i) =>
53+
<ScaleDropdownSelectItem value={type} key={i}>
54+
{type}
55+
</ScaleDropdownSelectItem>)}
56+
</ScaleDropdownSelect>
57+
4358
<form
4459
className="flex flex-col gap-y-6"
4560
autoComplete="off"
@@ -57,20 +72,6 @@ export function EventEditor({ Event }: { Event: Models.IEvent }) {
5772
helperText={Validation.title}
5873
/>
5974

60-
<ScaleDropdownSelect
61-
label="Type"
62-
value={State.type}
63-
disabled={!IsIncident(Event.Type)}
64-
onScale-change={(e) => Actions.setType(e.target.value as EventType)}
65-
invalid={!!Validation.type}
66-
helperText={Validation.type}
67-
>
68-
{Object.values(EventType).slice(2, 5).map((type, i) =>
69-
<ScaleDropdownSelectItem value={type} key={i}>
70-
{type}
71-
</ScaleDropdownSelectItem>)}
72-
</ScaleDropdownSelect>
73-
7475
<ScaleDropdownSelect
7576
label="Status"
7677
value={State.status}

src/Components/New/NewForm.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ export function NewForm() {
3636
OnSubmit();
3737
}}
3838
>
39-
<ScaleTextField
40-
placeholder="Please give the title of event"
41-
required
42-
label="Title"
43-
value={State.title}
44-
onScale-input={(e) => Actions.setTitle(e.target.value as string)}
45-
invalid={!!Validation.title}
46-
helperText={Validation.title}
47-
/>
4839

4940
<ScaleDropdownSelect
5041
label="Type"
@@ -59,6 +50,16 @@ export function NewForm() {
5950
</ScaleDropdownSelectItem>)}
6051
</ScaleDropdownSelect>
6152

53+
<ScaleTextField
54+
placeholder="Please give the title of event"
55+
required
56+
label="Title"
57+
value={State.title}
58+
onScale-input={(e) => Actions.setTitle(e.target.value as string)}
59+
invalid={!!Validation.title}
60+
helperText={Validation.title}
61+
/>
62+
6263
<ScaleTextarea
6364
placeholder="If there is any known information, please write it down here."
6465
resize="vertical"

0 commit comments

Comments
 (0)