feat(sgw): Add new services and utilities for ship, trip, and photo management
This commit is contained in:
62
src/components/shared/Button.tsx
Normal file
62
src/components/shared/Button.tsx
Normal file
@@ -0,0 +1,62 @@
|
||||
import { DeleteOutlined, EditOutlined } from '@ant-design/icons';
|
||||
import { Button, Popconfirm, Tooltip } from 'antd';
|
||||
import { useState } from 'react';
|
||||
|
||||
/* =======================
|
||||
DeleteButton
|
||||
======================= */
|
||||
|
||||
interface DeleteButtonProps {
|
||||
title: string;
|
||||
text: string;
|
||||
onOk: () => void | Promise<void>;
|
||||
}
|
||||
|
||||
export const DeleteButton: React.FC<DeleteButtonProps> = ({
|
||||
title,
|
||||
text,
|
||||
onOk,
|
||||
}) => {
|
||||
const [visible, setVisible] = useState<boolean>(false);
|
||||
|
||||
const handleConfirm = async () => {
|
||||
await onOk();
|
||||
setVisible(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Popconfirm
|
||||
title={title}
|
||||
open={visible}
|
||||
onConfirm={handleConfirm}
|
||||
onCancel={() => setVisible(false)}
|
||||
>
|
||||
<Tooltip title={text}>
|
||||
<Button
|
||||
size="small"
|
||||
danger
|
||||
type="primary"
|
||||
icon={<DeleteOutlined />}
|
||||
onClick={() => setVisible(true)}
|
||||
/>
|
||||
</Tooltip>
|
||||
</Popconfirm>
|
||||
);
|
||||
};
|
||||
|
||||
/* =======================
|
||||
EditButton
|
||||
======================= */
|
||||
|
||||
interface EditButtonProps {
|
||||
text: string;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
export const EditButton: React.FC<EditButtonProps> = ({ text, onClick }) => {
|
||||
return (
|
||||
<Tooltip title={text}>
|
||||
<Button size="small" icon={<EditOutlined />} onClick={onClick} />
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user