Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link route election/joel #65

Merged
merged 7 commits into from
Oct 22, 2024
Merged

Link route election/joel #65

merged 7 commits into from
Oct 22, 2024

Conversation

Joel-leal
Copy link
Contributor

@Joel-leal Joel-leal commented Aug 12, 2024

Description

I added a new route to handle redirection based on an election ID. This route captures the ID from the URL to fetch election details from the database.

Changes

  • Defined a route that takes an election ID from the URL.
  • Redirected the user to a specific page based on the election ID.

Notes

  • In addition to creating the route task, I configured the environment variable.

Board issue

Copy link

vercel bot commented Aug 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
voting-system ⬜️ Ignored (Inspect) Oct 21, 2024 7:50pm

@Joel-leal Joel-leal requested a review from frattezi August 12, 2024 18:30
@Joel-leal Joel-leal force-pushed the link-route-election/joel branch from b696123 to e7f9f45 Compare September 12, 2024 14:38
@frattezi frattezi changed the base branch from main to form-election/joel September 12, 2024 14:46
Base automatically changed from form-election/joel to main September 12, 2024 14:47
@frattezi frattezi assigned frattezi and Joel-leal and unassigned frattezi Sep 12, 2024
prisma/schema.prisma Outdated Show resolved Hide resolved
Copy link
Contributor

@frattezi frattezi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minors, but looks good!

src/packages/components/HomePage/ElectionForm.tsx Outdated Show resolved Hide resolved
@frattezi
Copy link
Contributor

Remove the route.ts file under src/app/elections/route.ts

Copy link
Contributor

@frattezi frattezi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a minor comment

@@ -48,7 +48,7 @@ export async function startElection(formData: FormData) {
},
});

revalidatePath("/");
redirect(`http://localhost:3000/elections/${electionId}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to setup this as a environment var called APP_BASE_URL as this will change depending on environment.

With the redirect command, in this case here, you can also omit the base url and send only the paths ahead, like:

Suggested change
redirect(`http://localhost:3000/elections/${electionId}`);
redirect(`elections/${electionId}`);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for adding the env var as I mentioned if you follow this alternative

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change here 2b69f27

@Joel-leal Joel-leal merged commit cc16270 into main Oct 22, 2024
4 checks passed
@Joel-leal Joel-leal deleted the link-route-election/joel branch October 22, 2024 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redirect user to election after user starts an election in the home page
2 participants