import React, { useState, useEffect } from 'react'; import classNames from 'classnames'; import Table from 'components/common/Table'; import Button from 'components/common/Button'; import PageHeader from 'components/layout/PageHeader'; import Modal from 'components/common/Modal'; import WebsiteEditForm from '../forms/WebsiteEditForm'; import DeleteForm from '../forms/DeleteForm'; import TrackingCodeForm from '../forms/TrackingCodeForm'; import ShareUrlForm from '../forms/ShareUrlForm'; import EmptyPlaceholder from 'components/common/EmptyPlaceholder'; import Pen from 'assets/pen.svg'; import Trash from 'assets/trash.svg'; import Plus from 'assets/plus.svg'; import Code from 'assets/code.svg'; import Link from 'assets/link.svg'; import { get } from 'lib/web'; import styles from './WebsiteSettings.module.css'; export default function WebsiteSettings() { const [data, setData] = useState(); const [editWebsite, setEditWebsite] = useState(); const [deleteWebsite, setDeleteWebsite] = useState(); const [addWebsite, setAddWebsite] = useState(); const [showCode, setShowCode] = useState(); const [showUrl, setShowUrl] = useState(); const [saved, setSaved] = useState(0); const Buttons = row => ( <> {row.share_id && ( ); const columns = [ { key: 'name', label: 'Name', className: 'col-6 col-md-4' }, { key: 'domain', label: 'Domain', className: 'col-6 col-md-4' }, { key: 'action', className: classNames(styles.buttons, 'col-12 col-md-4 pt-2 pt-md-0'), render: Buttons, }, ]; function handleSave() { setSaved(state => state + 1); handleClose(); } function handleClose() { setAddWebsite(null); setEditWebsite(null); setDeleteWebsite(null); setShowCode(null); setShowUrl(null); } async function loadData() { setData(await get(`/api/websites`)); } useEffect(() => { loadData(); }, [saved]); if (!data) { return null; } const empty = ( ); return ( <>
Websites
{editWebsite && ( )} {addWebsite && ( )} {deleteWebsite && ( )} {showCode && ( )} {showUrl && ( )} ); }