CoastalCommitsPastes/client/app/admin/components/admin.tsx

45 lines
875 B
TypeScript
Raw Normal View History

2022-11-10 02:11:36 -05:00
"use client"
import { TOKEN_COOKIE_NAME } from "@lib/constants"
import { getCookie } from "cookies-next"
2022-04-09 20:48:19 -04:00
import styles from "./admin.module.css"
import PostTable from "./post-table"
import UserTable from "./user-table"
export const adminFetcher = async (
url: string,
options?: {
method?: string
body?: any
}
) =>
fetch("/server-api/admin" + url, {
method: options?.method || "GET",
2022-04-09 20:48:19 -04:00
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${getCookie(TOKEN_COOKIE_NAME)}`
},
body: options?.body && JSON.stringify(options.body)
})
const Admin = () => {
2022-04-09 20:48:19 -04:00
return (
<div className={styles.adminWrapper}>
<h2>Administration</h2>
<div
style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
gap: 4
}}
>
<UserTable />
<PostTable />
</div>
2022-04-09 20:48:19 -04:00
</div>
)
}
2022-04-09 20:48:19 -04:00
export default Admin