fix lint issue

This commit is contained in:
Maurits Lourens 2021-07-28 00:09:15 +02:00
parent f2b1125e0b
commit 3e88d6103d
3 changed files with 18 additions and 20 deletions

View File

@ -20,11 +20,11 @@
name: string().required("Your application must have a name"),
}
export let app;
export let app
let modal;
let modal
let valid = false
let dirty = false;
let dirty = false
$: checkValidity($values, validator)
$: {
// prevent validation by setting name to undefined without an app
@ -65,8 +65,8 @@
async function updateApp() {
try {
// Update App
await apps.update(app.instance._id, $values.name);
hide();
await apps.update(app.instance._id, $values.name)
hide()
} catch (error) {
console.error(error)
notifications.error(error)
@ -81,14 +81,14 @@
}
const onCancel = () => {
hide();
hide()
}
const onShow = () => {
dirty = false;
dirty = false
}
</script>
<Modal bind:this={modal} on:hide={onCancel} on:show={onShow}>
<ModalContent
title={"Update app"}
@ -104,7 +104,7 @@
bind:value={$values.name}
error={$touched.name && $errors.name}
on:blur={() => ($touched.name = true)}
on:change={() => dirty = true}
on:change={() => (dirty = true)}
label="Name"
/>
</ModalContent>

View File

@ -297,11 +297,7 @@
Are you sure you want to unpublish the app <b>{selectedApp?.name}</b>?
</ConfirmDialog>
<UpdateAppModal
app={selectedApp}
bind:this={updatingModal}
>
</UpdateAppModal>
<UpdateAppModal app={selectedApp} bind:this={updatingModal} />
<style>
.title,

View File

@ -1,7 +1,7 @@
import { writable } from "svelte/store"
import { get } from "builderStore/api"
import { AppStatus } from "../../constants"
import api from "../../builderStore/api";
import api from "../../builderStore/api"
export function createAppStore() {
const store = writable([])
@ -54,15 +54,17 @@ export function createAppStore() {
}
}
async function update (appId, name) {
async function update(appId, name) {
const response = await api.put(`/api/applications/${appId}`, { name })
if (response.status === 200) {
store.update(state => {
const updatedAppIndex = state.findIndex(app => app.instance._id === appId);
const updatedAppIndex = state.findIndex(
app => app.instance._id === appId
)
if (updatedAppIndex !== -1) {
const updatedApp = state[updatedAppIndex];
updatedApp.name = name;
state.apps = state.splice(updatedAppIndex, 1, updatedApp);
const updatedApp = state[updatedAppIndex]
updatedApp.name = name
state.apps = state.splice(updatedAppIndex, 1, updatedApp)
}
return state
})