mirror of
https://github.com/Discreetly/frontend.git
synced 2026-01-08 20:38:04 -05:00
merge refinement
This commit is contained in:
@@ -1,84 +1,86 @@
|
||||
<script lang="ts">
|
||||
import { createRoom } from '$lib/services/server';
|
||||
import { getIdentity } from '$lib/utils';
|
||||
import { selectedServer, configStore } from '$lib/stores'
|
||||
import { Stepper } from '@skeletonlabs/skeleton'
|
||||
import { goto } from '$app/navigation';
|
||||
import RoomName from './1_RoomName.svelte'
|
||||
import MembershipType from './2_MembershipType.svelte'
|
||||
import RateLimit from './3_RateLimit.svelte';
|
||||
import MessageLimit from './4_MessageLimit.svelte';
|
||||
import ClaimCodes from './5_ClaimCodes.svelte';
|
||||
import type { RoomFormData } from '$lib/types';
|
||||
import { createRoom } from '$lib/services/server';
|
||||
import { getCommitment, getIdentity } from '$lib/utils';
|
||||
import { selectedServer, configStore, alertQueue } from '$lib/stores';
|
||||
import { Stepper } from '@skeletonlabs/skeleton';
|
||||
import RoomName from './1_RoomName.svelte';
|
||||
import MembershipType from './2_MembershipType.svelte';
|
||||
import RateLimit from './3_RateLimit.svelte';
|
||||
import MessageLimit from './4_MessageLimit.svelte';
|
||||
import ClaimCodes from './5_ClaimCodes.svelte';
|
||||
import type { RoomFormData } from '$lib/types';
|
||||
|
||||
let formData: RoomFormData = {
|
||||
roomName: "",
|
||||
membershipType: 'IDENTITY_LIST',
|
||||
rateLimit: 10,
|
||||
messageLimit: 3,
|
||||
claimCodes: 0,
|
||||
roomType: 'PUBLIC',
|
||||
bandadaAddress: undefined,
|
||||
bandadaGroupId: undefined,
|
||||
bandadaApiKey: undefined,
|
||||
};
|
||||
let formData: RoomFormData = {
|
||||
roomName: '',
|
||||
membershipType: 'IDENTITY_LIST',
|
||||
rateLimit: 10,
|
||||
messageLimit: 3,
|
||||
claimCodes: 0,
|
||||
roomType: 'PUBLIC',
|
||||
bandadaAddress: undefined,
|
||||
bandadaGroupId: undefined,
|
||||
bandadaApiKey: undefined
|
||||
};
|
||||
|
||||
let createdCodes: string[] | undefined = [];
|
||||
let submitted = false;
|
||||
|
||||
function handleSubmit (): void {
|
||||
const identity = getIdentity();
|
||||
formData.rateLimit = formData.rateLimit * 1000
|
||||
createRoom(
|
||||
$selectedServer,
|
||||
formData.roomName,
|
||||
$configStore.apiUsername as string,
|
||||
$configStore.apiPassword as string,
|
||||
formData.rateLimit,
|
||||
formData.messageLimit,
|
||||
formData.claimCodes,
|
||||
[identity._commitment],
|
||||
formData.membershipType,
|
||||
formData.roomType,
|
||||
formData.bandadaAddress,
|
||||
formData.bandadaGroupId,
|
||||
formData.bandadaApiKey,
|
||||
).then((res) => {
|
||||
console.log(res);
|
||||
submitted = true;
|
||||
createdCodes = res.claimCodes;
|
||||
console.log(createdCodes)
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
let createdCodes: string[] | undefined = [];
|
||||
let submitted = false;
|
||||
|
||||
function handleSubmit(): void {
|
||||
const idc = getCommitment();
|
||||
formData.rateLimit = formData.rateLimit * 1000;
|
||||
if (idc) {
|
||||
createRoom(
|
||||
$selectedServer,
|
||||
formData.roomName,
|
||||
$configStore.apiUsername as string,
|
||||
$configStore.apiPassword as string,
|
||||
formData.rateLimit,
|
||||
formData.messageLimit,
|
||||
formData.claimCodes,
|
||||
[idc],
|
||||
formData.membershipType,
|
||||
formData.roomType,
|
||||
formData.bandadaAddress,
|
||||
formData.bandadaGroupId,
|
||||
formData.bandadaApiKey
|
||||
).then((res) => {
|
||||
console.log(res);
|
||||
submitted = true;
|
||||
createdCodes = res.claimCodes;
|
||||
console.log(createdCodes);
|
||||
});
|
||||
} else {
|
||||
alertQueue.enqueue('You must create an identity before creating a room', 'error');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="grid grid-flow-rows gap-7 my-5 max-w-md mx-auto">
|
||||
<h1 class="text-3xl text-center">Create a Room</h1>
|
||||
<Stepper class="max-w-sm sm:max-w-md md:max-w-3xl mx-auto mt-16"
|
||||
on:complete={() => {
|
||||
handleSubmit();
|
||||
}}
|
||||
buttonNext="variant-filled-surface-50-900-token"
|
||||
buttonComplete="variant-filled-success">
|
||||
<RoomName {formData} />
|
||||
<MembershipType {formData} />
|
||||
<RateLimit {formData} />
|
||||
<MessageLimit {formData} />
|
||||
<ClaimCodes {formData} />
|
||||
</Stepper>
|
||||
{#if submitted && createdCodes}
|
||||
<div class="grid grid-flow-rows gap-7 my-5 max-w-md mx-auto">
|
||||
<h1 class="text-3xl text-center">Your Room Codes</h1>
|
||||
<div class="grid grid-flow-rows gap-7 my-5 max-w-md mx-auto">
|
||||
{#each createdCodes as code}
|
||||
<div class="grid grid-flow-rows gap-7 my-5 max-w-md mx-auto">
|
||||
<i class="text-center">https://app.discreetly.chat/join/{Object.values(code)}</i>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<h1 class="text-3xl text-center">Create a Room</h1>
|
||||
<Stepper
|
||||
class="max-w-sm sm:max-w-md md:max-w-3xl mx-auto mt-16"
|
||||
on:complete={() => {
|
||||
handleSubmit();
|
||||
}}
|
||||
buttonNext="variant-filled-surface-50-900-token"
|
||||
buttonComplete="variant-filled-success"
|
||||
>
|
||||
<RoomName {formData} />
|
||||
<MembershipType {formData} />
|
||||
<RateLimit {formData} />
|
||||
<MessageLimit {formData} />
|
||||
<ClaimCodes {formData} />
|
||||
</Stepper>
|
||||
{#if submitted && createdCodes}
|
||||
<div class="grid grid-flow-rows gap-7 my-5 max-w-md mx-auto">
|
||||
<h1 class="text-3xl text-center">Your Room Codes</h1>
|
||||
<div class="grid grid-flow-rows gap-7 my-5 max-w-md mx-auto">
|
||||
{#each createdCodes as code}
|
||||
<div class="grid grid-flow-rows gap-7 my-5 max-w-md mx-auto">
|
||||
<i class="text-center">https://app.discreetly.chat/join/{Object.values(code)}</i>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
<script lang="ts">
|
||||
import Introduction from './1_Introduction.svelte';
|
||||
import IdentityGeneration from './2_IdentityGeneration.svelte';
|
||||
import Join from './3_Join.svelte';
|
||||
import Backup from './4_Backup.svelte';
|
||||
import { configStore } from '$lib/stores';
|
||||
import Loading from '$lib/components/loading.svelte';
|
||||
import { Stepper, Step } from '@skeletonlabs/skeleton';
|
||||
import { goto } from '$app/navigation';
|
||||
import { IdentityStoreE } from '$lib/types';
|
||||
</script>
|
||||
|
||||
<div class="h-100 mt-2 mx-2 md:mx-4">
|
||||
|
||||
Reference in New Issue
Block a user