Skip to content

Commit

Permalink
feat(notices): add new route for creating notices and refactor existi…
Browse files Browse the repository at this point in the history
…ng routes to use it

refactor(ConfirmationDialog.tsx): import server action from _actions and pass it down as prop
refactor(next.config.js): add new route for creating notices and refactor existing routes to use it
  • Loading branch information
masterkain committed May 19, 2023
1 parent 04007e2 commit e05bd1b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ async function POST(request: NextRequest) {

const customNanoid = customAlphabet(urlAlphabet, 21);
// assuming airbroke frontend is deployed alongside collector
const responseJSON = { id: customNanoid, url: `${getServerHostname(request)}/projects/${project.id}/notices` };
const responseJSON = { id: customNanoid(), url: `${getServerHostname(request)}/projects/${project.id}/notices` };
console.log(responseJSON); // Log the response JSON
return NextResponse.json(responseJSON, { status: 201 });
}

Expand Down
2 changes: 1 addition & 1 deletion components/ConfirmationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function ConfirmationDialog({
title,
body,
btnTitle,
projectConfirmationAction,
projectConfirmationAction, // server action imported from _actions and passed down as prop
}: {
project: project;
title?: string;
Expand Down
10 changes: 9 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ const nextConfig = {
return [
{
source: '/api/v3/projects/:project_id/create-notice',
destination: '/api/v3/projects/:project_id/notices',
destination: '/api/v3/notices',
},
{
source: '/api/v3/projects/:project_id/notices',
destination: '/api/v3/notices',
},
{
source: '/notifier_api/v2/notices',
destination: '/api/v3/notices',
},
];
},
Expand Down

0 comments on commit e05bd1b

Please sign in to comment.