-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from VaquitApp/feature/receive-invite
Feat: receive invite
- Loading branch information
Showing
6 changed files
with
88 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { inviteService } from '$lib/server/api'; | ||
import { error, redirect } from '@sveltejs/kit'; | ||
import type { Actions, PageServerLoad } from './$types'; | ||
|
||
export const load: PageServerLoad = async ({ params, cookies }) => { | ||
const token = params.id || ''; | ||
const invite: Invite = await inviteService.get(token, cookies); | ||
return { invite }; | ||
}; | ||
|
||
export const actions: Actions = { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
default: async ({ cookies, request, params }) => { | ||
const token = params.id || ''; | ||
|
||
// TODO: El metodo getGroup esta restringido a solo lectura de usuarios que ya forman parte del team | ||
// La idea era en el formulario mostrar el nombre y descripcion del grupo, pero por ahora estamos ok | ||
// con esto. | ||
|
||
if (!token || !token.length) { | ||
throw error(400, 'Token is required'); | ||
} | ||
|
||
const invite: AcceptInvite = { | ||
token: token | ||
}; | ||
await inviteService.accept(invite, cookies); | ||
redirect(302, `/groups`); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script lang="ts"> | ||
import { title } from '$lib'; | ||
import type { PageData } from './$types'; | ||
export let data: PageData; | ||
const pageTitle = `Unirse`; | ||
</script> | ||
|
||
<svelte:head> | ||
<title>{title} - {pageTitle}</title> | ||
</svelte:head> | ||
|
||
<nav aria-label="breadcrumb"> | ||
<ul> | ||
<li><a href="/groups">Grupos</a></li> | ||
<li>Invitaciones</li> | ||
<li>Aceptar</li> | ||
</ul> | ||
</nav> | ||
|
||
<h2>¡Has sido Invitad@ a un grupo!</h2> | ||
<form method="POST"> | ||
<fieldset> | ||
<!--TODO: TRAERNOS DATOS DEL GRUPO..--> | ||
<label> | ||
ID del Grupo | ||
<input type="text" name="group_id" value={data.invite.group_id} disabled /> | ||
</label> | ||
<label> | ||
Token de la Invitación | ||
<input type="text" name="token" value={data.invite.token} disabled /> | ||
</label> | ||
<button>Unirse</button> | ||
<button type="button" class="outline" on:click={() => history.back()}>Cancelar</button> | ||
</fieldset> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
<ul> | ||
<li><a href="/groups">Grupos</a></li> | ||
<li>Invitaciones</li> | ||
<li>Enviar</li> | ||
</ul> | ||
</nav> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters