2022-04-13 00:14:10 -04:00
|
|
|
import { Text, Fieldset, Spacer } from "@geist-ui/core"
|
2022-04-09 20:48:19 -04:00
|
|
|
import { Post, User } from "@lib/types"
|
|
|
|
import Cookies from "js-cookie"
|
2022-04-13 00:14:10 -04:00
|
|
|
import { useEffect, useMemo, useState } from "react"
|
2022-04-09 20:48:19 -04:00
|
|
|
import styles from "./admin.module.css"
|
|
|
|
import PostModal from "./post-modal-link"
|
2022-04-13 00:14:10 -04:00
|
|
|
import PostTable from "./post-table"
|
|
|
|
import UserTable from "./user-table"
|
2022-03-29 03:11:02 -04:00
|
|
|
|
2022-04-13 00:14:10 -04:00
|
|
|
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 ${Cookies.get("drift-token")}`
|
2022-04-13 00:14:10 -04:00
|
|
|
},
|
|
|
|
body: options?.body && JSON.stringify(options.body)
|
|
|
|
})
|
2022-03-28 15:13:22 -04:00
|
|
|
|
|
|
|
const Admin = () => {
|
2022-04-09 20:48:19 -04:00
|
|
|
return (
|
|
|
|
<div className={styles.adminWrapper}>
|
|
|
|
<Text h2>Administration</Text>
|
2022-04-13 00:14:10 -04:00
|
|
|
<UserTable />
|
2022-04-09 20:48:19 -04:00
|
|
|
<Spacer height={1} />
|
2022-04-13 00:14:10 -04:00
|
|
|
<PostTable />
|
2022-04-09 20:48:19 -04:00
|
|
|
</div>
|
|
|
|
)
|
2022-03-28 15:13:22 -04:00
|
|
|
}
|
|
|
|
|
2022-04-09 20:48:19 -04:00
|
|
|
export default Admin
|