Skip to content

Commit

Permalink
Refactoring...
Browse files Browse the repository at this point in the history
  • Loading branch information
pmakode-akamai committed Jul 16, 2024
1 parent 76d7614 commit b65694e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
6 changes: 0 additions & 6 deletions packages/manager/src/components/Autocomplete/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ import {

import type { AutocompleteProps } from '@mui/material/Autocomplete';

export interface Item<T = number | string, L = string> {
data?: any;
label: L;
value: T;
}

export interface EnhancedAutocompleteProps<
T extends { label: string },
Multiple extends boolean | undefined = undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import type {
KubeNodePoolResponse,
} from '@linode/api-v4/lib/kubernetes';
import type { APIError } from '@linode/api-v4/lib/types';
import type { Item } from 'src/components/Autocomplete/Autocomplete';

export const CreateCluster = () => {
const { classes } = useStyles();
Expand All @@ -65,7 +64,7 @@ export const CreateCluster = () => {
>();
const [nodePools, setNodePools] = React.useState<KubeNodePoolResponse[]>([]);
const [label, setLabel] = React.useState<string | undefined>();
const [version, setVersion] = React.useState<Item<string> | undefined>();
const [version, setVersion] = React.useState<string | undefined>();
const [errors, setErrors] = React.useState<APIError[] | undefined>();
const [submitting, setSubmitting] = React.useState<boolean>(false);
const [hasAgreed, setAgreed] = React.useState<boolean>(false);
Expand Down Expand Up @@ -113,15 +112,15 @@ export const CreateCluster = () => {

React.useEffect(() => {
if (versions.length > 0) {
setVersion(getLatestVersion(versions));
setVersion(getLatestVersion(versions).value);
}
}, [versionData]);

const createCluster = () => {
const { push } = history;
setErrors(undefined);
setSubmitting(true);
const k8s_version = version ? version.value : undefined;
const k8s_version = version ?? undefined;

// Only type and count to the API.
const node_pools = nodePools.map(
Expand Down Expand Up @@ -245,18 +244,15 @@ export const CreateCluster = () => {
</StyledRegionSelectStack>
<Divider sx={{ marginTop: 4 }} />
<Autocomplete
isOptionEqualToValue={(option, value) =>
option.value === value.value
}
onChange={(_, selected: Item<string>) => {
setVersion(selected);
onChange={(_, selected) => {
setVersion(selected?.value);
}}
disableClearable={!!version}
errorText={errorMap.k8s_version}
label="Kubernetes Version"
options={versions}
placeholder={' '}
value={version ?? null}
value={versions.find((v) => v.value === version) ?? null}
/>
<Divider sx={{ marginTop: 4 }} />
{showHighAvailability ? (
Expand Down

0 comments on commit b65694e

Please sign in to comment.