fix(striker-ui): passthrough input validation in EditUpsInputGroup

main
Tsu-ba-me 2 years ago
parent c0fb71ea29
commit 7976170ca2
  1. 25
      striker-ui/components/ManageUps/EditUpsInputGroup.tsx
  2. 9
      striker-ui/types/EditUpsInputGroup.d.ts

@ -1,27 +1,40 @@
import { FC, ReactElement, useMemo } from 'react';
import { ReactElement, useMemo } from 'react';
import AddUpsInputGroup from './AddUpsInputGroup';
import AddUpsInputGroup, { INPUT_ID_UPS_TYPE } from './AddUpsInputGroup';
import { INPUT_ID_UPS_IP, INPUT_ID_UPS_NAME } from './CommonUpsInputGroup';
import Spinner from '../Spinner';
const INPUT_ID_UPS_UUID = 'edit-ups-input-ups-uuid';
const EditUpsInputGroup: FC<EditUpsInputGroupProps> = ({
const EditUpsInputGroup = <
M extends {
[K in
| typeof INPUT_ID_UPS_IP
| typeof INPUT_ID_UPS_NAME
| typeof INPUT_ID_UPS_TYPE]: string;
},
>({
formUtils,
loading: isExternalLoading,
previous,
upsTemplate,
upsUUID,
}) => {
}: EditUpsInputGroupProps<M>): ReactElement => {
const content = useMemo<ReactElement>(
() =>
isExternalLoading ? (
<Spinner />
) : (
<>
<AddUpsInputGroup previous={previous} upsTemplate={upsTemplate} />
<AddUpsInputGroup
formUtils={formUtils}
previous={previous}
upsTemplate={upsTemplate}
/>
<input hidden id={INPUT_ID_UPS_UUID} readOnly value={upsUUID} />
</>
),
[isExternalLoading, previous, upsTemplate, upsUUID],
[formUtils, isExternalLoading, previous, upsTemplate, upsUUID],
);
return content;

@ -2,7 +2,8 @@ type EditUpsInputGroupOptionalProps = {
loading?: boolean;
};
type EditUpsInputGroupProps = EditUpsInputGroupOptionalProps &
Pick<AddUpsInputGroupProps, 'previous' | 'upsTemplate'> & {
upsUUID: string;
};
type EditUpsInputGroupProps<M extends MapToInputTestID> =
EditUpsInputGroupOptionalProps &
Pick<AddUpsInputGroupProps<M>, 'formUtils' | 'previous' | 'upsTemplate'> & {
upsUUID: string;
};

Loading…
Cancel
Save