diff --git a/my-app/src/lib/server/api.ts b/my-app/src/lib/server/api.ts
index 58d6a0b..10a65c0 100644
--- a/my-app/src/lib/server/api.ts
+++ b/my-app/src/lib/server/api.ts
@@ -31,7 +31,7 @@ async function send(method: Method, { path, data, headers = {} }: Request) {
return text ? JSON.parse(text) : {};
}
- throw error(res.status);
+ throw error(res.status, await res.text());
}
function get(path: string, headers?: Headers) {
@@ -92,3 +92,9 @@ export const categoryService = {
get: (id: Id, cookies: Cookies) => get(`category/${id}`, getAuthHeader(cookies)),
list: (groupId: Id, cookies: Cookies) => get(`category/${groupId}`, getAuthHeader(cookies))
};
+export const inviteService = {
+ get: (token: string, cookies: Cookies) => get(`invite/${token}`, getAuthHeader(cookies)),
+ send: (data: SendInvite, cookies: Cookies) => post(`invite`, data, getAuthHeader(cookies)),
+ accept: (data: AcceptInvite, cookies: Cookies) =>
+ post(`invite/join/${data.token}`, undefined!, getAuthHeader(cookies))
+};
diff --git a/my-app/src/lib/svgs.ts b/my-app/src/lib/svgs.ts
index d4f46cb..7886c19 100644
--- a/my-app/src/lib/svgs.ts
+++ b/my-app/src/lib/svgs.ts
@@ -4,3 +4,6 @@ export const PENCIL_SVG =
export const INFO_SVG =
'';
+
+export const ADD_USER_SVG =
+ '';
diff --git a/my-app/src/routes/groups/+page.svelte b/my-app/src/routes/groups/+page.svelte
index c9b7d19..be50c8d 100644
--- a/my-app/src/routes/groups/+page.svelte
+++ b/my-app/src/routes/groups/+page.svelte
@@ -50,6 +50,7 @@
Editar grupo
+ Miembros
diff --git a/my-app/src/routes/groups/members/[[id=integer]]/+page.server.ts b/my-app/src/routes/groups/members/[[id=integer]]/+page.server.ts
new file mode 100644
index 0000000..905cd17
--- /dev/null
+++ b/my-app/src/routes/groups/members/[[id=integer]]/+page.server.ts
@@ -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 };
+};
diff --git a/my-app/src/routes/groups/members/[[id=integer]]/+page.svelte b/my-app/src/routes/groups/members/[[id=integer]]/+page.svelte
new file mode 100644
index 0000000..c42cd55
--- /dev/null
+++ b/my-app/src/routes/groups/members/[[id=integer]]/+page.svelte
@@ -0,0 +1,35 @@
+
+
+Miembros de {data.group.name}
+ {@html ADD_USER_SVG}
+
{user.email}
+{/each} + + diff --git a/my-app/src/routes/invites/accept/[id]/+page.server.ts b/my-app/src/routes/invites/accept/[id]/+page.server.ts new file mode 100644 index 0000000..536c8f0 --- /dev/null +++ b/my-app/src/routes/invites/accept/[id]/+page.server.ts @@ -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`); + } +}; diff --git a/my-app/src/routes/invites/accept/[id]/+page.svelte b/my-app/src/routes/invites/accept/[id]/+page.svelte new file mode 100644 index 0000000..87bd06a --- /dev/null +++ b/my-app/src/routes/invites/accept/[id]/+page.svelte @@ -0,0 +1,36 @@ + + +