import SealSelect from '@/components/seal-form/seal-select'; import { useIntl } from '@umijs/max'; import { Form } from 'antd'; import _ from 'lodash'; import React from 'react'; import styled from 'styled-components'; import { regionList } from '../config'; import { ClusterFormData as FormData } from '../config/types'; type OptionData = { label: string; datacenter: string; value: string; }; const OptionItem = styled.div` display: flex; align-items: center; .label { font-weight: 500; } .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--ant-color-text); margin: 0 8px; } .datacenter, .value { color: var(--ant-color-text-secondary); } `; interface CloudProviderProps { provider: string; // 'kubernetes' | 'digitalocean'; credentialList: Global.BaseOption[]; } const optionRender = ( option: Global.BaseOption< number, { data: OptionData; } > ): React.ReactNode => { const { value } = option; const data = option.data!; return ( {data.label} {data.datacenter}{' '} {' '} {_.toUpper(value)} ); }; const labelRender = (props: { label: string; value: string; }): React.ReactNode => { const data = regionList.find((item) => item.value === props.value); return ( {data?.label} {data?.datacenter}{' '} {_.toUpper(data?.value)} ); }; const CloudProvider: React.FC = (props) => { const { credentialList } = props; const intl = useIntl(); return ( <> name="credential_id" rules={[ { required: true, message: intl.formatMessage( { id: 'common.form.rule.input' }, { name: 'credential' } ) } ]} > name="region" rules={[ { required: true, message: intl.formatMessage( { id: 'common.form.rule.input' }, { name: 'Region' } ) } ]} > ); }; export default CloudProvider;