Add redirect to project after submission

This commit is contained in:
Max Wofford 2024-08-16 14:28:03 -04:00
parent 921b87ccef
commit f4e220a8cd
3 changed files with 10 additions and 4 deletions

View file

@ -6,11 +6,16 @@ import Submit from '../../submit'
const Loading = () => <div>Loading...</div>
const ErrorMsg = () => <div>There was an error loading your projects.</div>
async function projectAdded(response) {
const projectID = response.project
window.location.href = '/arcade/showcase/project/' + projectID
}
const NewProjectForm = ({authToken}) => {
console.log({authToken})
const { status, formProps, useField } = useForm(
'/api/arcade/showcase/projects/add',
null,
projectAdded,
{ initData: {authToken} },
)
return (
@ -18,6 +23,7 @@ const NewProjectForm = ({authToken}) => {
<form {...formProps}>
<Label>
<Text>Repo / code link</Text>
<Text color="muted">We'll pull in your project details from this repo</Text>
<Input
{...useField('codeLink')}
placeholder="https://github.com/hackclub/arcade"

View file

@ -51,7 +51,7 @@ const useForm = (
const response = await r.json()
if (r.ok) {
setStatus('success')
if (callback) callback(r)
if (callback) callback(response)
if (options.clearOnSubmit) {
setTimeout(() => {
setData({})

View file

@ -35,5 +35,5 @@ export default async function handler(req, res) {
"Play Link": playLink,
})
return res.status(200).json(project)
return res.status(200).json({ project: project.id })
}