mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
Fix more typing issues (#928)
* Fix or comment several ts-ignores * Fix typing related to BaseOverflowButton * Remove unused functionality of useCookbooks, fix usage bug * Fix more typing, add some comments * Only allow ts-ignore if it has a comment
This commit is contained in:
parent
c4540f1395
commit
f794208862
@ -42,8 +42,13 @@ module.exports = {
|
|||||||
allowModifiers: true,
|
allowModifiers: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"@typescript-eslint/ban-ts-comment": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"ts-ignore": "allow-with-description",
|
||||||
|
},
|
||||||
|
],
|
||||||
// TODO Gradually activate all rules
|
// TODO Gradually activate all rules
|
||||||
"@typescript-eslint/ban-ts-comment": "off",
|
|
||||||
"@typescript-eslint/no-unsafe-assignment": "off",
|
"@typescript-eslint/no-unsafe-assignment": "off",
|
||||||
"@typescript-eslint/no-unsafe-member-access": "off",
|
"@typescript-eslint/no-unsafe-member-access": "off",
|
||||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { BaseCRUDAPI } from "../_base";
|
import { BaseCRUDAPI } from "../_base";
|
||||||
import { UserRead } from "./admin-users";
|
import { UserOut } from "~/types/api-types/user";
|
||||||
const prefix = "/api";
|
const prefix = "/api";
|
||||||
|
|
||||||
export interface Token {
|
export interface Token {
|
||||||
@ -29,7 +29,7 @@ export interface GroupRead extends GroupCreate {
|
|||||||
id: number;
|
id: number;
|
||||||
categories: any[];
|
categories: any[];
|
||||||
webhooks: any[];
|
webhooks: any[];
|
||||||
users: UserRead[];
|
users: UserOut[];
|
||||||
preferences: Preferences;
|
preferences: Preferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,39 +1,14 @@
|
|||||||
import { BaseCRUDAPI } from "../_base";
|
import { BaseCRUDAPI } from "../_base";
|
||||||
|
import { UserIn, UserOut } from "~/types/api-types/user";
|
||||||
|
|
||||||
const prefix = "/api";
|
const prefix = "/api";
|
||||||
|
|
||||||
export interface UserCreate {
|
|
||||||
username: string;
|
|
||||||
fullName: string;
|
|
||||||
email: string;
|
|
||||||
admin: boolean;
|
|
||||||
group: string;
|
|
||||||
advanced: boolean;
|
|
||||||
canInvite: boolean;
|
|
||||||
canManage: boolean;
|
|
||||||
canOrganize: boolean;
|
|
||||||
password: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UserToken {
|
|
||||||
name: string;
|
|
||||||
id: number;
|
|
||||||
createdAt: Date;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UserRead extends UserToken {
|
|
||||||
id: number;
|
|
||||||
groupId: number;
|
|
||||||
favoriteRecipes: any[];
|
|
||||||
tokens: UserToken[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const routes = {
|
const routes = {
|
||||||
adminUsers: `${prefix}/admin/users`,
|
adminUsers: `${prefix}/admin/users`,
|
||||||
adminUsersId: (tag: string) => `${prefix}/admin/users/${tag}`,
|
adminUsersId: (tag: string) => `${prefix}/admin/users/${tag}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
export class AdminUsersApi extends BaseCRUDAPI<UserRead, UserCreate> {
|
export class AdminUsersApi extends BaseCRUDAPI<UserOut, UserIn> {
|
||||||
baseRoute: string = routes.adminUsers;
|
baseRoute: string = routes.adminUsers;
|
||||||
itemRoute = routes.adminUsersId;
|
itemRoute = routes.adminUsersId;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,6 @@ export class RecipeAPI extends BaseCRUDAPI<Recipe, CreateRecipe> {
|
|||||||
|
|
||||||
async createAsset(recipeSlug: string, payload: CreateAsset) {
|
async createAsset(recipeSlug: string, payload: CreateAsset) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
// @ts-ignore
|
|
||||||
formData.append("file", payload.file);
|
formData.append("file", payload.file);
|
||||||
formData.append("name", payload.name);
|
formData.append("name", payload.name);
|
||||||
formData.append("extension", payload.extension);
|
formData.append("extension", payload.extension);
|
||||||
@ -65,8 +64,7 @@ export class RecipeAPI extends BaseCRUDAPI<Recipe, CreateRecipe> {
|
|||||||
updateImage(slug: string, fileObject: File) {
|
updateImage(slug: string, fileObject: File) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("image", fileObject);
|
formData.append("image", fileObject);
|
||||||
// @ts-ignore
|
formData.append("extension", fileObject.name.split(".").pop() ?? "");
|
||||||
formData.append("extension", fileObject.name.split(".").pop());
|
|
||||||
|
|
||||||
return this.requests.put<any>(routes.recipesRecipeSlugImage(slug), formData);
|
return this.requests.put<any>(routes.recipesRecipeSlugImage(slug), formData);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ export interface CreateAsset {
|
|||||||
name: string;
|
name: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
extension: string;
|
extension: string;
|
||||||
file?: File;
|
file: File;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RecipeCommentCreate {
|
export interface RecipeCommentCreate {
|
||||||
|
@ -1,33 +1,19 @@
|
|||||||
import { BaseCRUDAPI } from "../_base";
|
import { BaseCRUDAPI } from "../_base";
|
||||||
import { Recipe } from "~/types/api-types/recipe";
|
import { RecipeTool, RecipeToolCreate, RecipeToolResponse } from "~/types/api-types/recipe";
|
||||||
|
|
||||||
const prefix = "/api";
|
const prefix = "/api";
|
||||||
|
|
||||||
export interface CreateTool {
|
|
||||||
name: string;
|
|
||||||
onHand: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Tool extends CreateTool {
|
|
||||||
id: number;
|
|
||||||
slug: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RecipeToolResponse extends Tool {
|
|
||||||
recipes: Recipe[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const routes = {
|
const routes = {
|
||||||
tools: `${prefix}/tools`,
|
tools: `${prefix}/tools`,
|
||||||
toolsId: (id: string) => `${prefix}/tools/${id}`,
|
toolsId: (id: string) => `${prefix}/tools/${id}`,
|
||||||
toolsSlug: (id: string) => `${prefix}/tools/slug/${id}`,
|
toolsSlug: (id: string) => `${prefix}/tools/slug/${id}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
export class ToolsApi extends BaseCRUDAPI<Tool, CreateTool> {
|
export class ToolsApi extends BaseCRUDAPI<RecipeTool, RecipeToolCreate> {
|
||||||
baseRoute: string = routes.tools;
|
baseRoute: string = routes.tools;
|
||||||
itemRoute = routes.toolsId;
|
itemRoute = routes.toolsId;
|
||||||
|
|
||||||
async byslug(slug: string) {
|
async byslug(slug: string) {
|
||||||
return await this.requests.get<Tool>(routes.toolsSlug(slug));
|
return await this.requests.get<RecipeToolResponse>(routes.toolsSlug(slug));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,18 @@ import { BaseAPI } from "../_base";
|
|||||||
|
|
||||||
const prefix = "/api";
|
const prefix = "/api";
|
||||||
|
|
||||||
|
interface DownloadData {
|
||||||
|
fileToken: string,
|
||||||
|
}
|
||||||
|
|
||||||
export class UtilsAPI extends BaseAPI {
|
export class UtilsAPI extends BaseAPI {
|
||||||
async download(url: string) {
|
async download(url: string) {
|
||||||
const { response } = await this.requests.get(url);
|
const { response } = await this.requests.get<DownloadData>(url);
|
||||||
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
const token: string = response.data.fileToken;
|
const token: string = response.data.fileToken;
|
||||||
|
|
||||||
const tokenURL = prefix + "/utils/download?token=" + token;
|
const tokenURL = prefix + "/utils/download?token=" + token;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
v-on="on"
|
v-on="on"
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
</template>
|
</template>
|
||||||
<v-date-picker v-model="expirationDate" no-title @input="pickerMenu = false"></v-date-picker>
|
<v-date-picker v-model="expirationDate" no-title @input="datePickerMenu = false"></v-date-picker>
|
||||||
</v-menu>
|
</v-menu>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions class="justify-end">
|
<v-card-actions class="justify-end">
|
||||||
@ -178,4 +178,4 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, defineComponent, reactive, toRefs } from "@nuxtjs/composition-api";
|
import { computed, defineComponent, reactive, toRefs } from "@nuxtjs/composition-api";
|
||||||
// @ts-ignore
|
// @ts-ignore vue-markdown has no types
|
||||||
import VueMarkdown from "@adapttive/vue-markdown";
|
import VueMarkdown from "@adapttive/vue-markdown";
|
||||||
import { parseIngredientText } from "~/composables/recipes";
|
import { parseIngredientText } from "~/composables/recipes";
|
||||||
import { RecipeIngredient } from "~/types/api-types/recipe";
|
import { RecipeIngredient } from "~/types/api-types/recipe";
|
||||||
|
@ -178,7 +178,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import draggable from "vuedraggable";
|
import draggable from "vuedraggable";
|
||||||
// @ts-ignore
|
// @ts-ignore vue-markdown has no types
|
||||||
import VueMarkdown from "@adapttive/vue-markdown";
|
import VueMarkdown from "@adapttive/vue-markdown";
|
||||||
import { ref, toRefs, reactive, defineComponent, watch, onMounted } from "@nuxtjs/composition-api";
|
import { ref, toRefs, reactive, defineComponent, watch, onMounted } from "@nuxtjs/composition-api";
|
||||||
import { RecipeStep, IngredientReferences, RecipeIngredient } from "~/types/api-types/recipe";
|
import { RecipeStep, IngredientReferences, RecipeIngredient } from "~/types/api-types/recipe";
|
||||||
|
@ -32,9 +32,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
// @ts-ignore
|
// @ts-ignore vue-markdown has no types
|
||||||
import VueMarkdown from "@adapttive/vue-markdown";
|
import VueMarkdown from "@adapttive/vue-markdown";
|
||||||
import { defineComponent } from "@nuxtjs/composition-api";
|
import { defineComponent } from "@nuxtjs/composition-api";
|
||||||
|
import { RecipeNote } from "~/types/api-types/recipe";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -42,7 +43,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
type: Array,
|
type: Array as () => RecipeNote[],
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from "@nuxtjs/composition-api";
|
import { defineComponent } from "@nuxtjs/composition-api";
|
||||||
// @ts-ignore
|
// @ts-ignore vue-markdown has no types
|
||||||
import VueMarkdown from "@adapttive/vue-markdown";
|
import VueMarkdown from "@adapttive/vue-markdown";
|
||||||
import RecipeTimeCard from "~/components/Domain/Recipe/RecipeTimeCard.vue";
|
import RecipeTimeCard from "~/components/Domain/Recipe/RecipeTimeCard.vue";
|
||||||
import { Recipe } from "~/types/api-types/recipe";
|
import { Recipe } from "~/types/api-types/recipe";
|
||||||
|
@ -47,13 +47,13 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, ref, computed } from "@nuxtjs/composition-api";
|
import { defineComponent, ref, computed } from "@nuxtjs/composition-api";
|
||||||
import { Tool } from "~/api/class-interfaces/tools";
|
import { RecipeTool } from "~/types/api-types/recipe";
|
||||||
import { useTools } from "~/composables/recipes";
|
import { useTools } from "~/composables/recipes";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
type: Array as () => Tool[],
|
type: Array as () => RecipeTool[],
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
edit: {
|
edit: {
|
||||||
|
@ -42,7 +42,7 @@ export interface ButtonOption {
|
|||||||
icon: string;
|
icon: string;
|
||||||
text: string;
|
text: string;
|
||||||
event: string;
|
event: string;
|
||||||
children: ButtonOption[];
|
children?: ButtonOption[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
@ -136,8 +136,6 @@ export default defineComponent({
|
|||||||
watch: {
|
watch: {
|
||||||
determineClose() {
|
determineClose() {
|
||||||
this.submitted = false;
|
this.submitted = false;
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
this.dialog = false;
|
this.dialog = false;
|
||||||
},
|
},
|
||||||
dialog(val) {
|
dialog(val) {
|
||||||
@ -155,12 +153,10 @@ export default defineComponent({
|
|||||||
this.submitted = true;
|
this.submitted = true;
|
||||||
},
|
},
|
||||||
open() {
|
open() {
|
||||||
// @ts-ignore
|
|
||||||
this.dialog = true;
|
this.dialog = true;
|
||||||
this.logDeprecatedProp("open");
|
this.logDeprecatedProp("open");
|
||||||
},
|
},
|
||||||
close() {
|
close() {
|
||||||
// @ts-ignore
|
|
||||||
this.dialog = false;
|
this.dialog = false;
|
||||||
this.logDeprecatedProp("close");
|
this.logDeprecatedProp("close");
|
||||||
},
|
},
|
||||||
|
@ -60,9 +60,10 @@ const MODES = {
|
|||||||
|
|
||||||
export interface MenuItem {
|
export interface MenuItem {
|
||||||
text: string;
|
text: string;
|
||||||
icon: string;
|
icon?: string;
|
||||||
to?: string;
|
to?: string;
|
||||||
event: string;
|
value?: string;
|
||||||
|
event?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@ -78,6 +79,7 @@ export default defineComponent({
|
|||||||
disabled: {
|
disabled: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
|
default: false,
|
||||||
},
|
},
|
||||||
value: {
|
value: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -96,28 +98,24 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props, context) {
|
setup(props, context) {
|
||||||
const activeObj = ref({
|
const activeObj = ref<MenuItem>({
|
||||||
text: "DEFAULT",
|
text: "DEFAULT",
|
||||||
value: "",
|
value: "",
|
||||||
icon: undefined,
|
|
||||||
event: undefined,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let startIndex = 0;
|
let startIndex = 0;
|
||||||
props.items.forEach((item, index) => {
|
props.items.forEach((item, index) => {
|
||||||
// @ts-ignore
|
|
||||||
if (item.value === props.value) {
|
if (item.value === props.value) {
|
||||||
startIndex = index;
|
startIndex = index;
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
activeObj.value = item;
|
activeObj.value = item;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const itemGroup = ref(startIndex);
|
const itemGroup = ref(startIndex);
|
||||||
|
|
||||||
function setValue(v: any) {
|
function setValue(v: MenuItem) {
|
||||||
context.emit(INPUT_EVENT, v.value);
|
context.emit(INPUT_EVENT, v.value);
|
||||||
activeObj.value = v;
|
activeObj.value = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
// @ts-ignore
|
// @ts-ignore vue-markdown has no types
|
||||||
import VueMarkdown from "@adapttive/vue-markdown";
|
import VueMarkdown from "@adapttive/vue-markdown";
|
||||||
|
|
||||||
import { defineComponent, computed, ref } from "@nuxtjs/composition-api";
|
import { defineComponent, computed, ref } from "@nuxtjs/composition-api";
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
// @ts-ignore
|
// @ts-ignore v-jsoneditor has no types
|
||||||
import VJsoneditor from "v-jsoneditor";
|
import VJsoneditor from "v-jsoneditor";
|
||||||
import { defineComponent } from "@nuxtjs/composition-api";
|
import { defineComponent } from "@nuxtjs/composition-api";
|
||||||
|
|
||||||
|
@ -2,13 +2,12 @@ import { Ref } from "@nuxtjs/composition-api";
|
|||||||
// import { useStaticRoutes } from "../api";
|
// import { useStaticRoutes } from "../api";
|
||||||
import { Recipe } from "~/types/api-types/recipe";
|
import { Recipe } from "~/types/api-types/recipe";
|
||||||
|
|
||||||
export const useRecipeMeta = (recipe: Ref<Recipe>) => {
|
export const useRecipeMeta = (recipe: Ref<Recipe | null>) => {
|
||||||
// const { recipeImage } = useStaticRoutes();
|
// const { recipeImage } = useStaticRoutes();
|
||||||
return () => {
|
return () => {
|
||||||
const imageURL = "";
|
const imageURL = "";
|
||||||
return {
|
return {
|
||||||
title: recipe?.value?.name,
|
title: recipe?.value?.name,
|
||||||
// @ts-ignore
|
|
||||||
mainImage: imageURL,
|
mainImage: imageURL,
|
||||||
meta: [
|
meta: [
|
||||||
{ hid: "og:title", property: "og:title", content: recipe?.value?.name || "Recipe" },
|
{ hid: "og:title", property: "og:title", content: recipe?.value?.name || "Recipe" },
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
import { useAsync, ref } from "@nuxtjs/composition-api";
|
import { useAsync, ref } from "@nuxtjs/composition-api";
|
||||||
import { set } from "@vueuse/core";
|
|
||||||
import { useAsyncKey } from "../use-utils";
|
import { useAsyncKey } from "../use-utils";
|
||||||
import { useUserApi } from "~/composables/api";
|
import { useUserApi } from "~/composables/api";
|
||||||
import { Recipe } from "~/types/api-types/recipe";
|
import { Recipe } from "~/types/api-types/recipe";
|
||||||
|
|
||||||
export const allRecipes = ref<Recipe[] | null>([]);
|
export const allRecipes = ref<Recipe[]>([]);
|
||||||
export const recentRecipes = ref<Recipe[] | null>([]);
|
export const recentRecipes = ref<Recipe[]>([]);
|
||||||
|
|
||||||
const rand = (n: number) => Math.floor(Math.random() * n);
|
const rand = (n: number) => Math.floor(Math.random() * n);
|
||||||
|
|
||||||
@ -60,7 +59,7 @@ export const useSorter = () => {
|
|||||||
export const useLazyRecipes = function () {
|
export const useLazyRecipes = function () {
|
||||||
const api = useUserApi();
|
const api = useUserApi();
|
||||||
|
|
||||||
const recipes = ref<Recipe[] | null>([]);
|
const recipes = ref<Recipe[]>([]);
|
||||||
|
|
||||||
async function fetchMore(start: number, limit: number) {
|
async function fetchMore(start: number, limit: number) {
|
||||||
const { data } = await api.recipes.getAll(start, limit);
|
const { data } = await api.recipes.getAll(start, limit);
|
||||||
@ -100,8 +99,7 @@ export const useRecipes = (all = false, fetchRecipes = true) => {
|
|||||||
async function refreshRecipes() {
|
async function refreshRecipes() {
|
||||||
const { data } = await api.recipes.getAll(start, end);
|
const { data } = await api.recipes.getAll(start, end);
|
||||||
if (data) {
|
if (data) {
|
||||||
// @ts-ignore
|
recipes.value = data;
|
||||||
set(recipes, data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { useAsync, ref, reactive } from "@nuxtjs/composition-api";
|
import { useAsync, ref, reactive } from "@nuxtjs/composition-api";
|
||||||
import { set } from "@vueuse/core";
|
|
||||||
import { toastLoading, loader } from "./use-toast";
|
import { toastLoading, loader } from "./use-toast";
|
||||||
import { AllBackups, ImportBackup } from "~/api/class-interfaces/backups";
|
import { AllBackups, ImportBackup } from "~/api/class-interfaces/backups";
|
||||||
import { useUserApi } from "~/composables/api";
|
import { useUserApi } from "~/composables/api";
|
||||||
@ -11,8 +10,7 @@ const backups = ref<AllBackups>({
|
|||||||
|
|
||||||
function setBackups(newBackups: AllBackups | null) {
|
function setBackups(newBackups: AllBackups | null) {
|
||||||
if (newBackups) {
|
if (newBackups) {
|
||||||
// @ts-ignore
|
backups.value = newBackups;
|
||||||
set(backups, newBackups);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useAsync, ref, reactive, Ref } from "@nuxtjs/composition-api";
|
import { useAsync, ref, Ref } from "@nuxtjs/composition-api";
|
||||||
import { useAsyncKey } from "./use-utils";
|
import { useAsyncKey } from "./use-utils";
|
||||||
import { useUserApi } from "~/composables/api";
|
import { useUserApi } from "~/composables/api";
|
||||||
import { CookBook } from "~/api/class-interfaces/group-cookbooks";
|
import { CookBook } from "~/api/class-interfaces/group-cookbooks";
|
||||||
@ -24,16 +24,6 @@ export const useCookbook = function () {
|
|||||||
export const useCookbooks = function () {
|
export const useCookbooks = function () {
|
||||||
const api = useUserApi();
|
const api = useUserApi();
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const deleteTargetId = ref(0);
|
|
||||||
const validForm = ref(true);
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
const workingCookbookData: CookBook = reactive({
|
|
||||||
id: 0,
|
|
||||||
name: "",
|
|
||||||
position: 1,
|
|
||||||
categories: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
getAll() {
|
getAll() {
|
||||||
@ -68,7 +58,6 @@ export const useCookbooks = function () {
|
|||||||
this.refreshAll();
|
this.refreshAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.resetWorking();
|
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
},
|
},
|
||||||
async updateOne(updateData: CookBook) {
|
async updateOne(updateData: CookBook) {
|
||||||
@ -110,18 +99,6 @@ export const useCookbooks = function () {
|
|||||||
this.refreshAll();
|
this.refreshAll();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
resetWorking() {
|
|
||||||
workingCookbookData.id = 0;
|
|
||||||
workingCookbookData.name = "";
|
|
||||||
workingCookbookData.position = 0;
|
|
||||||
workingCookbookData.categories = [];
|
|
||||||
},
|
|
||||||
setWorking(item: CookBook) {
|
|
||||||
workingCookbookData.id = item.id;
|
|
||||||
workingCookbookData.name = item.name;
|
|
||||||
workingCookbookData.position = item.position;
|
|
||||||
workingCookbookData.categories = item.categories;
|
|
||||||
},
|
|
||||||
flushStore() {
|
flushStore() {
|
||||||
cookbookStore = null;
|
cookbookStore = null;
|
||||||
},
|
},
|
||||||
@ -131,5 +108,5 @@ export const useCookbooks = function () {
|
|||||||
cookbookStore = actions.getAll();
|
cookbookStore = actions.getAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
return { cookbooks: cookbookStore, workingCookbookData, deleteTargetId, actions, validForm };
|
return { cookbooks: cookbookStore, actions };
|
||||||
};
|
};
|
||||||
|
@ -31,7 +31,7 @@ export const useMealplans = function (range: Ref<DateRange>) {
|
|||||||
start: format(range.value.start, "yyyy-MM-dd"),
|
start: format(range.value.start, "yyyy-MM-dd"),
|
||||||
limit: format(range.value.end, "yyyy-MM-dd"),
|
limit: format(range.value.end, "yyyy-MM-dd"),
|
||||||
};
|
};
|
||||||
// @ts-ignore
|
// @ts-ignore TODO Modify typing to allow for string start+limit for mealplans
|
||||||
const { data } = await api.mealplans.getAll(query.start, query.limit);
|
const { data } = await api.mealplans.getAll(query.start, query.limit);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
@ -46,7 +46,7 @@ export const useMealplans = function (range: Ref<DateRange>) {
|
|||||||
start: format(range.value.start, "yyyy-MM-dd"),
|
start: format(range.value.start, "yyyy-MM-dd"),
|
||||||
limit: format(range.value.end, "yyyy-MM-dd"),
|
limit: format(range.value.end, "yyyy-MM-dd"),
|
||||||
};
|
};
|
||||||
// @ts-ignore
|
// @ts-ignore TODO Modify typing to allow for string start+limit for mealplans
|
||||||
const { data } = await api.mealplans.getAll(query.start, query.limit);
|
const { data } = await api.mealplans.getAll(query.start, query.limit);
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -71,7 +71,7 @@ export const useMealplans = function (range: Ref<DateRange>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
// @ts-ignore
|
// @ts-ignore TODO Modify mealpan types to be from auto-generated files
|
||||||
const { data } = await api.mealplans.updateOne(updateData.id, updateData);
|
const { data } = await api.mealplans.updateOne(updateData.id, updateData);
|
||||||
if (data) {
|
if (data) {
|
||||||
this.refreshAll();
|
this.refreshAll();
|
||||||
|
@ -7,7 +7,7 @@ export function useRouterQuery(query: string) {
|
|||||||
const param: WritableComputedRef<string> = computed({
|
const param: WritableComputedRef<string> = computed({
|
||||||
get(): string {
|
get(): string {
|
||||||
console.log("Get Query Change");
|
console.log("Get Query Change");
|
||||||
// @ts-ignore
|
// @ts-ignore For some reason, this could also return an array
|
||||||
return router.value?.query[query] || "";
|
return router.value?.query[query] || "";
|
||||||
},
|
},
|
||||||
set(v: string): void {
|
set(v: string): void {
|
||||||
@ -30,7 +30,6 @@ export function useRouteQuery<T extends string | string[]>(name: string, default
|
|||||||
},
|
},
|
||||||
set(v) {
|
set(v) {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
// @ts-ignore
|
|
||||||
router.replace({ query: { ...route.value.query, [name]: v } });
|
router.replace({ query: { ...route.value.query, [name]: v } });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -13,11 +13,11 @@ export function detectServerBaseUrl(req?: IncomingMessage | null) {
|
|||||||
return `${url.protocol}//${url.host}`;
|
return `${url.protocol}//${url.host}`;
|
||||||
} else if (req.headers.host) {
|
} else if (req.headers.host) {
|
||||||
// TODO Socket.encrypted doesn't exist. What is needed here?
|
// TODO Socket.encrypted doesn't exist. What is needed here?
|
||||||
// @ts-ignore
|
// @ts-ignore See above
|
||||||
const protocol = req.socket.encrypted ? "https:" : "http:";
|
const protocol = req.socket.encrypted ? "https:" : "http:";
|
||||||
return `${protocol}//${req.headers.host}`;
|
return `${protocol}//${req.headers.host}`;
|
||||||
} else if (req.socket.remoteAddress) {
|
} else if (req.socket.remoteAddress) {
|
||||||
// @ts-ignore
|
// @ts-ignore See above
|
||||||
const protocol = req.socket.encrypted ? "https:" : "http:";
|
const protocol = req.socket.encrypted ? "https:" : "http:";
|
||||||
return `${protocol}//${req.socket.localAddress || ""}:${req.socket.localPort || ""}`;
|
return `${protocol}//${req.socket.localAddress || ""}:${req.socket.localPort || ""}`;
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ export function deepCopy<T>(obj: T): T {
|
|||||||
// Some other kind of object, deep-copy its
|
// Some other kind of object, deep-copy its
|
||||||
// properties into a new object
|
// properties into a new object
|
||||||
rv = Object.keys(obj).reduce(function (prev, key) {
|
rv = Object.keys(obj).reduce(function (prev, key) {
|
||||||
// @ts-ignore
|
// @ts-ignore This is hard to make type-safe
|
||||||
prev[key] = deepCopy(obj[key]);
|
prev[key] = deepCopy(obj[key]);
|
||||||
return prev;
|
return prev;
|
||||||
}, {});
|
}, {});
|
||||||
|
@ -71,7 +71,6 @@ import { useCookbooks } from "~/composables/use-group-cookbooks";
|
|||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { AppHeader, AppSidebar, TheSnackbar },
|
components: { AppHeader, AppSidebar, TheSnackbar },
|
||||||
// @ts-ignore
|
|
||||||
middleware: "auth",
|
middleware: "auth",
|
||||||
setup() {
|
setup() {
|
||||||
const { cookbooks } = useCookbooks();
|
const { cookbooks } = useCookbooks();
|
||||||
|
@ -27,11 +27,9 @@
|
|||||||
import { defineComponent, useRoute, onMounted, ref } from "@nuxtjs/composition-api";
|
import { defineComponent, useRoute, onMounted, ref } from "@nuxtjs/composition-api";
|
||||||
import GroupPreferencesEditor from "~/components/Domain/Group/GroupPreferencesEditor.vue";
|
import GroupPreferencesEditor from "~/components/Domain/Group/GroupPreferencesEditor.vue";
|
||||||
import { useAdminApi } from "~/composables/api";
|
import { useAdminApi } from "~/composables/api";
|
||||||
import { useGroups } from "~/composables/use-groups";
|
|
||||||
import { alert } from "~/composables/use-toast";
|
import { alert } from "~/composables/use-toast";
|
||||||
import { useUserForm } from "~/composables/use-users";
|
|
||||||
import { validators } from "~/composables/use-validators";
|
|
||||||
import { VForm } from "~/types/vuetify";
|
import { VForm } from "~/types/vuetify";
|
||||||
|
import { GroupRead } from "~/api/admin/admin-groups";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -39,8 +37,6 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
layout: "admin",
|
layout: "admin",
|
||||||
setup() {
|
setup() {
|
||||||
const { userForm } = useUserForm();
|
|
||||||
const { groups } = useGroups();
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
const groupId = route.value.params.id;
|
const groupId = route.value.params.id;
|
||||||
@ -52,7 +48,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
const adminApi = useAdminApi();
|
const adminApi = useAdminApi();
|
||||||
|
|
||||||
const group = ref({});
|
const group = ref<GroupRead | null>(null);
|
||||||
|
|
||||||
const userError = ref(false);
|
const userError = ref(false);
|
||||||
|
|
||||||
@ -65,20 +61,17 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
// @ts-ignore
|
|
||||||
group.value = data;
|
group.value = data;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
if (!refGroupEditForm.value?.validate()) {
|
if (!refGroupEditForm.value?.validate() || group.value === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
const { response, data } = await adminApi.groups.updateOne(group.value.id, group.value);
|
const { response, data } = await adminApi.groups.updateOne(group.value.id, group.value);
|
||||||
if (response?.status === 200 && data) {
|
if (response?.status === 200 && data) {
|
||||||
// @ts-ignore
|
|
||||||
group.value = data;
|
group.value = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,11 +79,8 @@ export default defineComponent({
|
|||||||
return {
|
return {
|
||||||
group,
|
group,
|
||||||
userError,
|
userError,
|
||||||
userForm,
|
|
||||||
refGroupEditForm,
|
refGroupEditForm,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
groups,
|
|
||||||
validators,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -45,6 +45,7 @@ import { alert } from "~/composables/use-toast";
|
|||||||
import { useUserForm } from "~/composables/use-users";
|
import { useUserForm } from "~/composables/use-users";
|
||||||
import { validators } from "~/composables/use-validators";
|
import { validators } from "~/composables/use-validators";
|
||||||
import { VForm } from "~/types/vuetify";
|
import { VForm } from "~/types/vuetify";
|
||||||
|
import { UserOut } from "~/types/api-types/user";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
layout: "admin",
|
layout: "admin",
|
||||||
@ -62,19 +63,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
const adminApi = useAdminApi();
|
const adminApi = useAdminApi();
|
||||||
|
|
||||||
const user = ref({
|
const user = ref<UserOut | null>(null);
|
||||||
username: "",
|
|
||||||
fullName: "",
|
|
||||||
email: "",
|
|
||||||
admin: false,
|
|
||||||
group: "",
|
|
||||||
advanced: false,
|
|
||||||
canInvite: false,
|
|
||||||
canManage: false,
|
|
||||||
canOrganize: false,
|
|
||||||
id: 0,
|
|
||||||
groupId: 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
const userError = ref(false);
|
const userError = ref(false);
|
||||||
|
|
||||||
@ -87,19 +76,16 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
// @ts-ignore
|
|
||||||
user.value = data;
|
user.value = data;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
if (!refNewUserForm.value?.validate()) return;
|
if (!refNewUserForm.value?.validate() || user.value === null) return;
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
const { response, data } = await adminApi.users.updateOne(user.value.id, user.value);
|
const { response, data } = await adminApi.users.updateOne(user.value.id, user.value);
|
||||||
|
|
||||||
if (response?.status === 200 && data) {
|
if (response?.status === 200 && data) {
|
||||||
// @ts-ignore
|
|
||||||
user.value = data;
|
user.value = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,8 @@ import { defineComponent, reactive, ref, toRefs } from "@nuxtjs/composition-api"
|
|||||||
import { Confidence, Parser } from "~/api/class-interfaces/recipes/types";
|
import { Confidence, Parser } from "~/api/class-interfaces/recipes/types";
|
||||||
import { useUserApi } from "~/composables/api";
|
import { useUserApi } from "~/composables/api";
|
||||||
|
|
||||||
|
type ConfidenceAttribute = "average" | "comment" | "name" | "unit" | "quantity" | "food";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
layout: "admin",
|
layout: "admin",
|
||||||
setup() {
|
setup() {
|
||||||
@ -85,11 +87,12 @@ export default defineComponent({
|
|||||||
|
|
||||||
const confidence = ref<Confidence>({});
|
const confidence = ref<Confidence>({});
|
||||||
|
|
||||||
function getColor(attribute: string) {
|
function getColor(attribute: ConfidenceAttribute) {
|
||||||
const percentage = getConfidence(attribute);
|
const percentage = getConfidence(attribute);
|
||||||
|
if (percentage === undefined)
|
||||||
|
return;
|
||||||
|
|
||||||
// @ts-ignore
|
const p_as_num = parseFloat(percentage.replace("%", ""));
|
||||||
const p_as_num = parseFloat(percentage?.replace("%", ""));
|
|
||||||
|
|
||||||
// Set color based off range
|
// Set color based off range
|
||||||
if (p_as_num > 75) {
|
if (p_as_num > 75) {
|
||||||
@ -101,18 +104,16 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConfidence(attribute: string) {
|
function getConfidence(attribute: ConfidenceAttribute) {
|
||||||
attribute = attribute.toLowerCase();
|
|
||||||
if (!confidence.value) {
|
if (!confidence.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
const property = confidence.value[attribute];
|
||||||
const property: number = confidence.value[attribute];
|
if (property !== undefined) {
|
||||||
if (property) {
|
|
||||||
return `${(property * 100).toFixed(0)}%`;
|
return `${(property * 100).toFixed(0)}%`;
|
||||||
}
|
}
|
||||||
return null;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tryText = [
|
const tryText = [
|
||||||
@ -150,18 +151,18 @@ export default defineComponent({
|
|||||||
properties.unit.value = data.ingredient?.unit?.name || "";
|
properties.unit.value = data.ingredient?.unit?.name || "";
|
||||||
properties.food.value = data.ingredient?.food?.name || "";
|
properties.food.value = data.ingredient?.food?.name || "";
|
||||||
|
|
||||||
for (const property in properties) {
|
(["comment", "quantity", "unit", "food"] as ConfidenceAttribute[]).forEach(property => {
|
||||||
const color = getColor(property);
|
const color = getColor(property);
|
||||||
const confidence = getConfidence(property);
|
const confidence = getConfidence(property);
|
||||||
if (color) {
|
if (color) {
|
||||||
// @ts-ignore
|
// @ts-ignore See above
|
||||||
properties[property].color = color;
|
properties[property].color = color;
|
||||||
}
|
}
|
||||||
if (confidence) {
|
if (confidence) {
|
||||||
// @ts-ignore
|
// @ts-ignore See above
|
||||||
properties[property].confidence = confidence;
|
properties[property].confidence = confidence;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
state.loading = false;
|
state.loading = false;
|
||||||
}
|
}
|
||||||
@ -169,7 +170,7 @@ export default defineComponent({
|
|||||||
const properties = reactive({
|
const properties = reactive({
|
||||||
quantity: {
|
quantity: {
|
||||||
subtitle: "Quantity",
|
subtitle: "Quantity",
|
||||||
value: "" as any,
|
value: "" as string | number,
|
||||||
color: null,
|
color: null,
|
||||||
confidence: null,
|
confidence: null,
|
||||||
},
|
},
|
||||||
|
@ -86,7 +86,7 @@ import {
|
|||||||
useAsync,
|
useAsync,
|
||||||
useContext,
|
useContext,
|
||||||
} from "@nuxtjs/composition-api";
|
} from "@nuxtjs/composition-api";
|
||||||
import { AdminAboutInfo, CheckAppConfig } from "~/api/admin/admin-about";
|
import { CheckAppConfig } from "~/api/admin/admin-about";
|
||||||
import { useAdminApi, useUserApi } from "~/composables/api";
|
import { useAdminApi, useUserApi } from "~/composables/api";
|
||||||
import { validators } from "~/composables/use-validators";
|
import { validators } from "~/composables/use-validators";
|
||||||
import { useAsyncKey } from "~/composables/use-utils";
|
import { useAsyncKey } from "~/composables/use-utils";
|
||||||
@ -96,6 +96,7 @@ interface SimpleCheck {
|
|||||||
text: string;
|
text: string;
|
||||||
successText: string;
|
successText: string;
|
||||||
errorText: string;
|
errorText: string;
|
||||||
|
warning: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@ -209,8 +210,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
const { $globals, i18n } = useContext();
|
const { $globals, i18n } = useContext();
|
||||||
|
|
||||||
// @ts-ignore
|
const rawAppInfo = ref({
|
||||||
const rawAppInfo = ref<AdminAboutInfo>({
|
|
||||||
version: "null",
|
version: "null",
|
||||||
versionLatest: "null",
|
versionLatest: "null",
|
||||||
});
|
});
|
||||||
@ -220,7 +220,8 @@ export default defineComponent({
|
|||||||
const { data } = await adminApi.about.about();
|
const { data } = await adminApi.about.about();
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
rawAppInfo.value = data;
|
rawAppInfo.value.version = data.version;
|
||||||
|
rawAppInfo.value.versionLatest = data.versionLatest;
|
||||||
|
|
||||||
const prettyInfo = [
|
const prettyInfo = [
|
||||||
{
|
{
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, useRoute, ref } from "@nuxtjs/composition-api";
|
import { defineComponent, useRoute, ref } from "@nuxtjs/composition-api";
|
||||||
// @ts-ignore
|
// @ts-ignore vue-markdown has no types
|
||||||
import VueMarkdown from "@adapttive/vue-markdown";
|
import VueMarkdown from "@adapttive/vue-markdown";
|
||||||
import { useStaticRoutes } from "~/composables/api";
|
import { useStaticRoutes } from "~/composables/api";
|
||||||
import { parseIngredientText, useRecipe } from "~/composables/recipes";
|
import { parseIngredientText, useRecipe } from "~/composables/recipes";
|
||||||
|
@ -446,7 +446,7 @@ import {
|
|||||||
useRouter,
|
useRouter,
|
||||||
onMounted,
|
onMounted,
|
||||||
} from "@nuxtjs/composition-api";
|
} from "@nuxtjs/composition-api";
|
||||||
// @ts-ignore
|
// @ts-ignore vue-markdown has no types
|
||||||
import VueMarkdown from "@adapttive/vue-markdown";
|
import VueMarkdown from "@adapttive/vue-markdown";
|
||||||
import draggable from "vuedraggable";
|
import draggable from "vuedraggable";
|
||||||
import { invoke, until } from "@vueuse/core";
|
import { invoke, until } from "@vueuse/core";
|
||||||
@ -469,9 +469,8 @@ import RecipeIngredientEditor from "~/components/Domain/Recipe/RecipeIngredientE
|
|||||||
import RecipePrintView from "~/components/Domain/Recipe/RecipePrintView.vue";
|
import RecipePrintView from "~/components/Domain/Recipe/RecipePrintView.vue";
|
||||||
import RecipeTools from "~/components/Domain/Recipe/RecipeTools.vue";
|
import RecipeTools from "~/components/Domain/Recipe/RecipeTools.vue";
|
||||||
import RecipeComments from "~/components/Domain/Recipe/RecipeComments.vue";
|
import RecipeComments from "~/components/Domain/Recipe/RecipeComments.vue";
|
||||||
import { Recipe } from "~/types/api-types/recipe";
|
import { Recipe, RecipeTool } from "~/types/api-types/recipe";
|
||||||
import { uuid4, deepCopy } from "~/composables/use-utils";
|
import { uuid4, deepCopy } from "~/composables/use-utils";
|
||||||
import { Tool } from "~/api/class-interfaces/tools";
|
|
||||||
import { useRouteQuery } from "~/composables/use-router";
|
import { useRouteQuery } from "~/composables/use-router";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@ -505,9 +504,8 @@ export default defineComponent({
|
|||||||
|
|
||||||
console.log({ working: this.recipe, saved: this.originalRecipe });
|
console.log({ working: this.recipe, saved: this.originalRecipe });
|
||||||
|
|
||||||
if (this.form && !isSame) {
|
if (this.form && !isSame && this.recipe?.slug !== undefined) {
|
||||||
if (window.confirm("You have unsaved changes. Do you want to save before leaving?")) {
|
if (window.confirm("You have unsaved changes. Do you want to save before leaving?")) {
|
||||||
// @ts-ignore
|
|
||||||
await this.api.recipes.updateOne(this.recipe.slug, this.recipe);
|
await this.api.recipes.updateOne(this.recipe.slug, this.recipe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -536,14 +534,11 @@ export default defineComponent({
|
|||||||
// ===============================================================
|
// ===============================================================
|
||||||
// Check Before Leaving
|
// Check Before Leaving
|
||||||
|
|
||||||
const domSaveChangesDialog = ref(null);
|
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
form: false,
|
form: false,
|
||||||
scale: 1,
|
scale: 1,
|
||||||
hideImage: false,
|
hideImage: false,
|
||||||
imageKey: 1,
|
imageKey: 1,
|
||||||
loadFailed: false,
|
|
||||||
skeleton: false,
|
skeleton: false,
|
||||||
jsonEditor: false,
|
jsonEditor: false,
|
||||||
jsonEditorOptions: {
|
jsonEditorOptions: {
|
||||||
@ -567,11 +562,11 @@ export default defineComponent({
|
|||||||
|
|
||||||
const { recipeImage } = useStaticRoutes();
|
const { recipeImage } = useStaticRoutes();
|
||||||
|
|
||||||
const { $vuetify } = useContext();
|
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// Layout Helpers
|
// Layout Helpers
|
||||||
|
|
||||||
|
const { $vuetify } = useContext();
|
||||||
const enableLandscape = computed(() => {
|
const enableLandscape = computed(() => {
|
||||||
const preferLandscape = recipe?.value?.settings?.landscapeView;
|
const preferLandscape = recipe?.value?.settings?.landscapeView;
|
||||||
const smallScreen = !$vuetify.breakpoint.smAndUp;
|
const smallScreen = !$vuetify.breakpoint.smAndUp;
|
||||||
@ -585,6 +580,10 @@ export default defineComponent({
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const imageHeight = computed(() => {
|
||||||
|
return $vuetify.breakpoint.xs ? "200" : "400";
|
||||||
|
});
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// Button Click Event Handlers
|
// Button Click Event Handlers
|
||||||
|
|
||||||
@ -604,6 +603,10 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function printRecipe() {
|
||||||
|
window.print();
|
||||||
|
}
|
||||||
|
|
||||||
async function closeEditor() {
|
async function closeEditor() {
|
||||||
state.form = false;
|
state.form = false;
|
||||||
state.jsonEditor = false;
|
state.jsonEditor = false;
|
||||||
@ -687,7 +690,10 @@ export default defineComponent({
|
|||||||
// ===============================================================
|
// ===============================================================
|
||||||
// Recipe Tools
|
// Recipe Tools
|
||||||
|
|
||||||
async function updateTool(tool: Tool) {
|
async function updateTool(tool: RecipeTool) {
|
||||||
|
if (tool.id === undefined)
|
||||||
|
return;
|
||||||
|
|
||||||
const { response } = await api.tools.updateOne(tool.id, tool);
|
const { response } = await api.tools.updateOne(tool.id, tool);
|
||||||
|
|
||||||
if (response?.status === 200) {
|
if (response?.status === 200) {
|
||||||
@ -735,7 +741,6 @@ export default defineComponent({
|
|||||||
// ===============================================================
|
// ===============================================================
|
||||||
// Metadata
|
// Metadata
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
const metaData = useRecipeMeta(recipe);
|
const metaData = useRecipeMeta(recipe);
|
||||||
|
|
||||||
useMeta(metaData);
|
useMeta(metaData);
|
||||||
@ -743,9 +748,8 @@ export default defineComponent({
|
|||||||
return {
|
return {
|
||||||
createApiExtra,
|
createApiExtra,
|
||||||
apiNewKey,
|
apiNewKey,
|
||||||
originalRecipe,
|
|
||||||
domSaveChangesDialog,
|
|
||||||
enableLandscape,
|
enableLandscape,
|
||||||
|
imageHeight,
|
||||||
scaledYield,
|
scaledYield,
|
||||||
toggleJson,
|
toggleJson,
|
||||||
...toRefs(state),
|
...toRefs(state),
|
||||||
@ -754,6 +758,7 @@ export default defineComponent({
|
|||||||
loading,
|
loading,
|
||||||
addStep,
|
addStep,
|
||||||
deleteRecipe,
|
deleteRecipe,
|
||||||
|
printRecipe,
|
||||||
closeEditor,
|
closeEditor,
|
||||||
updateTool,
|
updateTool,
|
||||||
updateRecipe,
|
updateRecipe,
|
||||||
@ -765,15 +770,5 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
head: {},
|
head: {},
|
||||||
computed: {
|
|
||||||
imageHeight() {
|
|
||||||
return this.$vuetify.breakpoint.xs ? "200" : "400";
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
printRecipe() {
|
|
||||||
window.print();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -135,7 +135,6 @@ export default defineComponent({
|
|||||||
if (data) {
|
if (data) {
|
||||||
parsedIng.value = data;
|
parsedIng.value = data;
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
errors.value = data.map((ing, index: number) => {
|
errors.value = data.map((ing, index: number) => {
|
||||||
const unitError = !checkForUnit(ing.ingredient.unit);
|
const unitError = !checkForUnit(ing.ingredient.unit);
|
||||||
const foodError = !checkForFood(ing.ingredient.food);
|
const foodError = !checkForFood(ing.ingredient.food);
|
||||||
|
@ -332,7 +332,8 @@ import RecipeCategoryTagSelector from "~/components/Domain/Recipe/RecipeCategory
|
|||||||
import { validators } from "~/composables/use-validators";
|
import { validators } from "~/composables/use-validators";
|
||||||
import { Recipe } from "~/types/api-types/recipe";
|
import { Recipe } from "~/types/api-types/recipe";
|
||||||
import { alert } from "~/composables/use-toast";
|
import { alert } from "~/composables/use-toast";
|
||||||
import { VForm} from "~/types/vuetify";
|
import { VForm } from "~/types/vuetify";
|
||||||
|
import { MenuItem } from "~/components/global/BaseOverflowButton.vue";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { VJsoneditor, RecipeCategoryTagSelector },
|
components: { VJsoneditor, RecipeCategoryTagSelector },
|
||||||
@ -344,7 +345,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
const { $globals } = useContext();
|
const { $globals } = useContext();
|
||||||
|
|
||||||
const tabs = [
|
const tabs: MenuItem[] = [
|
||||||
{
|
{
|
||||||
icon: $globals.icons.link,
|
icon: $globals.icons.link,
|
||||||
text: "Import with URL",
|
text: "Import with URL",
|
||||||
@ -422,48 +423,36 @@ export default defineComponent({
|
|||||||
|
|
||||||
// ===================================================
|
// ===================================================
|
||||||
// Recipe URL Import
|
// Recipe URL Import
|
||||||
// @ts-ignore
|
const domUrlForm = ref<VForm | null>(null);
|
||||||
const domUrlForm = ref<VForm>(null);
|
|
||||||
|
|
||||||
async function createByUrl(url: string) {
|
async function createByUrl(url: string) {
|
||||||
if (!domUrlForm.value.validate() || url === "") {
|
if (!domUrlForm.value?.validate() || url === "") {
|
||||||
console.log("Invalid URL", url);
|
console.log("Invalid URL", url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state.loading = true;
|
state.loading = true;
|
||||||
const { response } = await api.recipes.createOneByUrl(url);
|
const { response } = await api.recipes.createOneByUrl(url);
|
||||||
if (response?.status !== 201) {
|
|
||||||
// @ts-ignore
|
|
||||||
if (!response?.error?.response?.data?.detail?.message) {
|
|
||||||
state.error = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
state.loading = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
handleResponse(response);
|
handleResponse(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===================================================
|
// ===================================================
|
||||||
// Recipe Create By Name
|
// Recipe Create By Name
|
||||||
const newRecipeName = ref("");
|
const newRecipeName = ref("");
|
||||||
// @ts-ignore
|
const domCreateByName = ref<VForm | null>(null);
|
||||||
const domCreateByName = ref<VForm>(null);
|
|
||||||
|
|
||||||
async function createByName(name: string) {
|
async function createByName(name: string) {
|
||||||
if (!domCreateByName.value.validate() || name === "") {
|
if (!domCreateByName.value?.validate() || name === "") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { response } = await api.recipes.createOne({ name });
|
const { response } = await api.recipes.createOne({ name });
|
||||||
// TODO createOne claims to return a Recipe, but actually the API only returns a string
|
// TODO createOne claims to return a Recipe, but actually the API only returns a string
|
||||||
// @ts-ignore
|
// @ts-ignore See above
|
||||||
handleResponse(response, true);
|
handleResponse(response, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===================================================
|
// ===================================================
|
||||||
// Recipe Import From Zip File
|
// Recipe Import From Zip File
|
||||||
// @ts-ignore
|
const newRecipeZip = ref<File | null>(null);
|
||||||
const newRecipeZip = ref<File>(null);
|
|
||||||
const newRecipeZipFileName = "archive";
|
const newRecipeZipFileName = "archive";
|
||||||
|
|
||||||
async function createByZip() {
|
async function createByZip() {
|
||||||
|
@ -47,9 +47,7 @@ export default defineComponent({
|
|||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
function removeRecipe(slug: string) {
|
function removeRecipe(slug: string) {
|
||||||
// @ts-ignore
|
|
||||||
for (let i = 0; i < recipes?.value?.length; i++) {
|
for (let i = 0; i < recipes?.value?.length; i++) {
|
||||||
// @ts-ignore
|
|
||||||
if (recipes?.value[i].slug === slug) {
|
if (recipes?.value[i].slug === slug) {
|
||||||
recipes?.value.splice(i, 1);
|
recipes?.value.splice(i, 1);
|
||||||
break;
|
break;
|
||||||
|
@ -115,7 +115,6 @@ export default defineComponent({
|
|||||||
methods: {
|
methods: {
|
||||||
assignSorted(val: Array<Recipe>) {
|
assignSorted(val: Array<Recipe>) {
|
||||||
if (this.category) {
|
if (this.category) {
|
||||||
// @ts-ignore
|
|
||||||
this.category.recipes = val;
|
this.category.recipes = val;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -115,7 +115,6 @@ export default defineComponent({
|
|||||||
methods: {
|
methods: {
|
||||||
assignSorted(val: Array<Recipe>) {
|
assignSorted(val: Array<Recipe>) {
|
||||||
if (this.tags) {
|
if (this.tags) {
|
||||||
// @ts-ignore
|
|
||||||
this.tags.recipes = val;
|
this.tags.recipes = val;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -109,7 +109,6 @@ export default defineComponent({
|
|||||||
methods: {
|
methods: {
|
||||||
assignSorted(val: Array<Recipe>) {
|
assignSorted(val: Array<Recipe>) {
|
||||||
if (this.tools) {
|
if (this.tools) {
|
||||||
// @ts-ignore
|
|
||||||
this.tools.recipes = val;
|
this.tools.recipes = val;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -129,8 +129,7 @@ export default defineComponent({
|
|||||||
state.joinGroup = true;
|
state.joinGroup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
const domRegisterForm = ref<VForm | null>(null);
|
||||||
const domRegisterForm = ref<VForm>(null);
|
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
group: "",
|
group: "",
|
||||||
|
@ -188,7 +188,7 @@ export default defineComponent({
|
|||||||
const includesTags = check(
|
const includesTags = check(
|
||||||
state.includeTags,
|
state.includeTags,
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore See above
|
||||||
recipe.tags.map((x: Tag) => x.name),
|
recipe.tags.map((x: Tag) => x.name),
|
||||||
state.tagFilter.matchAny,
|
state.tagFilter.matchAny,
|
||||||
state.tagFilter.exclude
|
state.tagFilter.exclude
|
||||||
@ -196,8 +196,7 @@ export default defineComponent({
|
|||||||
const includesCats = check(
|
const includesCats = check(
|
||||||
state.includeCategories,
|
state.includeCategories,
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore See above
|
||||||
|
|
||||||
recipe.recipeCategory.map((x) => x.name),
|
recipe.recipeCategory.map((x) => x.name),
|
||||||
state.catFilter.matchAny,
|
state.catFilter.matchAny,
|
||||||
state.catFilter.exclude
|
state.catFilter.exclude
|
||||||
@ -205,7 +204,7 @@ export default defineComponent({
|
|||||||
const includesFoods = check(
|
const includesFoods = check(
|
||||||
state.includeFoods,
|
state.includeFoods,
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore See above
|
||||||
recipe.recipeIngredient.map((x) => x?.food?.name || ""),
|
recipe.recipeIngredient.map((x) => x?.food?.name || ""),
|
||||||
state.foodFilter.matchAny,
|
state.foodFilter.matchAny,
|
||||||
state.foodFilter.exclude
|
state.foodFilter.exclude
|
||||||
|
@ -270,7 +270,7 @@ import {
|
|||||||
useMeta,
|
useMeta,
|
||||||
useRoute,
|
useRoute,
|
||||||
} from "@nuxtjs/composition-api";
|
} from "@nuxtjs/composition-api";
|
||||||
// @ts-ignore
|
// @ts-ignore vue-markdown has no types
|
||||||
import VueMarkdown from "@adapttive/vue-markdown";
|
import VueMarkdown from "@adapttive/vue-markdown";
|
||||||
// import { useRecipeMeta } from "~/composables/recipes";
|
// import { useRecipeMeta } from "~/composables/recipes";
|
||||||
import { useStaticRoutes, useUserApi } from "~/composables/api";
|
import { useStaticRoutes, useUserApi } from "~/composables/api";
|
||||||
@ -316,7 +316,6 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
const { recipeImage } = useStaticRoutes();
|
const { recipeImage } = useStaticRoutes();
|
||||||
const { meta, title } = useMeta();
|
const { meta, title } = useMeta();
|
||||||
|
|
||||||
@ -330,28 +329,25 @@ export default defineComponent({
|
|||||||
|
|
||||||
meta.value = [
|
meta.value = [
|
||||||
{ hid: "og:title", property: "og:title", content: data.name ?? "" },
|
{ hid: "og:title", property: "og:title", content: data.name ?? "" },
|
||||||
// @ts-ignore
|
|
||||||
{
|
{
|
||||||
hid: "og:desc",
|
hid: "og:desc",
|
||||||
property: "og:description",
|
property: "og:description",
|
||||||
content: data.description,
|
content: data.description ?? "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hid: "og-image",
|
hid: "og-image",
|
||||||
property: "og:image",
|
property: "og:image",
|
||||||
content: imageURL ?? "",
|
content: imageURL ?? "",
|
||||||
},
|
},
|
||||||
// @ts-ignore
|
|
||||||
{
|
{
|
||||||
hid: "twitter:title",
|
hid: "twitter:title",
|
||||||
property: "twitter:title",
|
property: "twitter:title",
|
||||||
content: data.name,
|
content: data.name ?? "",
|
||||||
},
|
},
|
||||||
// @ts-ignore
|
|
||||||
{
|
{
|
||||||
hid: "twitter:desc",
|
hid: "twitter:desc",
|
||||||
property: "twitter:description",
|
property: "twitter:description",
|
||||||
content: data.description,
|
content: data.description ?? "",
|
||||||
},
|
},
|
||||||
{ hid: "t-type", name: "twitter:card", content: "summary_large_image" },
|
{ hid: "t-type", name: "twitter:card", content: "summary_large_image" },
|
||||||
];
|
];
|
||||||
|
@ -425,7 +425,7 @@ export default defineComponent({
|
|||||||
shoppingList.value?.listItems.forEach((item) => {
|
shoppingList.value?.listItems.forEach((item) => {
|
||||||
if (item.labelId) {
|
if (item.labelId) {
|
||||||
labels.push({
|
labels.push({
|
||||||
// @ts-ignore
|
// @ts-ignore TODO
|
||||||
name: item.label.name,
|
name: item.label.name,
|
||||||
id: item.labelId,
|
id: item.labelId,
|
||||||
});
|
});
|
||||||
@ -439,7 +439,7 @@ export default defineComponent({
|
|||||||
const items: { [prop: string]: ShoppingListItemCreate[] } = {};
|
const items: { [prop: string]: ShoppingListItemCreate[] } = {};
|
||||||
|
|
||||||
const noLabel = {
|
const noLabel = {
|
||||||
"No Label": [],
|
"No Label": [] as ShoppingListItemCreate[],
|
||||||
};
|
};
|
||||||
|
|
||||||
shoppingList.value?.listItems.forEach((item) => {
|
shoppingList.value?.listItems.forEach((item) => {
|
||||||
@ -450,7 +450,6 @@ export default defineComponent({
|
|||||||
items[item.label.name] = [item];
|
items[item.label.name] = [item];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// @ts-ignore
|
|
||||||
noLabel["No Label"].push(item);
|
noLabel["No Label"].push(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -68,6 +68,7 @@
|
|||||||
import { defineComponent, reactive, toRefs, useContext, computed, onMounted } from "@nuxtjs/composition-api";
|
import { defineComponent, reactive, toRefs, useContext, computed, onMounted } from "@nuxtjs/composition-api";
|
||||||
import { SupportedMigration } from "~/api/class-interfaces/group-migrations";
|
import { SupportedMigration } from "~/api/class-interfaces/group-migrations";
|
||||||
import { ReportSummary } from "~/api/class-interfaces/group-reports";
|
import { ReportSummary } from "~/api/class-interfaces/group-reports";
|
||||||
|
import { MenuItem } from "~/components/global/BaseOverflowButton.vue";
|
||||||
import { useUserApi } from "~/composables/api";
|
import { useUserApi } from "~/composables/api";
|
||||||
|
|
||||||
const MIGRATIONS = {
|
const MIGRATIONS = {
|
||||||
@ -92,7 +93,7 @@ export default defineComponent({
|
|||||||
reports: [] as ReportSummary[],
|
reports: [] as ReportSummary[],
|
||||||
});
|
});
|
||||||
|
|
||||||
const items = [
|
const items: MenuItem[] = [
|
||||||
{
|
{
|
||||||
text: "Nextcloud",
|
text: "Nextcloud",
|
||||||
value: MIGRATIONS.nextcloud,
|
value: MIGRATIONS.nextcloud,
|
||||||
|
@ -162,6 +162,7 @@ import { useRecipes, allRecipes } from "~/composables/recipes";
|
|||||||
import { Recipe } from "~/types/api-types/recipe";
|
import { Recipe } from "~/types/api-types/recipe";
|
||||||
import GroupExportData from "~/components/Domain/Group/GroupExportData.vue";
|
import GroupExportData from "~/components/Domain/Group/GroupExportData.vue";
|
||||||
import { GroupDataExport } from "~/api/class-interfaces/recipe-bulk-actions";
|
import { GroupDataExport } from "~/api/class-interfaces/recipe-bulk-actions";
|
||||||
|
import { MenuItem } from "~/components/global/BaseOverflowButton.vue";
|
||||||
|
|
||||||
const MODES = {
|
const MODES = {
|
||||||
tag: "tag",
|
tag: "tag",
|
||||||
@ -191,7 +192,7 @@ export default defineComponent({
|
|||||||
id: false,
|
id: false,
|
||||||
owner: false,
|
owner: false,
|
||||||
tags: true,
|
tags: true,
|
||||||
tools: "Tools",
|
tools: true,
|
||||||
categories: true,
|
categories: true,
|
||||||
recipeYield: false,
|
recipeYield: false,
|
||||||
dateAdded: false,
|
dateAdded: false,
|
||||||
@ -207,29 +208,25 @@ export default defineComponent({
|
|||||||
dateAdded: "Date Added",
|
dateAdded: "Date Added",
|
||||||
};
|
};
|
||||||
|
|
||||||
const actions = [
|
const actions: MenuItem[] = [
|
||||||
{
|
{
|
||||||
icon: $globals.icons.database,
|
icon: $globals.icons.database,
|
||||||
text: "Export",
|
text: "Export",
|
||||||
value: 0,
|
|
||||||
event: "export-selected",
|
event: "export-selected",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: $globals.icons.tags,
|
icon: $globals.icons.tags,
|
||||||
text: "Tag",
|
text: "Tag",
|
||||||
value: 1,
|
|
||||||
event: "tag-selected",
|
event: "tag-selected",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: $globals.icons.tags,
|
icon: $globals.icons.tags,
|
||||||
text: "Categorize",
|
text: "Categorize",
|
||||||
value: 2,
|
|
||||||
event: "categorize-selected",
|
event: "categorize-selected",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: $globals.icons.delete,
|
icon: $globals.icons.delete,
|
||||||
text: "Delete",
|
text: "Delete",
|
||||||
value: 3,
|
|
||||||
event: "delete-selected",
|
event: "delete-selected",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -264,7 +261,6 @@ export default defineComponent({
|
|||||||
// All Recipes
|
// All Recipes
|
||||||
|
|
||||||
function selectAll() {
|
function selectAll() {
|
||||||
// @ts-ignore
|
|
||||||
selected.value = allRecipes.value;
|
selected.value = allRecipes.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +116,7 @@ import { ref, reactive, defineComponent, computed, useContext, watch } from "@nu
|
|||||||
import { useUserApi } from "~/composables/api";
|
import { useUserApi } from "~/composables/api";
|
||||||
import UserAvatar from "~/components/Domain/User/UserAvatar.vue";
|
import UserAvatar from "~/components/Domain/User/UserAvatar.vue";
|
||||||
import { VForm } from "~/types/vuetify";
|
import { VForm } from "~/types/vuetify";
|
||||||
|
import { UserOut } from "~/types/api-types/user";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -123,7 +124,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const nuxtContext = useContext();
|
const nuxtContext = useContext();
|
||||||
const user = computed(() => nuxtContext.$auth.user);
|
const user = computed(() => nuxtContext.$auth.user as unknown as UserOut);
|
||||||
|
|
||||||
watch(user, () => {
|
watch(user, () => {
|
||||||
userCopy.value = { ...user.value };
|
userCopy.value = { ...user.value };
|
||||||
@ -141,7 +142,6 @@ export default defineComponent({
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function updateUser() {
|
async function updateUser() {
|
||||||
// @ts-ignore
|
|
||||||
const { response } = await api.users.updateOne(userCopy.value.id, userCopy.value);
|
const { response } = await api.users.updateOne(userCopy.value.id, userCopy.value);
|
||||||
if (response?.status === 200) {
|
if (response?.status === 200) {
|
||||||
nuxtContext.$auth.fetchUser();
|
nuxtContext.$auth.fetchUser();
|
||||||
@ -152,7 +152,6 @@ export default defineComponent({
|
|||||||
if (!userCopy.value?.id) {
|
if (!userCopy.value?.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
|
||||||
const { response } = await api.users.changePassword(userCopy.value.id, {
|
const { response } = await api.users.changePassword(userCopy.value.id, {
|
||||||
currentPassword: password.current,
|
currentPassword: password.current,
|
||||||
newPassword: password.newOne,
|
newPassword: password.newOne,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user