Verbrauchsausweis Test Vollständig, Besserer Login angefangen
This commit is contained in:
67
src/client/lib/spawnSignupPrompt.ts
Normal file
67
src/client/lib/spawnSignupPrompt.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { dialogs } from "../../../svelte-dialogs.config";
|
||||
import { addNotification } from "#components/Notifications/shared";
|
||||
import { client } from "src/trpc";
|
||||
|
||||
export async function spawnSignupPrompt() {
|
||||
const result = await dialogs.prompt(
|
||||
[
|
||||
{
|
||||
label: "Vorname",
|
||||
type: "text",
|
||||
required: true,
|
||||
placeholder: "Vorname",
|
||||
name: "vorname"
|
||||
},
|
||||
{
|
||||
label: "Name",
|
||||
type: "text",
|
||||
required: true,
|
||||
placeholder: "Name",
|
||||
name: "name"
|
||||
},
|
||||
{
|
||||
label: "Email",
|
||||
type: "email",
|
||||
required: true,
|
||||
placeholder: "Email",
|
||||
name: "email"
|
||||
},
|
||||
{
|
||||
label: "Passwort",
|
||||
type: "password",
|
||||
name: "passwort",
|
||||
required: true,
|
||||
placeholder: "********",
|
||||
},
|
||||
],
|
||||
{
|
||||
title: "Registrieren",
|
||||
submitButtonText: "Registrieren",
|
||||
cancelButtonText: "Abbrechen",
|
||||
}
|
||||
);
|
||||
|
||||
if (!result) return false;
|
||||
|
||||
const [vorname, name, email, passwort] = result;
|
||||
|
||||
try {
|
||||
const response = await client.v1.benutzer.erstellen.mutate({
|
||||
email,
|
||||
passwort,
|
||||
vorname,
|
||||
name,
|
||||
});
|
||||
|
||||
return true;
|
||||
} catch(e) {
|
||||
addNotification({
|
||||
type: "error",
|
||||
message: "Registrieren fehlgeschlagen",
|
||||
dismissable: true,
|
||||
subtext: "Ein Fehler ist aufgetreten, vielleicht wird die angegebene Email bereits verwendet.",
|
||||
timeout: 5000,
|
||||
})
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user