signup flow now works correctly
This commit is contained in:
parent
9b7adf9d8c
commit
7ef4f2b2ac
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue