Skip to content

Commit 4216b57

Browse files
authored
Swap reason and url fields in proposal voting form (#2599)
Part of #2550 Signed-off-by: fayi-da <[email protected]>
1 parent 6cac655 commit 4216b57

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

apps/sv/frontend/src/components/governance/ProposalVoteForm.tsx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -100,60 +100,60 @@ export const ProposalVoteForm: React.FC<ProposalVoteFormProps> = props => {
100100
>
101101
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
102102
<form.Field
103-
name="url"
103+
name="reason"
104104
validators={{
105105
onChange: ({ value }) => {
106-
const result = z
107-
.string()
108-
.optional()
109-
// URL is optional so we allow undefined or empty string here as it's the default value
110-
.refine(url => !url || url.trim() === '' || isValidUrl(url), {
111-
message: 'Invalid URL',
112-
})
113-
.safeParse(value);
106+
const result = z.string().safeParse(value);
114107
return result.success ? undefined : result.error.issues[0].message;
115108
},
116109
}}
117110
children={field => {
118111
return (
119112
<TextField
120-
label="URL"
113+
label="Reason"
114+
multiline
115+
rows={4}
121116
name={field.name}
122117
value={field.state.value}
123118
onBlur={field.handleBlur}
124119
onChange={e => field.handleChange(e.target.value)}
125120
error={!field.state.meta.isValid}
126-
helperText={
127-
<span data-testid="your-vote-url-helper-text">
128-
{field.state.meta.errors?.[0]}
129-
</span>
130-
}
131-
inputProps={{ 'data-testid': 'your-vote-url-input' }}
121+
helperText={field.state.meta.errors?.[0]}
122+
inputProps={{ 'data-testid': 'your-vote-reason-input' }}
132123
/>
133124
);
134125
}}
135126
/>
136127
<form.Field
137-
name="reason"
128+
name="url"
138129
validators={{
139130
onChange: ({ value }) => {
140-
const result = z.string().safeParse(value);
131+
const result = z
132+
.string()
133+
.optional()
134+
// URL is optional so we allow undefined or empty string here as it's the default value
135+
.refine(url => !url || url.trim() === '' || isValidUrl(url), {
136+
message: 'Invalid URL',
137+
})
138+
.safeParse(value);
141139
return result.success ? undefined : result.error.issues[0].message;
142140
},
143141
}}
144142
children={field => {
145143
return (
146144
<TextField
147-
label="Reason"
148-
multiline
149-
rows={4}
145+
label="URL"
150146
name={field.name}
151147
value={field.state.value}
152148
onBlur={field.handleBlur}
153149
onChange={e => field.handleChange(e.target.value)}
154150
error={!field.state.meta.isValid}
155-
helperText={field.state.meta.errors?.[0]}
156-
inputProps={{ 'data-testid': 'your-vote-reason-input' }}
151+
helperText={
152+
<span data-testid="your-vote-url-helper-text">
153+
{field.state.meta.errors?.[0]}
154+
</span>
155+
}
156+
inputProps={{ 'data-testid': 'your-vote-url-input' }}
157157
/>
158158
);
159159
}}

0 commit comments

Comments
 (0)