mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-07 03:13:30 +00:00
[ENG-1680] Show error messages for feedback form (#2196)
Update FeedbackButton.tsx
This commit is contained in:
parent
471db4a691
commit
4b74c0af04
|
@ -8,7 +8,7 @@ import { useLocale } from '~/hooks';
|
||||||
|
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
message: z.string().min(1, { message: i18n.t('feedback_is_required') }),
|
message: z.string().min(1, { message: i18n.t('feedback_is_required') }),
|
||||||
emoji: z.number().min(0).max(3)
|
emoji: z.number().min(0).max(3, { message: 'Please select an emoji' })
|
||||||
});
|
});
|
||||||
|
|
||||||
const EMOJIS = ['🤩', '😀', '🙁', '😭'];
|
const EMOJIS = ['🤩', '😀', '🙁', '😭'];
|
||||||
|
@ -32,8 +32,9 @@ export default function () {
|
||||||
message: ''
|
message: ''
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const popover = usePopover();
|
|
||||||
|
|
||||||
|
const emojiError = form.formState.errors.emoji?.message;
|
||||||
|
const popover = usePopover();
|
||||||
const authState = auth.useStateSnapshot();
|
const authState = auth.useStateSnapshot();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -69,30 +70,42 @@ export default function () {
|
||||||
placeholder={t('feedback_placeholder')}
|
placeholder={t('feedback_placeholder')}
|
||||||
className="!h-36 w-full flex-1"
|
className="!h-36 w-full flex-1"
|
||||||
/>
|
/>
|
||||||
<div className="flex flex-row justify-between">
|
<div className="flex flex-row items-center justify-between">
|
||||||
<Controller
|
<Controller
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="emoji"
|
name="emoji"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div className="flex items-center justify-center gap-1 text-lg">
|
<div className="flex flex-col items-center">
|
||||||
{EMOJIS.map((emoji, i) => (
|
<div className="flex items-center gap-1 text-lg">
|
||||||
<button
|
{EMOJIS.map((emoji, i) => (
|
||||||
type="button"
|
<button
|
||||||
onClick={() => field.onChange(i)}
|
type="button"
|
||||||
key={i}
|
onClick={() => field.onChange(i)}
|
||||||
className={clsx(
|
key={i}
|
||||||
field.value === i ? 'bg-accent' : 'bg-app-input',
|
className={clsx(
|
||||||
'flex h-7 w-7 cursor-pointer items-center justify-center rounded-full border border-app-line transition-all duration-200 hover:scale-125'
|
field.value === i
|
||||||
)}
|
? 'bg-accent'
|
||||||
>
|
: 'bg-app-input',
|
||||||
{emoji}
|
'flex size-7 cursor-pointer items-center justify-center rounded-full border transition-all duration-200 hover:scale-125',
|
||||||
</button>
|
emojiError
|
||||||
))}
|
? 'border-red-500'
|
||||||
|
: 'border-app-line'
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{emoji}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
{emojiError && (
|
||||||
|
<p className="pt-1 text-xs text-red-500">
|
||||||
|
Please select an emoji
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Button type="submit" variant="accent" disabled={!form.formState.isValid}>
|
<Button type="submit" variant="accent">
|
||||||
{t('send')}
|
{t('send')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue