2022-11-09 22:46:12 -05:00
|
|
|
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"
|
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",
|
2022-11-09 22:46:12 -05:00
|
|
|
Authorization: `Bearer ${getCookie(TOKEN_COOKIE_NAME)}`
|
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}>
|
2022-11-08 03:23:28 -05:00
|
|
|
<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-03-28 15:13:22 -04:00
|
|
|
}
|
|
|
|
|
2022-04-09 20:48:19 -04:00
|
|
|
export default Admin
|