1
0
Fork 0
mirror of synced 2024-06-27 18:40:42 +12:00

signup flow now works correctly

This commit is contained in:
kevmodrome 2020-08-03 16:26:28 +02:00
parent 2f10f51cd4
commit 667e70a706
No known key found for this signature in database
GPG key ID: E8F9CD141E63BF38
4 changed files with 34 additions and 17 deletions

View file

@ -1,14 +1,10 @@
<script>
import Button from "components/common/Button.svelte"
export let name,
description = `A minimalist CRM which removes the noise and allows you to focus
on your business.`,
_id
export let name, _id
</script>
<div class="apps-card">
<h3 class="app-title">{name}</h3>
<p class="app-desc">{description}</p>
<div class="card-footer">
<a href={`/_builder/${_id}`} class="app-button">Open {name}</a>
</div>

View file

@ -6,8 +6,9 @@
</script>
<script>
import { store, workflowStore, backendUiStore } from "builderStore"
import { string, object } from "yup"
import api from "builderStore/api"
import api, { get } from "builderStore/api"
import Form from "@svelteschool/svelte-forms"
import Spinner from "components/common/Spinner.svelte"
import { API, Info, User } from "./Steps"
@ -114,27 +115,48 @@
async function signUp() {
submitting = true
try {
// Add API key if there is none.
if (!hasKey) {
await updateKey(["budibase", $createAppStore.values.apiKey])
}
const response = await post("/api/applications", {
// Create App
const appResp = await post("/api/applications", {
name: $createAppStore.values.applicationName,
})
const res = await response.json()
const appJson = await appResp.json()
analytics.captureEvent("web_app_created", {
name,
description,
appId: res._id,
appId: appJson._id,
})
console.log("App created!")
// $goto(`./${res._id}`)
// Select Correct Application/DB in prep for creating user
const applicationPkg = await get(`/api/${appJson._id}/appPackage`)
const pkg = await applicationPkg.json()
if (applicationPkg.ok) {
backendUiStore.actions.reset()
await store.setPackage(pkg)
workflowStore.actions.fetch()
} else {
throw new Error(pkg)
}
// Create user
const user = {
name: $createAppStore.values.username,
username: $createAppStore.values.username,
password: $createAppStore.values.password,
accessLevelId: $createAppStore.values.accessLevelId,
}
const userResp = await api.post(`/api/users`, user)
const json = await userResp.json()
$goto(`./${appJson._id}`)
} catch (error) {
console.error(error)
}
}
async function updateKey([key, value]) {
console.log("Saving API Key")
const response = await api.put(`/api/keys/${key}`, { value })
const res = await response.json()
return res

View file

@ -1,3 +1,3 @@
export { default as API } from './API.svelte'
export { default as Info } from './Info.svelte'
export { default as User } from './User.svelte'
export { default as API } from "./API.svelte"
export { default as Info } from "./Info.svelte"
export { default as User } from "./User.svelte"

View file

@ -69,7 +69,6 @@ exports.create = async function(ctx) {
"@budibase/materialdesign-components",
],
name: ctx.request.body.name,
description: ctx.request.body.description,
}
const { rev } = await db.put(newApplication)