mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-10 18:27:25 +03:00
52 lines
1.9 KiB
TypeScript
52 lines
1.9 KiB
TypeScript
import {
|
|
faChartPie as pieChartIcon,
|
|
faEdit as editIcon,
|
|
faMinusCircle as deleteIcon,
|
|
faQrcode as qrIcon,
|
|
} from '@fortawesome/free-solid-svg-icons';
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
import type { FC } from 'react';
|
|
import { DropdownItem } from 'reactstrap';
|
|
import { RowDropdownBtn } from '../../../src/utils/RowDropdownBtn';
|
|
import { useToggle } from '../../utils/helpers/hooks';
|
|
import type { ShortUrl, ShortUrlModalProps } from '../data';
|
|
import { ShortUrlDetailLink } from './ShortUrlDetailLink';
|
|
|
|
interface ShortUrlsRowMenuProps {
|
|
shortUrl: ShortUrl;
|
|
}
|
|
type ShortUrlModal = FC<ShortUrlModalProps>;
|
|
|
|
export const ShortUrlsRowMenu = (
|
|
DeleteShortUrlModal: ShortUrlModal,
|
|
QrCodeModal: ShortUrlModal,
|
|
) => ({ shortUrl }: ShortUrlsRowMenuProps) => {
|
|
const [isQrModalOpen,, openQrCodeModal, closeQrCodeModal] = useToggle();
|
|
const [isDeleteModalOpen,, openDeleteModal, closeDeleteModal] = useToggle();
|
|
|
|
return (
|
|
<RowDropdownBtn minWidth={190}>
|
|
<DropdownItem tag={ShortUrlDetailLink} shortUrl={shortUrl} suffix="visits">
|
|
<FontAwesomeIcon icon={pieChartIcon} fixedWidth /> Visit stats
|
|
</DropdownItem>
|
|
|
|
<DropdownItem tag={ShortUrlDetailLink} shortUrl={shortUrl} suffix="edit">
|
|
<FontAwesomeIcon icon={editIcon} fixedWidth /> Edit short URL
|
|
</DropdownItem>
|
|
|
|
<DropdownItem onClick={openQrCodeModal}>
|
|
<FontAwesomeIcon icon={qrIcon} fixedWidth /> QR code
|
|
</DropdownItem>
|
|
<QrCodeModal shortUrl={shortUrl} isOpen={isQrModalOpen} toggle={closeQrCodeModal} />
|
|
|
|
<DropdownItem divider />
|
|
|
|
<DropdownItem className="dropdown-item--danger" onClick={openDeleteModal}>
|
|
<FontAwesomeIcon icon={deleteIcon} fixedWidth /> Delete short URL
|
|
</DropdownItem>
|
|
<DeleteShortUrlModal shortUrl={shortUrl} isOpen={isDeleteModalOpen} toggle={closeDeleteModal} />
|
|
</RowDropdownBtn>
|
|
);
|
|
};
|
|
|
|
export type ShortUrlsRowMenuType = ReturnType<typeof ShortUrlsRowMenu>;
|