import React, { useState, useEffect, Fragment } from "react"; import { useNavigate } from "react-router-dom"; import { Dialog, Transition } from "@headlessui/react"; import DeleteWindow from "./window/delete"; const fetchData = async () => { try { const response = await fetch(wpclickizy.apiUrl + "wp-clickizy/v1/accounts/get"); if (!response.ok) { throw new Error("Network response was not ok."); } const data = await response.json(); return data; } catch (error) { console.error("Error fetching data:", error); throw error; } }; const deleteAccount = async () => { try { const response = await fetch( wpclickizy.apiUrl + "wpclickizy/v1/accounts/delete", ); if (!response.ok) { throw new Error("Network response was not ok"); } const result = await response.json(); return result; } catch (error) { console.log("Error while deleting account"); throw error; } }; export default function AccountList() { const navigate = useNavigate(); let [open, setOpen] = useState(false); let [isOpen, setIsOpen] = useState(true); let [editing, setEditing] = useState(null); function openModal(id) { setEditing(id); setIsOpen(true); } function openSidebar() { setOpen(true); } const handleButtonClick = () => { // Use history.push to navigate to a new route navigate("/accounts-add"); }; const [accounts, setAccounts] = useState([]); useEffect(() => { const fetchAccounts = async () => { try { const data = await fetchData(); setAccounts(data); } catch (error) { // Handle error } }; fetchAccounts(); }, []); return ( <>
Panel title
{/* Your content */}
{/* Insert search icon SVG inside the relative div and position it absolutely to the left */}
{/* Repeat the following tr for each row in your table data */} {accounts.map((account) => ( ))} {/* End of table row repeat */}
Email First Name Last Name ACTION
{/* Insert user icon SVG or image here */}

{account.email}

{account.first_name}

{account.last_name} {/* Insert vertical dots icon SVG or image here */}
); }