diff --git a/api/src/routes/applications.ts b/api/src/routes/applications.ts index 78cfd79..a5970d5 100644 --- a/api/src/routes/applications.ts +++ b/api/src/routes/applications.ts @@ -22,8 +22,8 @@ router.post('/', async (req, res) => { res.sendStatus(201); } catch (err) { - console.error('Insert failed:', err); - res.status(500).json({ error: 'Failed to save application' }); + console.error('Failed to create application: \n', err); + res.status(500).json({ error: 'Failed to create application' }); } }); @@ -170,4 +170,15 @@ VALUES(?, ?, ?);` } }); +router.post('/restart', async (req: Request, res: Response) => { + const user = req.user.id; + try { + await setUserState(user, MemberState.Guest); + res.sendStatus(200); + } catch (error) { + console.error('Comment failed:', error); + res.status(500).json({ error: 'Could not rester application' }); + } +}) + module.exports = router; diff --git a/ui/src/api/application.ts b/ui/src/api/application.ts index 4193635..6e8fd4a 100644 --- a/ui/src/api/application.ts +++ b/ui/src/api/application.ts @@ -136,4 +136,15 @@ export async function denyApplication(id: Number) { if (!res.ok) { console.error("Something went wrong denying the application") } +} + +export async function restartApplication() { + const res = await fetch(`${addr}/application/restart`, { + method: 'POST', + credentials: 'include' + }) + + if (!res.ok) { + console.error("Something went wrong restarting your application") + } } \ No newline at end of file diff --git a/ui/src/pages/Join.vue b/ui/src/pages/Join.vue index 062011e..484f65f 100644 --- a/ui/src/pages/Join.vue +++ b/ui/src/pages/Join.vue @@ -14,6 +14,7 @@ import { useUserStore } from '@/stores/user'; import { Check, Circle, Dot, Users, X } from 'lucide-vue-next' import { computed, ref } from 'vue'; import Application from './Application.vue'; +import { restartApplication } from '@/api/application'; function goToLogin() { const redirectUrl = encodeURIComponent(window.location.origin + '/join') @@ -71,10 +72,18 @@ const currentStep = computed(() => { }) const finalPanel = ref<'app' | 'message'>('message'); + +const reloadKey = ref(0); + +async function restartApp() { + await restartApplication(); + await userStore.loadUser(); + reloadKey.value++; +}