diff options
| author | Zephyruso <[email protected]> | 2023-06-28 12:55:58 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-06-28 12:55:58 +0800 |
| commit | d497b15bedae37abb105d750ef1dfe16f6a7e05d (patch) | |
| tree | a3567f2bf7bf9f228fea42ff996154198d38b311 /src/components/ModalSourceIP.tsx | |
| parent | f189d5b14f8c37c8d48a5c54fa52a0125f4d5306 (diff) | |
feat: close connection single or with filter (#64)
Diffstat (limited to 'src/components/ModalSourceIP.tsx')
| -rw-r--r-- | src/components/ModalSourceIP.tsx | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/components/ModalSourceIP.tsx b/src/components/ModalSourceIP.tsx new file mode 100644 index 0000000..a406601 --- /dev/null +++ b/src/components/ModalSourceIP.tsx @@ -0,0 +1,60 @@ +import React from 'react'; +import { useTranslation } from 'react-i18next'; + +import BaseModal from '~/components/shared/BaseModal'; + +import Button from './Button'; +import Input from './Input'; +import s from './ModalSourceIP.module.scss'; + +export default function ModalSourceIP({ isOpen, onRequestClose, sourceMap, setSourceMap }) { + const { t } = useTranslation(); + const setSource = (key, index, val) => { + sourceMap[index][key] = val; + setSourceMap(Array.from(sourceMap)); + }; + + return ( + <BaseModal isOpen={isOpen} onRequestClose={onRequestClose}> + <table className={s.sourceipTable}> + <thead> + <tr> + <th>{t('c_source')}</th> + <th>{t('device_name')}</th> + </tr> + </thead> + <tbody> + {sourceMap.map((source, index) => ( + <tr key={`${index}`}> + <td> + <Input + type="text" + name="reg" + autoComplete="off" + value={source.reg} + onChange={(e) => setSource('reg', index, e.target.value)} + /> + </td> + <td> + <Input + type="text" + name="name" + autoComplete="off" + value={source.name} + onChange={(e) => setSource('name', index, e.target.value)} + /> + </td> + <td> + <Button onClick={() => sourceMap.splice(index, 1)}>{t('delete')}</Button> + </td> + </tr> + ))} + </tbody> + </table> + <div> + <div className={s.iptableTipContainer}>{t('sourceip_tip')}</div> + <Button onClick={() => sourceMap.push({ reg: '', name: '' })}>{t('add_tag')}</Button> + </div> + </BaseModal> + ); +} |
