Copilot commented on code in PR #3014: URL: https://github.com/apache/apisix-dashboard/pull/3014#discussion_r2074905745
########## src/components/form-slice/FormPartSSL/FormItemCertKeyList.tsx: ########## @@ -0,0 +1,107 @@ +import { Button, Fieldset, Stack, type FieldsetProps } from '@mantine/core'; +import { useTranslation } from 'react-i18next'; +import { useFieldArray, useFormContext } from 'react-hook-form'; +import { FormSection } from '../FormSection'; +import type { SSLPostType } from './schema'; +import type { PropsWithChildren } from 'react'; +import { FormItemTextareaWithUpload } from '@/components/form/TextareaWithUpload'; +import IconDelete from '~icons/material-symbols/delete-forever-outline'; + +const PairWrapper = ( + props: PropsWithChildren & Pick<FieldsetProps, 'legend'> +) => { + const { children, legend } = props; + return ( + <Fieldset p={8} mb={5} legend={legend}> + <Stack flex={1} gap={1}> + {children} + </Stack> + </Fieldset> + ); +}; + +const RequiredCertKey = () => { + const { t } = useTranslation(); + const { control } = useFormContext<SSLPostType>(); + return ( + <PairWrapper> + <FormItemTextareaWithUpload + control={control} + label={`${t('form.ssls.cert')} 1`} + name="cert" + required + /> + <FormItemTextareaWithUpload + control={control} + label={`${t('form.ssls.key')} 1`} + name="key" + required + /> + </PairWrapper> + ); +}; +const CertKeyPairList = () => { + const { t } = useTranslation(); + const certs = useFieldArray({ + name: 'certs', + }); + const keys = useFieldArray({ + name: 'keys', + }); + return ( + <> + {certs.fields.map((cert, idx) => ( + <PairWrapper + key={cert.id} Review Comment: [nitpick] Using two separate field arrays for 'certs' and 'keys' could lead to synchronization issues. Consider refactoring to use a single field array where each entry contains both the cert and key for improved maintainability. ```suggestion const certKeyPairs = useFieldArray({ name: 'certKeyPairs', }); return ( <> {certKeyPairs.fields.map((pair, idx) => ( <PairWrapper key={pair.id} ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org