import React, { useState, useEffect } from 'react'; import Table from './common/Table'; import Button from './common/Button'; import PageHeader from './layout/PageHeader'; 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 { get } from 'lib/web'; import Modal from './common/Modal'; import WebsiteEditForm from './forms/WebsiteEditForm'; import DeleteForm from './forms/DeleteForm'; import WebsiteCodeForm from './forms/WebsiteCodeForm'; 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 [saved, setSaved] = useState(0); const columns = [ { key: 'name', label: 'Name', className: styles.col }, { key: 'domain', label: 'Domain', className: styles.col }, { key: 'action', className: styles.buttons, render: row => ( <> ), }, ]; function handleSave() { setSaved(state => state + 1); handleClose(); } function handleClose() { setAddWebsite(null); setEditWebsite(null); setDeleteWebsite(null); setShowCode(null); } async function loadData() { setData(await get(`/api/website`)); } useEffect(() => { loadData(); }, [saved]); if (!data) { return null; } return ( <>
Websites
{editWebsite && ( )} {addWebsite && ( )} {deleteWebsite && ( )} {showCode && ( )} ); }