|
|
|
@ -1,8 +1,10 @@ |
|
|
|
<script> |
|
|
|
import { ModalContent, Body, Input } from "@budibase/bbui" |
|
|
|
import { ModalContent, Body, Input, notifications } from "@budibase/bbui" |
|
|
|
import { createValidationStore, emailValidator } from "helpers/validation" |
|
|
|
import { users } from "stores/portal" |
|
|
|
|
|
|
|
const [email, error, touched] = createValidationStore("", emailValidator) |
|
|
|
const password = generatePassword() |
|
|
|
|
|
|
|
function generatePassword() { |
|
|
|
return Array(30) |
|
|
|
@ -21,9 +23,19 @@ |
|
|
|
) |
|
|
|
.join("") |
|
|
|
} |
|
|
|
|
|
|
|
async function createUser() { |
|
|
|
const res = await users.create({ email: $email, password }) |
|
|
|
if (res.status) { |
|
|
|
notifications.error(res.message) |
|
|
|
} else { |
|
|
|
notifications.success("Succesfully created user") |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<ModalContent |
|
|
|
onConfirm={createUser} |
|
|
|
size="M" |
|
|
|
title="Basic user onboarding" |
|
|
|
confirmText="Continue" |
|
|
|
@ -42,5 +54,5 @@ |
|
|
|
bind:value={$email} |
|
|
|
error={$touched && $error} |
|
|
|
/> |
|
|
|
<Input disabled label="Password" value={generatePassword()} /> |
|
|
|
<Input disabled label="Password" value={password} /> |
|
|
|
</ModalContent> |
|
|
|
|