Merge pull request #45 from appwrite/invite-page

feat: invite page
This commit is contained in:
Torsten Dittmann authored and GitHub committed 2022-09-09 16:17:30 +02:00
commit 50c7f15062
7 files changed
+144 -16

No files matched your search

+1
View File
@@ -15,5 +15,6 @@ export { default as InputSearch } from './inputSearch.svelte';
export { default as InputRadio } from './inputRadio.svelte';
export { default as InputSelect } from './inputSelect.svelte';
export { default as InputCheckbox } from './inputCheckbox.svelte';
export { default as InputChoice } from './inputChoice.svelte';
export { default as InputPhone } from './inputPhone.svelte';
export { default as Helper } from './helper.svelte';
+30
View File
@@ -0,0 +1,30 @@
<script lang="ts">
import { FormItem } from '.';
export let type: 'checkbox' | 'switchbox' = 'checkbox';
export let label: string;
export let showLabel = true;
export let id: string;
export let value = false;
export let required = false;
export let disabled = false;
</script>
<FormItem>
<label class="choice-item" for={id}>
<input
{id}
{disabled}
{required}
type="checkbox"
class:switch={type === 'switchbox'}
bind:checked={value} />
<div class="choice-item-content">
<div class:u-hide={!showLabel} class="choice-item-title">{label}</div>
{#if $$slots}
<p class="choice-item-paragraph"><slot /></p>
{/if}
</div>
</label>
</FormItem>
+10 -6
View File
@@ -3,6 +3,7 @@
import LoginLight from '$lib/images/login/login-light-mode.svg';
import LoginDark from '$lib/images/login/login-dark-mode.svg';
import { app } from '$lib/stores/app';
import { base } from '$app/paths';
const technologies = [
'js',
@@ -31,8 +32,9 @@
<div class="u-margin-block-start-auto" />
<div class="u-margin-block-start-auto is-no-mobile" />
<div
class="container u-margin-block-start-20"
class="container u-margin-block-start-20 is-no-mobile"
style="--p-container-max-size: var(--container-size-large);">
{#if $app.themeInUse === 'dark'}
<img src={LoginDark} alt="" class="u-only-dark" />
@@ -43,16 +45,18 @@
<div class="u-margin-block-start-auto" />
<div class="u-margin-block-start-auto is-no-mobile" />
<div
class="container u-text-color-light-gray is-only-desktop"
class="container u-text-color-light-gray is-no-mobile"
style="--p-container-max-size:var(--container-size-small); --p-container-padding-inline:1rem;">
<p>Integrate with your favourite technologies</p>
<ul
class="u-flex u-main-center u-flex-wrap u-gap-16 u-margin-block-start-32 u-line-height-1 ">
class="u-flex u-main-center u-flex-wrap u-gap-16 u-margin-block-start-32 u-line-height-1 u-opacity-0-5">
{#each technologies as tech}
<li>
<span
class={`icon-${tech} u-font-size-32`}
<img
src={`${base}/icons/${$app.themeInUse}/grayscale/${tech}.svg`}
alt={tech}
aria-hidden="true"
aria-label={tech} />
</li>
@@ -62,7 +66,7 @@
<div class="u-margin-block-start-40" />
</section>
<section class="grid-1-1-col-2 u-flex u-main-center u-cross-center">
<div class="container u-flex u-flex-vertical u-cross-center">
<div class="container u-flex u-flex-vertical u-cross-center u-height-100-percents">
<div class="u-margin-block-start-auto" />
<div class="u-max-width-500 u-width-full-line">
+5 -1
View File
@@ -23,6 +23,8 @@
window.GOOGLE_ANALYTICS = import.meta.env.VITE_GOOGLE_ANALYTICS?.toString() ?? false;
}
const acceptedRoutes = ['/login', '/register', '/recover', '/invite'];
onMount(async () => {
try {
if (!$user) {
@@ -33,7 +35,9 @@
await redirectTo();
}
} catch (error) {
await goto(`${base}/login`);
if (acceptedRoutes.includes($page.url.pathname)) {
await goto(`${base}${$page.url.pathname}${$page.url.search}`);
} else await goto(`${base}/login`);
} finally {
loaded = true;
}
@@ -14,7 +14,7 @@
const dispatch = createEventDispatcher();
let email: string, name: string, error: string;
const url = `${$page.url.origin}/console/`;
const url = `${$page.url.origin}/invite`;
const create = async () => {
try {
@@ -18,6 +18,7 @@
import type { Models } from '@aw-labs/appwrite-console';
import { pageLimit } from '$lib/stores/layout';
import { page } from '$app/stores';
import { addNotification } from '$lib/stores/notifications';
let search = '';
let offset: number = null;
@@ -29,14 +30,26 @@
const getAvatar = (name: string) =>
sdkForConsole.avatars.getInitials(name, 120, 120).toString();
const deleted = () => memberList.load($organization.$id, search, $pageLimit, offset ?? 0);
const resend = async (member: Models.Membership) =>
await sdkForConsole.teams.createMembership(
$organization.$id,
member.userEmail,
member.roles,
url,
member.userName
);
const resend = async (member: Models.Membership) => {
try {
await sdkForConsole.teams.createMembership(
$organization.$id,
member.userEmail,
member.roles,
url,
member.userName
);
addNotification({
type: 'success',
message: `Invite has been sent to ${member.userEmail}`
});
} catch (error) {
addNotification({
type: 'error',
message: error
});
}
};
$: if (search) offset = 0;
$: memberList.load($organization.$id, search, $pageLimit, offset ?? 0);
+76
View File
@@ -0,0 +1,76 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { base } from '$app/paths';
import { Button, Form, FormList, InputChoice } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdkForConsole } from '$lib/stores/sdk';
import { user } from '$lib/stores/user';
import { Unauthenticated } from '$lib/layout';
import { page } from '$app/stores';
import { onMount } from 'svelte';
let teamId: string, membershipId: string, userId: string, secret: string;
let terms = false;
onMount(() => {
userId = $page.url.searchParams.get('userId');
secret = $page.url.searchParams.get('secret');
teamId = $page.url.searchParams.get('teamId');
membershipId = $page.url.searchParams.get('membershipId');
});
const acceptInvite = async () => {
try {
await sdkForConsole.teams.updateMembershipStatus(teamId, membershipId, userId, secret);
await user.fetchUser();
addNotification({
type: 'success',
message: 'Successfully logged in.'
});
await goto(`${base}/console`);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
}
};
</script>
<svelte:head>
<title>Appwrite - Accept invite</title>
</svelte:head>
<Unauthenticated>
<svelte:fragment slot="title">Invite</svelte:fragment>
<svelte:fragment>
{#if !userId || !secret || !membershipId || !teamId}
<p class="text">Invalid invite link.</p>
{:else}
<p class="text">You have been invited to join a team project on Appwrite</p>
<Form on:submit={acceptInvite}>
<FormList>
<InputChoice
required
bind:value={terms}
id="terms"
label="terms"
showLabel={false}>
By accepting the invitation, you agree to the <a
class="link"
href="https://appwrite.io/policy/terms"
target="_blank">Terms and Conditions</a>
and
<a class="link" href="https://appwrite.io/policy/privacy" target="_blank">
Privacy Policy</a
>.</InputChoice>
<div class="u-flex u-main-end u-gap-12">
<Button secondary href={`${base}/login`}>Cancel</Button>
<Button submit>Accept</Button>
</div>
</FormList>
</Form>
{/if}
</svelte:fragment>
</Unauthenticated>