mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
feat: update sdk and small fixes
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
import { type Client, type Models } from '@appwrite.io/console';
|
||||
|
||||
export type MockNumber = {
|
||||
phone: string;
|
||||
otp: string;
|
||||
};
|
||||
|
||||
export type Project = Models.Project & {
|
||||
authMockNumbers: MockNumber[];
|
||||
};
|
||||
|
||||
export class Auth {
|
||||
client: Client;
|
||||
|
||||
constructor(client: Client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
async updateMockNumbers(projectId: string, numbers: MockNumber[]): Promise<Project> {
|
||||
const path = `/projects/${projectId}/auth/mock-numbers`;
|
||||
const params = {
|
||||
projectId,
|
||||
numbers: numbers
|
||||
};
|
||||
const uri = new URL(this.client.config.endpoint + path);
|
||||
return await this.client.call(
|
||||
'patch',
|
||||
uri,
|
||||
{
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
params
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
Vcs
|
||||
} from '@appwrite.io/console';
|
||||
import { Billing } from '../sdk/billing';
|
||||
import { Auth } from '$lib/sdk/auth';
|
||||
import { Sources } from '$lib/sdk/sources';
|
||||
|
||||
const endpoint = VARS.APPWRITE_ENDPOINT ?? `${globalThis?.location?.origin}/v1`;
|
||||
@@ -69,7 +68,6 @@ export const sdk = {
|
||||
health: new Health(clientConsole),
|
||||
locale: new Locale(clientConsole),
|
||||
projects: new Projects(clientConsole),
|
||||
auth: new Auth(clientConsole),
|
||||
teams: new Teams(clientConsole),
|
||||
users: new Users(clientConsole),
|
||||
migrations: new Migrations(clientConsole),
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import { CardGrid, Heading } from '$lib/components';
|
||||
import { InputPhone, InputText } from '$lib/elements/forms';
|
||||
import { Button, Form, FormItem, FormItemPart } from '$lib/elements/forms';
|
||||
import type { MockNumber } from '$lib/sdk/auth';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { project } from '../../store';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
@@ -11,18 +10,20 @@
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { writable } from 'svelte/store';
|
||||
import Empty from '$lib/components/empty.svelte';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
const numbers = writable<MockNumber[]>($project.authMockNumbers);
|
||||
const numbers = writable<Models.MockNumber[]>($project.authMockNumbers.numbers);
|
||||
let initialNumbers = [];
|
||||
let projectId: string = $project.$id;
|
||||
let submitDisabled = true;
|
||||
|
||||
$: initialNumbers = $project.authMockNumbers.map((num) => ({ ...num }));
|
||||
$: initialNumbers = $project.authMockNumbers.numbers.map((num) => ({ ...num }));
|
||||
$: submitDisabled = JSON.stringify($numbers) === JSON.stringify(initialNumbers);
|
||||
|
||||
async function updateMockNumbers() {
|
||||
try {
|
||||
await sdk.forConsole.auth.updateMockNumbers(projectId, $numbers);
|
||||
// TODO: fix once SDK is updated
|
||||
//@ts-expect-error $numbers is the wrong type in the SDK
|
||||
await sdk.forConsole.projects.updateMockNumbers(projectId, $numbers);
|
||||
await invalidate(Dependencies.PROJECT);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
@@ -38,7 +39,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
function addPhoneNumber(number: MockNumber) {
|
||||
function addPhoneNumber(number: Models.MockNumber) {
|
||||
numbers.update((n) => [
|
||||
...n,
|
||||
{
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { page } from '$app/stores';
|
||||
import type { Project } from '$lib/sdk/auth';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { BarSeriesOption } from 'echarts/charts';
|
||||
import { derived, writable } from 'svelte/store';
|
||||
|
||||
export const project = derived(
|
||||
page,
|
||||
($page) => $page.data.project as Project & { region?: string }
|
||||
($page) => $page.data.project as Models.Project & { region?: string }
|
||||
);
|
||||
export const onboarding = derived(
|
||||
project,
|
||||
|
||||
Reference in New Issue
Block a user