Skip to content

Commit

Permalink
Add default values and helper text
Browse files Browse the repository at this point in the history
  • Loading branch information
mjac0bs committed Jun 26, 2024
1 parent 69c624b commit c2fc27d
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Controller, useFormContext } from 'react-hook-form';
import { useAccount } from 'src/queries/account/account';
import { EntityType } from './SupportTicketDialog';
import { SupportTicketProductSelectionFields } from './SupportTicketProductSelectionFields';
import { Link } from 'src/components/Link';

export interface AccountLimitCustomFields extends CustomFields {
numberOfEntities: string;
Expand All @@ -23,13 +24,23 @@ export const SupportTicketAccountLimitFields = (props: Props) => {
const form = useFormContext<AccountLimitCustomFields>();

const { data: account } = useAccount();

const defaultValues = {
companyName: account?.company,
customerName: `${account?.first_name} ${account?.last_name}`,
...form.formState.defaultValues,
};

React.useEffect(() => {
form.reset(defaultValues);
}, []);

return (
<>
<Controller
render={({ field, fieldState }) => (
<TextField
data-qa-ticket-customer-name
defaultValue={`${account?.first_name} ${account?.last_name}`}
errorText={fieldState.error?.message}
label={ACCOUNT_LIMIT_FIELD_NAME_TO_LABEL_MAP.customerName}
name="customerName"
Expand Down Expand Up @@ -66,6 +77,11 @@ export const SupportTicketAccountLimitFields = (props: Props) => {
placeholder="Dedicated 4GB, Shared 8GB, High Memory 24GB, etc."
onChange={field.onChange}
value={field.value}
helperText={
<Link to="https://www.linode.com/pricing/">
View types of plans
</Link>
}
/>
)}
control={form.control}
Expand Down

0 comments on commit c2fc27d

Please sign in to comment.