-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathpage.jsx
More file actions
31 lines (24 loc) · 679 Bytes
/
page.jsx
File metadata and controls
31 lines (24 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import TicketForm from "@/app/(components)/TicketForm";
const getTicketById = async (id) => {
const res = await fetch(`${process.env.BASE_URL}${id}`, {
cache: "no-store",
});
if (!res.ok) {
throw new Error("Failed to get ticket.");
}
return res.json();
};
const TicketPage = async ({ params }) => {
const EDITMODE = params.id === "new" ? false : true;
let updateTicketData = {};
if (EDITMODE) {
updateTicketData = await getTicketById(params.id);
updateTicketData = updateTicketData.foundTicket;
} else {
updateTicketData = {
id: "new",
};
}
return <TicketForm ticket={updateTicketData} />;
};
export default TicketPage;