🎨 Prettier formats the code
This commit is contained in:
@@ -1,16 +1,24 @@
|
||||
<template>
|
||||
<main class="flex items-center justify-center min-w-screen min-h-screen">
|
||||
<UButton icon="material-symbols:lock" size="xl" color="primary" variant="solid">Lock</UButton>
|
||||
</main>
|
||||
<main class="flex items-center justify-center min-w-screen min-h-screen">
|
||||
<UButton
|
||||
icon="material-symbols:lock"
|
||||
size="xl"
|
||||
color="primary"
|
||||
variant="solid"
|
||||
>
|
||||
Lock
|
||||
</UButton>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
const token = useToken()
|
||||
const token = useToken();
|
||||
const locked = true;
|
||||
|
||||
onMounted(() => {
|
||||
if (!token.value) {
|
||||
return navigateTo("/token")
|
||||
return navigateTo("/token");
|
||||
}
|
||||
console.log(token.value)
|
||||
})
|
||||
console.log(token.value);
|
||||
});
|
||||
</script>
|
||||
|
@@ -1,50 +1,57 @@
|
||||
<template>
|
||||
<main class="flex items-center justify-center min-w-screen min-h-screen">
|
||||
<UForm :schema="schema" :state="state" @submit="onSubmit" class="flex flex-col items-end justify-center gap-y-2">
|
||||
<UForm
|
||||
:schema="schema"
|
||||
:state="state"
|
||||
@submit="onSubmit"
|
||||
class="flex flex-col items-end justify-center gap-y-2"
|
||||
>
|
||||
<UFormField label="Token" name="token" size="xl" required>
|
||||
<UInput v-model="state.token" placeholder="Your token..." size="xl"/>
|
||||
<UInput
|
||||
v-model="state.token"
|
||||
placeholder="Your token..."
|
||||
size="xl"
|
||||
/>
|
||||
</UFormField>
|
||||
|
||||
<UButton type="submit" size="xl">
|
||||
Submit
|
||||
</UButton>
|
||||
<UButton type="submit" size="xl"> Submit </UButton>
|
||||
</UForm>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import * as v from "valibot"
|
||||
import type { FormSubmitEvent } from "@nuxt/ui"
|
||||
import * as v from "valibot";
|
||||
import type { FormSubmitEvent } from "@nuxt/ui";
|
||||
|
||||
const token = useToken()
|
||||
const token = useToken();
|
||||
|
||||
const schema = v.object({
|
||||
token: v.pipe(v.string(), v.nonEmpty("Please enter your token"))
|
||||
})
|
||||
type Schema = v.InferOutput<typeof schema>
|
||||
token: v.pipe(v.string(), v.nonEmpty("Please enter your token")),
|
||||
});
|
||||
type Schema = v.InferOutput<typeof schema>;
|
||||
|
||||
const state = reactive({
|
||||
token: ""
|
||||
})
|
||||
const toast = useToast()
|
||||
token: "",
|
||||
});
|
||||
const toast = useToast();
|
||||
|
||||
async function onSubmit(event: FormSubmitEvent<Schema>) {
|
||||
const token = event.data.token
|
||||
const token = event.data.token;
|
||||
const res = await $fetch("https://door.svitan.dev/open", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
console.log(token)
|
||||
console.log(res)
|
||||
toast.add({ title: "Token saved", color: "success" })
|
||||
console.log(token);
|
||||
console.log(res);
|
||||
toast.add({ title: "Token saved", color: "success" });
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (token.value) {
|
||||
return navigateTo("/")
|
||||
return navigateTo("/");
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user