mirror of
https://github.com/cssgunc/compass.git
synced 2025-04-18 17:50:16 -04:00
* Created mock/test table and resource page to see if implementation works * Fixed typing for TagsInput * cleaned up imports * Started moving data manipulation into Table * moved data manipulation logic into Table * added useTagsHandler custom hook to consolidate getTagColor and presetOptions state into one function * Fixed type errors for RowOpenAction * Refactored ServiceIndex * Refactored user table * Updated imports and client facing routes * added documentation for table components * Added documentation for TagsHandler * small changes for cleaner code * refactored typing for tables. More work needs to be done to ensure tables are overall working properly * added todo * updated client paths with new table props * alterned handleRowUpdate to only use setData * diverted responsibility of handleRowChange to Drawer instead of Table to remove repetition * updated documentation * added sorting util function to Table.tsx to reduce repetition * Edited sorting func to be more comaptible and edited hideData to be more concise * formatting * updated imports * updated tags for all tables * removed DataPoint dependecy from User, Service, and Resource models as it was unnecesary * Added inline documentation to table components * added documentation for DataPoint model * Update package-lock.json
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
"use client";
|
|
|
|
import { PageLayout } from "@/components/PageLayout";
|
|
import UserTable from "@/components/Table/UserTable";
|
|
import User from "@/utils/models/User";
|
|
import { createClient } from "@/utils/supabase/client";
|
|
|
|
import { UsersIcon } from "@heroicons/react/24/solid";
|
|
import { useEffect, useState } from "react";
|
|
|
|
export default function Page() {
|
|
const [users, setUsers] = useState<User[]>([]);
|
|
|
|
useEffect(() => {
|
|
async function getUser() {
|
|
const supabase = createClient();
|
|
|
|
const { data, error } = await supabase.auth.getUser();
|
|
|
|
if (error) {
|
|
console.log("Accessed admin page but not logged in");
|
|
return;
|
|
}
|
|
|
|
const userListData = await fetch(
|
|
`${process.env.NEXT_PUBLIC_HOST}/api/user/all?uuid=${data.user.id}`
|
|
);
|
|
|
|
const users: User[] = await userListData.json();
|
|
|
|
setUsers(users);
|
|
}
|
|
|
|
getUser();
|
|
}, []);
|
|
|
|
return (
|
|
<div className="min-h-screen flex flex-col">
|
|
{/* icon + title */}
|
|
<PageLayout title="Users" icon={<UsersIcon />}>
|
|
<UserTable data={users} setData={setUsers} />
|
|
</PageLayout>
|
|
</div>
|
|
);
|
|
}
|