Merge remote-tracking branch 'origin/main' into feat-campaign-server-side

This commit is contained in:
Damodar Lohani committed 2024-09-24 16:39:49 +05:45
commit c38438b5ef
22 files changed
+49 -70

No files matched your search

@@ -1,4 +1,6 @@
<script context="module" lang="ts">
let inputDigitFields: InputDigits;
export async function verify(challenge: Models.MfaChallenge, code: string) {
try {
if (challenge == null) {
@@ -10,6 +12,7 @@
await invalidate(Dependencies.ACCOUNT);
trackEvent(Submit.AccountCreate);
} catch (error) {
inputDigitFields?.clearInputsAndRefocus();
trackError(error, Submit.AccountCreate);
throw error;
}
@@ -81,7 +84,12 @@
{:else if challengeType == AuthenticationFactor.Phone}
<p>A 6-digit verification code was sent to your phone, enter it below.</p>
{/if}
<InputDigits bind:value={code} required autofocus {autoSubmit} />
<InputDigits
bind:value={code}
required
autofocus
{autoSubmit}
bind:this={inputDigitFields} />
{/if}
{#if showVerifyButton}
<FormItem>
+15
View File
@@ -38,6 +38,21 @@
}
});
/**
* Clears the input fields and moves the focus to the first input.
* Usually used when resetting fields on auth fails, etc.
*/
export function clearInputsAndRefocus() {
value = '';
autoSubmitted = false;
if (element) {
const inputs = element.querySelectorAll('input');
inputs.forEach((input) => (input.value = ''));
if (autofocus) inputs[0].focus();
}
}
onMount(() => {
const interval = setInterval(() => {
const input = element.querySelector('input');
+3 -15
View File
@@ -1,7 +1,6 @@
import { Client, type Models, Storage } from '@appwrite.io/console';
import type { Models } from '@appwrite.io/console';
import { writable } from 'svelte/store';
import { getProjectId } from '$lib/helpers/project';
import { VARS } from '$lib/system';
import { sdk } from './sdk';
type UploaderFile = {
$id: string;
@@ -18,17 +17,6 @@ export type Uploader = {
files: UploaderFile[];
};
const temporaryStorage = () => {
const endpoint = VARS.APPWRITE_ENDPOINT ?? `${globalThis?.location?.origin}/v1`;
const clientProject = new Client()
.setEndpoint(endpoint)
.setMode('admin')
.setProject(getProjectId());
return new Storage(clientProject);
};
const createUploader = () => {
const { subscribe, set, update } = writable<Uploader>({
isOpen: false,
@@ -83,7 +71,7 @@ const createUploader = () => {
n.files.unshift(newFile);
return n;
});
const uploadedFile = await temporaryStorage().createFile(
const uploadedFile = await sdk.forProject.storage.createFile(
bucketId,
id ?? 'unique()',
file,
@@ -78,7 +78,7 @@
content:
'You are limited to 1 free organization per account'
}}>
<Pill>FREE</Pill>
<Pill class="eyebrow-heading-3">FREE</Pill>
</div>
{/if}
{#if organization?.billingTrialStartDate && $daysLeftInTrial > 0 && organization.billingPlan !== BillingPlan.FREE && $plansInfo.get(organization.billingPlan)?.trialDays}
@@ -89,7 +89,7 @@
organization.billingStartDate
)}. ${$daysLeftInTrial} days remaining.`
}}>
<Pill>TRIAL</Pill>
<Pill class="eyebrow-heading-3">TRIAL</Pill>
</div>
{/if}
{/if}
@@ -108,7 +108,7 @@
{$organization.name}
</span>
{#if isCloud && $organization?.billingPlan === BillingPlan.FREE}
<Pill>FREE</Pill>
<Pill class="eyebrow-heading-3">FREE</Pill>
{/if}
{#if isCloud && $organization?.billingTrialStartDate && $daysLeftInTrial > 0 && $organization.billingPlan !== BillingPlan.FREE && $plansInfo.get($organization.billingPlan)?.trialDays}
<div
@@ -118,7 +118,7 @@
$organization.billingStartDate
)}. ${$daysLeftInTrial} days remaining.`
}}>
<Pill>TRIAL</Pill>
<Pill class="eyebrow-heading-3">TRIAL</Pill>
</div>
{/if}
</span>
@@ -26,7 +26,7 @@
await sdk.forProject.databases.updateBooleanAttribute(
databaseId,
collectionId,
data.key,
originalKey,
data.required,
data.default,
data.key !== originalKey ? data.key : undefined
@@ -27,7 +27,7 @@
await sdk.forProject.databases.updateDatetimeAttribute(
databaseId,
collectionId,
data.key,
originalKey,
data.required,
data.default,
data.key !== originalKey ? data.key : undefined
@@ -52,12 +52,16 @@
}
}
$: if (showEdit) {
currentAttr ??= { ...selectedAttribute };
originalKey = currentAttr.key;
error = null;
} else {
currentAttr = null;
$: onShow(showEdit);
function onShow(show: boolean) {
if (show) {
currentAttr ??= { ...selectedAttribute };
originalKey = currentAttr.key;
error = null;
} else {
currentAttr = null;
}
}
</script>
@@ -28,7 +28,7 @@
await sdk.forProject.databases.updateEmailAttribute(
databaseId,
collectionId,
data.key,
originalKey,
data.required,
data.default,
data.key !== originalKey ? data.key : undefined
@@ -28,7 +28,7 @@
await sdk.forProject.databases.updateEnumAttribute(
databaseId,
collectionId,
data.key,
originalKey,
data.elements,
data.required,
data.default,
@@ -29,7 +29,7 @@
await sdk.forProject.databases.updateFloatAttribute(
databaseId,
collectionId,
data.key,
originalKey,
data.required,
data.min,
data.max,
@@ -29,7 +29,7 @@
await sdk.forProject.databases.updateIntegerAttribute(
databaseId,
collectionId,
data.key,
originalKey,
data.required,
data.min,
data.max,
@@ -26,7 +26,7 @@
await sdk.forProject.databases.updateIpAttribute(
databaseId,
collectionId,
data.key,
originalKey,
data.required,
data.default,
data.key !== originalKey ? data.key : undefined
@@ -27,7 +27,7 @@
await sdk.forProject.databases.updateUrlAttribute(
databaseId,
collectionId,
data.key,
originalKey,
data.required,
data.default,
data.key !== originalKey ? data.key : undefined
@@ -50,7 +50,6 @@
import Create from './create-file/create.svelte';
import DeleteFile from './deleteFile.svelte';
import { isCloud } from '$lib/system';
import { onMount } from 'svelte';
export let data;
@@ -91,30 +90,6 @@
$: maxFileSize = isCloud
? humanFileSize(sizeToBytes(getServiceLimit('fileSize'), 'MB', 1000))
: null;
let isUploading = false;
const handleBeforeUnload = (event: BeforeUnloadEvent) => {
if (isUploading) {
event.preventDefault();
event.returnValue = 'An upload is in progress. Are you sure you want to leave?';
}
};
onMount(() => {
const unsubscribe = uploader.subscribe(() => {
isUploading = $uploader.files.some(
(file) => (!file.completed || file.progress < 100) && !file.failed
);
});
window.addEventListener('beforeunload', handleBeforeUnload);
return () => {
unsubscribe();
window.removeEventListener('beforeunload', handleBeforeUnload);
};
});
</script>
<Container>
@@ -51,17 +51,6 @@
await goto(`${base}/apply-credit?campaign=${data.campaign?.$id}`);
return;
}
if ($page.url.searchParams) {
const redirect = $page.url.searchParams.get('redirect');
$page.url.searchParams.delete('redirect');
if (redirect) {
await goto(`${redirect}${$page.url.search}`);
} else {
await goto(`${base}${$page.url.search ?? ''}`);
}
} else {
await goto(base);
}
} catch (error) {
disabled = false;
addNotification({
Binary file not shown.

After

Width:  |  Height:  |  Size: 417 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 KiB