-
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 #31 from VaquitApp/feature/list-group-users
Member List Page
- Loading branch information
Showing
10 changed files
with
198 additions
and
1 deletion.
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
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
9 changes: 9 additions & 0 deletions
9
my-app/src/routes/groups/members/[[id=integer]]/+page.server.ts
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,9 @@ | ||
import { groupService } from '$lib/server/api'; | ||
import type { PageServerLoad } from './$types'; | ||
|
||
export const load: PageServerLoad = async ({ params, cookies }) => { | ||
const id = Number(params.id) || 0; | ||
const group: Group = await groupService.get(id, cookies); | ||
const members: User[] = id ? await groupService.listAllMembers(id, cookies) : []; | ||
return { group, members }; | ||
}; |
35 changes: 35 additions & 0 deletions
35
my-app/src/routes/groups/members/[[id=integer]]/+page.svelte
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,35 @@ | ||
<script lang="ts"> | ||
import { ADD_USER_SVG } from '$lib/svgs'; | ||
import type { PageData } from './$types'; | ||
export let data: PageData; | ||
const pageTitle = `Miembros`; | ||
</script> | ||
|
||
<svelte:head> | ||
<title>{data.group.name} - {pageTitle}</title> | ||
</svelte:head> | ||
|
||
<nav aria-label="breadcrumb"> | ||
<ul> | ||
<li><a href="/groups">Grupos</a></li> | ||
<li>Miembros</li> | ||
</ul> | ||
</nav> | ||
|
||
<header class="row"> | ||
<h2 style="padding: 15px">Miembros de {data.group.name}</h2> | ||
<a class="secondary" href="/invites/send/{data.group.id}" role="button">{@html ADD_USER_SVG}</a> | ||
</header> | ||
|
||
{#each data.members as user} | ||
<p style="padding: 15px" class="row">{user.email}</p> | ||
{/each} | ||
|
||
<style> | ||
.row { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
} | ||
</style> |
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> |
30 changes: 30 additions & 0 deletions
30
my-app/src/routes/invites/send/[[id=integer]]/+page.server.ts
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 { groupService, inviteService } from '$lib/server/api'; | ||
import { error, redirect } from '@sveltejs/kit'; | ||
import type { Actions, PageServerLoad } from './$types'; | ||
import { getUserId } from '$lib/auth'; | ||
|
||
export const load: PageServerLoad = async ({ params, cookies }) => { | ||
const group_id = Number(params.id) || 0; | ||
const group: Group = await groupService.get(group_id, cookies); | ||
return { group }; | ||
}; | ||
|
||
export const actions: Actions = { | ||
default: async ({ cookies, request, params }) => { | ||
const group_id = Number(params.id) || 0; | ||
const data = await request.formData(); | ||
const email = data.get('email')?.toString(); | ||
|
||
if (!email) { | ||
throw error(400, 'Receiver Email is required'); | ||
} | ||
|
||
const invite: SendInvite = { | ||
sender_id: getUserId(cookies), | ||
receiver_email: email, | ||
group_id: group_id | ||
}; | ||
await inviteService.send(invite, cookies); | ||
redirect(302, `/groups/members/${group_id}`); | ||
} | ||
}; |
30 changes: 30 additions & 0 deletions
30
my-app/src/routes/invites/send/[[id=integer]]/+page.svelte
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 @@ | ||
<script lang="ts"> | ||
import type { PageData } from './$types'; | ||
export let data: PageData; | ||
const pageTitle = `Invitar`; | ||
</script> | ||
|
||
<svelte:head> | ||
<title>{data.group.name} - {pageTitle}</title> | ||
</svelte:head> | ||
|
||
<nav aria-label="breadcrumb"> | ||
<ul> | ||
<li><a href="/groups">Grupos</a></li> | ||
<li>Invitaciones</li> | ||
<li>Enviar</li> | ||
</ul> | ||
</nav> | ||
|
||
<h2>Invitar Usuario a {data.group.name}</h2> | ||
<form method="POST"> | ||
<fieldset> | ||
<label> | ||
Ingrese el email de la persona a ser invitada | ||
<input type="text" name="email" placeholder="Email Invitado" required /> | ||
</label> | ||
<button>Invitar</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