🐳 Adds dockerfile
This commit is contained in:
@@ -47,7 +47,7 @@
|
||||
:color="locked ? 'primary' : 'secondary'"
|
||||
variant="solid"
|
||||
class="flex items-center justify-center w-full h-10"
|
||||
@click="() => (locked = !locked)"
|
||||
@click="toggleLock"
|
||||
>
|
||||
{{ locked ? "Unlock" : "Lock" }}
|
||||
</UButton>
|
||||
@@ -87,14 +87,44 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
const token = useToken()
|
||||
|
||||
const open = ref(true)
|
||||
const locked = ref(true)
|
||||
const alert = ref(false)
|
||||
|
||||
const toast = useToast()
|
||||
|
||||
async function toggleLock() {
|
||||
const desired = !locked.value
|
||||
await $fetch(useAPI("/lock"), {
|
||||
method: "POST",
|
||||
headers: useHeaders(),
|
||||
body: {
|
||||
locked: desired,
|
||||
},
|
||||
onRequestError: handleRequestError,
|
||||
onResponse: handleResponse(() => {
|
||||
toast.add({
|
||||
title: `The door was ${desired ? "locked" : "unlocked"}`,
|
||||
color: "success",
|
||||
})
|
||||
locked.value = desired
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (!token.value) {
|
||||
return navigateTo("/token")
|
||||
}
|
||||
console.log(token.value)
|
||||
|
||||
$fetch(useAPI("/lock"), {
|
||||
method: "GET",
|
||||
headers: useHeaders(),
|
||||
onRequestError: handleRequestError,
|
||||
onResponse: handleResponse(async (response) => {
|
||||
console.log("god: ", await response.json())
|
||||
}),
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
@@ -37,33 +37,17 @@ const toast = useToast()
|
||||
|
||||
async function onSubmit(event: FormSubmitEvent<Schema>) {
|
||||
const received = event.data.token
|
||||
await $fetch("https://door.svitan.dev/open", {
|
||||
await $fetch(useAPI("/open"), {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${received}`,
|
||||
},
|
||||
async onRequestError({ error }) {
|
||||
toast.add({
|
||||
title: "Error occurred",
|
||||
description: error.message,
|
||||
color: "error",
|
||||
})
|
||||
},
|
||||
async onResponse({ response }) {
|
||||
if (response.status === 200) {
|
||||
toast.add({ title: "Token saved", color: "success" })
|
||||
token.value = received
|
||||
navigateTo("/")
|
||||
} else if (response.status === 401) {
|
||||
toast.add({ title: "Token not valid", color: "error" })
|
||||
} else {
|
||||
toast.add({
|
||||
title: "Error occurred",
|
||||
description: await response.text(),
|
||||
color: "error",
|
||||
})
|
||||
}
|
||||
},
|
||||
onRequestError: handleRequestError,
|
||||
onResponse: handleResponse(() => {
|
||||
toast.add({ title: "Token saved", color: "success" })
|
||||
token.value = received
|
||||
navigateTo("/")
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user