Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fast-drinks-stop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@venusprotocol/evm": patch
---

feat: remove raw translate key on vai
4 changes: 3 additions & 1 deletion apps/evm/src/containers/Form/RhfTokenTextField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ export type RhfTokenTextFieldProps<TFormValues extends FieldValues> = {
name: Path<TFormValues>;
control: Control<TFormValues>;
rules?: RegisterOptions;
hideErrorDescription?: boolean;
} & Omit<TokenTextFieldProps, 'value' | 'onChange'>;

export const RhfTokenTextField = <TFormValues extends FieldValues>({
name,
rules,
control,
hideErrorDescription = false,
...tokenTextFieldProps
}: RhfTokenTextFieldProps<TFormValues>) => {
const formState = useFormState({ control });
Expand All @@ -40,7 +42,7 @@ export const RhfTokenTextField = <TFormValues extends FieldValues>({
hasError={hasError}
disabled={field.disabled || formState.isSubmitting || tokenTextFieldProps.disabled}
description={
hasError && fieldState.error ? (
!hideErrorDescription && hasError && fieldState.error ? (
<p className="text-red">{fieldState.error.message}</p>
) : undefined
}
Expand Down
1 change: 1 addition & 0 deletions apps/evm/src/pages/Vai/Borrow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ export const Borrow: React.FC = () => {
name="amountTokens"
rules={{ required: true }}
disabled={!isUserConnected || isUserMissingPrimeToken}
hideErrorDescription
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend taking a different approach.

This form is behaving differently in the sense that we use a custom UI to show errors. The designs were made quite a while ago and so I think we'd be better off staying consistent with the newest form.

So the approach I propose is to update the useForm hook of this component so that the error that's set on the field isn't an error code but rather the full error message. This means the RhfTokenTextField component won't need to be updated and will natively display the human-friendly error message.

token={vai}
rightMaxButton={{
label: t('vai.borrow.amountTokensInput.limitButtonLabel'),
Expand Down
1 change: 1 addition & 0 deletions apps/evm/src/pages/Vai/Repay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export const Repay: React.FC = () => {
name="amountTokens"
rules={{ required: true }}
disabled={!isUserConnected}
hideErrorDescription
token={vai}
rightMaxButton={
limitTokens
Expand Down
Loading