✨ Adds fetching and toggling alerts
This commit is contained in:
@@ -13,8 +13,8 @@ FROM oven/bun:1
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/.output .
|
||||
|
||||
ENV PORT 3000
|
||||
ENV HOST 0.0.0.0
|
||||
ENV PORT=3000
|
||||
ENV HOST=0.0.0.0
|
||||
|
||||
EXPOSE 3000
|
||||
CMD ["bun", "/app/server/index.mjs"]
|
||||
|
@@ -77,7 +77,7 @@
|
||||
:color="alert ? 'primary' : 'secondary'"
|
||||
variant="solid"
|
||||
class="flex items-center justify-center w-full h-10"
|
||||
@click="() => (alert = !alert)"
|
||||
@click="toggleAlert"
|
||||
>
|
||||
{{ alert ? "Turn off" : "Turn on" }}
|
||||
</UButton>
|
||||
@@ -119,6 +119,21 @@ async function toggleLock() {
|
||||
.catch(handleRequestError)
|
||||
}
|
||||
|
||||
async function toggleAlert() {
|
||||
const desired = !alert.value
|
||||
axios
|
||||
.post(useAPI("/alert"), { alert: desired }, { headers: useHeaders() })
|
||||
.then((res) => {
|
||||
handleResponse(res, () => {
|
||||
toast.add({
|
||||
title: `Alerts were turned ${desired ? "on" : "off"}`,
|
||||
})
|
||||
alert.value = desired
|
||||
})
|
||||
})
|
||||
.catch(handleRequestError)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (!token.value) {
|
||||
return navigateTo("/token")
|
||||
@@ -134,5 +149,16 @@ onMounted(() => {
|
||||
})
|
||||
})
|
||||
.catch(handleRequestError)
|
||||
|
||||
axios
|
||||
.get<boolean>(useAPI("/alert"), {
|
||||
headers: useHeaders(),
|
||||
})
|
||||
.then((res) => {
|
||||
handleResponse(res, (response) => {
|
||||
alert.value = response.data
|
||||
})
|
||||
})
|
||||
.catch(handleRequestError)
|
||||
})
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user