diff --git a/frontend/components/Domain/Recipe/RecipeIngredients.vue b/frontend/components/Domain/Recipe/RecipeIngredients.vue index 4a13321e..1b84e1a7 100644 --- a/frontend/components/Domain/Recipe/RecipeIngredients.vue +++ b/frontend/components/Domain/Recipe/RecipeIngredients.vue @@ -9,7 +9,7 @@

{{ ingredient.title }}

- + diff --git a/frontend/composables/api/use-app-info.ts b/frontend/composables/api/use-app-info.ts index 95446753..950b3115 100644 --- a/frontend/composables/api/use-app-info.ts +++ b/frontend/composables/api/use-app-info.ts @@ -1,13 +1,16 @@ -import { onMounted, ref, Ref } from "@nuxtjs/composition-api"; +import { ref, Ref, useAsync, useContext } from "@nuxtjs/composition-api"; +import { useAsyncKey } from "../use-utils"; import { AppInfo } from "~/types/api-types/admin"; export function useAppInfo(): Ref { const appInfo = ref(null); - onMounted(async () => { - const data = await fetch("/api/app/about").then((res) => res.json()); - appInfo.value = data as AppInfo; - }); + const { $axios } = useContext(); + + useAsync(async () => { + const data = await $axios.get("/api/app/about"); + appInfo.value = data.data; + }, useAsyncKey()); return appInfo; } diff --git a/frontend/composables/use-password-field.ts b/frontend/composables/use-password-field.ts new file mode 100644 index 00000000..de89b22c --- /dev/null +++ b/frontend/composables/use-password-field.ts @@ -0,0 +1,22 @@ +import { computed, ref, useContext } from "@nuxtjs/composition-api"; + +export function usePasswordField() { + const show = ref(false); + + const { $globals } = useContext(); + + const passwordIcon = computed(() => { + return show.value ? $globals.icons.eyeOff : $globals.icons.eye; + }); + const inputType = computed(() => (show.value ? "text" : "password")); + + const togglePasswordShow = () => { + show.value = !show.value; + }; + + return { + inputType, + togglePasswordShow, + passwordIcon, + }; +} diff --git a/frontend/pages/login.vue b/frontend/pages/login.vue index f93c09f5..fc976052 100644 --- a/frontend/pages/login.vue +++ b/frontend/pages/login.vue @@ -25,7 +25,7 @@ Sign In - + @@ -110,6 +112,7 @@ import { defineComponent, ref, useContext, computed, reactive } from "@nuxtjs/composition-api"; import { useDark } from "@vueuse/core"; import { useAppInfo } from "~/composables/api"; +import { usePasswordField } from "~/composables/use-password-field"; import { alert } from "~/composables/use-toast"; import { useToggleDarkMode } from "~/composables/use-utils"; export default defineComponent({ @@ -131,6 +134,8 @@ export default defineComponent({ const appInfo = useAppInfo(); + const { passwordIcon, inputType, togglePasswordShow } = usePasswordField(); + const allowSignup = computed(() => appInfo.value?.allowSignup || false); async function authenticate() { @@ -169,6 +174,9 @@ export default defineComponent({ allowSignup, authenticate, toggleDark, + passwordIcon, + inputType, + togglePasswordShow, }; },