-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
266 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,63 @@ | ||
import { getServerSession } from "next-auth" | ||
import React from "react" | ||
|
||
import { Box } from "@mui/joy" | ||
|
||
import { authOptions } from "../api/auth/[...nextauth]/route" | ||
|
||
import ContentContainer from "@/components/content-container" | ||
import { fetchCallbackData } from "@/services/graphql/queries/callback-query" | ||
import CallbackItem from "@/components/callback/callback-item" | ||
import CallBackList from "@/components/callback/callback-list" | ||
|
||
import CreateCallBack from "@/components/callback/callback-input" | ||
import { fetchCallbackData } from "@/services/graphql/queries/callback-query" | ||
import CallBackCardItem from "@/components/callback/callback-item" | ||
|
||
export default async function page() { | ||
const session = await getServerSession(authOptions) | ||
const token = session?.accessToken | ||
if (!token || typeof token !== "string") { | ||
throw new Error("invalid token") | ||
} | ||
|
||
let response | ||
try { | ||
response = await fetchCallbackData(token) | ||
} catch { | ||
} catch (err) { | ||
return null | ||
} | ||
|
||
const callbackEndpoints = response.data.me?.defaultAccount.callbackEndpoints || [] | ||
const endpoints = response.data.me?.defaultAccount.callbackEndpoints || [] | ||
|
||
return ( | ||
<ContentContainer> | ||
<CreateCallBack /> | ||
{callbackEndpoints.map((endpointItem) => { | ||
return ( | ||
<CallbackItem | ||
key={endpointItem.id} | ||
id={endpointItem.id} | ||
url={endpointItem.url} | ||
/> | ||
) | ||
})} | ||
<Box | ||
sx={{ | ||
maxWidth: "90em", | ||
margin: "0 auto", | ||
width: "100%", | ||
}} | ||
> | ||
<CreateCallBack /> | ||
<Box | ||
sx={{ | ||
display: { | ||
xs: "none", | ||
md: "block", | ||
}, | ||
}} | ||
> | ||
<CallBackList endpoints={endpoints} /> | ||
</Box> | ||
<Box | ||
sx={{ | ||
display: { | ||
xs: "block", | ||
md: "none", | ||
}, | ||
}} | ||
> | ||
<CallBackCardItem endpoints={endpoints} /> | ||
</Box> | ||
</Box> | ||
</ContentContainer> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.