hook up logo upload

This commit is contained in:
Keviin Åberg Kultalahti 2021-05-12 14:43:36 +02:00
parent acf963ceb3
commit 46ac4b43a1
1 changed files with 18 additions and 16 deletions

View File

@ -1,5 +1,4 @@
<script> <script>
import { object, string } from "yup"
import { import {
Layout, Layout,
Heading, Heading,
@ -13,7 +12,7 @@
notifications, notifications,
} from "@budibase/bbui" } from "@budibase/bbui"
import { organisation } from "stores/portal" import { organisation } from "stores/portal"
import { api } from "builderStore/api" import { post } from "builderStore/api"
import analytics from "analytics" import analytics from "analytics"
let analyticsDisabled = analytics.disabled() let analyticsDisabled = analytics.disabled()
@ -33,25 +32,28 @@
async function uploadLogo() { async function uploadLogo() {
let data = new FormData() let data = new FormData()
data.append("files", file) data.append("file", file)
const res = await api.post("/api/admin/configs/upload/settings/logo") const res = await post("/api/admin/configs/upload/settings/logo", data, {})
return await res.json()
} }
async function saveConfig() { async function saveConfig() {
loading = true loading = true
await toggleAnalytics() await toggleAnalytics()
console.log("company", company) const res = await uploadLogo()
const res = await organisation.save({ console.log(res)
company: company || $organisation?.config?.company, // console.log("company", company)
// logoUrl, // const res = await organisation.save({
// platformUrl, // company: company || $organisation?.config?.company,
}) // // logoUrl,
if (res.status === 200) { // // platformUrl,
notifications.success("General settings saved.") // })
} else { // if (res.status === 200) {
notifications.danger("Error when saving settings.") // notifications.success("General settings saved.")
} // } else {
// notifications.danger("Error when saving settings.")
// }
loading = false loading = false
} }
</script> </script>
@ -84,8 +86,8 @@
<Label size="L">Logo</Label> <Label size="L">Logo</Label>
<div class="file"> <div class="file">
<Dropzone <Dropzone
label="Select Image"
value={[file]} value={[file]}
gallery={false}
on:change={e => { on:change={e => {
file = e.detail?.[0] file = e.detail?.[0]
}} }}