mirror of
https://github.com/System-End/site.git
synced 2026-04-19 16:28:21 +00:00
Add redirect to project after submission
This commit is contained in:
parent
921b87ccef
commit
f4e220a8cd
3 changed files with 10 additions and 4 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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({})
|
||||
|
|
|
|||
|
|
@ -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 })
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue