mirror of
https://github.com/ThisIsBenny/wishlist-app.git
synced 2025-04-19 23:37:41 +00:00
typescript issues fixed
Signed-off-by: Benny Samir Hierl <bennysamir@posteo.de>
This commit is contained in:
parent
afc246f0b3
commit
ea83fa4a68
10 changed files with 42 additions and 39 deletions
|
@ -35,9 +35,9 @@ import { onErrorCaptured, ref } from 'vue'
|
|||
import { useI18n } from 'vue-i18n'
|
||||
const { t } = useI18n()
|
||||
|
||||
const error = ref(null)
|
||||
const error = ref()
|
||||
|
||||
onErrorCaptured((e: any) => {
|
||||
onErrorCaptured((e: unknown) => {
|
||||
error.value = e
|
||||
return false
|
||||
})
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
import { prisma } from '../../services'
|
||||
import { Wishlist, WishlistItem } from '@/types'
|
||||
|
||||
interface WishlistWhereInput {
|
||||
public?: boolean
|
||||
}
|
||||
|
||||
export default {
|
||||
getAll: async (where?: any): Promise<Wishlist[]> => {
|
||||
getAll: async (where?: WishlistWhereInput): Promise<Wishlist[]> => {
|
||||
return (await prisma.client.wishlist.findMany({
|
||||
where,
|
||||
include: { items: false },
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { FastifyRequest, FastifyReply, RouteOptions } from 'fastify'
|
||||
import ogs from 'open-graph-scraper'
|
||||
import ogs, { OpenGraphImage } from 'open-graph-scraper'
|
||||
|
||||
interface fetchOpenGraphRequest extends FastifyRequest {
|
||||
query: {
|
||||
|
@ -36,8 +36,9 @@ export const fetchOpenGraph = <RouteOptions>{
|
|||
request.log.debug(result)
|
||||
if (result.success) {
|
||||
const image =
|
||||
//@ts-expect-error: url not defined
|
||||
result.ogImage && result.ogImage.url ? result.ogImage.url : ''
|
||||
result.ogImage && (result.ogImage as OpenGraphImage).url
|
||||
? (result.ogImage as OpenGraphImage).url
|
||||
: ''
|
||||
reply.send({
|
||||
title: result.ogTitle || '',
|
||||
description: result.ogDescription || '',
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<template>
|
||||
<Form
|
||||
@submit="onSubmit"
|
||||
:validation-schema="schema"
|
||||
v-slot="{ meta }"
|
||||
class="w-full flex-col"
|
||||
>
|
||||
<form @submit="onSubmit" class="w-full flex-col">
|
||||
<InputText
|
||||
name="title"
|
||||
type="text"
|
||||
|
@ -46,13 +41,13 @@
|
|||
:icon="IconSave"
|
||||
>{{ t('components.form-wishlist.submit.text') }}</ButtonBase
|
||||
>
|
||||
</Form>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Wishlist } from '@/types'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { Form } from 'vee-validate'
|
||||
import { useForm } from 'vee-validate'
|
||||
import IconSave from '@/components/icons/IconSave.vue'
|
||||
import { object, string, boolean } from 'yup'
|
||||
|
||||
|
@ -94,8 +89,13 @@ const schema = object().shape(
|
|||
['imageSrc', 'imageFile']
|
||||
)
|
||||
|
||||
const onSubmit = async (values: any): Promise<void> => {
|
||||
const { handleSubmit, meta } = useForm({
|
||||
//@ts-expect-error ...
|
||||
validationSchema: schema,
|
||||
})
|
||||
|
||||
const onSubmit = handleSubmit((values) => {
|
||||
values.imageSrc = values.imageFile || values.imageSrc
|
||||
emits('update', values)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -108,13 +108,13 @@ const handleFile = async (file: File) => {
|
|||
if (base64String) value.value = base64String
|
||||
}
|
||||
|
||||
const handleChange = async (event: any) => {
|
||||
const handleChange = async (event: Event) => {
|
||||
const file = (event.target as FileEventTarget).files[0]
|
||||
handleFile(file)
|
||||
}
|
||||
const handleDrop = async (event: any) => {
|
||||
const handleDrop = async (event: DragEvent) => {
|
||||
showDropzone.value = false
|
||||
let droppedFiles = event.dataTransfer.files
|
||||
let droppedFiles = event.dataTransfer?.files
|
||||
if (!droppedFiles) return
|
||||
handleFile(droppedFiles[0])
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ export interface CustomAxiosError extends AxiosError {
|
|||
|
||||
const { token } = useAuth()
|
||||
const isLoading = ref(false)
|
||||
const error = ref<any | null>(null)
|
||||
const error = ref<CustomAxiosError | null>(null)
|
||||
|
||||
const config: AxiosRequestConfig = {
|
||||
baseURL: apiConfig.baseURL,
|
||||
|
|
|
@ -5,8 +5,7 @@ import { useEditMode } from './useEditMode'
|
|||
const { client } = useAxios()
|
||||
const { isActive: editModeIsActive } = useEditMode()
|
||||
|
||||
//@ts-expect-error ...
|
||||
const state = ref<Wishlist>({})
|
||||
const state = ref<Wishlist>()
|
||||
const isReady = ref(false)
|
||||
|
||||
const fetch = async (slugText: string): Promise<void> => {
|
||||
|
@ -14,7 +13,7 @@ const fetch = async (slugText: string): Promise<void> => {
|
|||
const { data } = await client.get(`/wishlist/${slugText}`)
|
||||
state.value = data
|
||||
isReady.value = true
|
||||
} catch (e: any) {
|
||||
} catch (e: CustomAxiosError | any) {
|
||||
if (e.isAxiosError && !(<CustomAxiosError>e.ignore)) {
|
||||
throw e
|
||||
}
|
||||
|
@ -33,7 +32,7 @@ const update = async (updatedData: Wishlist): Promise<void> => {
|
|||
...state.value,
|
||||
...data,
|
||||
}
|
||||
} catch (e: any) {
|
||||
} catch (e: CustomAxiosError | any) {
|
||||
if (e.isAxiosError && !(<CustomAxiosError>e.ignore)) {
|
||||
throw e
|
||||
}
|
||||
|
@ -48,7 +47,7 @@ const createItem = async (values: WishlistItem): Promise<void> => {
|
|||
try {
|
||||
const { data } = await client.post(`/wishlist/${id}/item`, payload)
|
||||
state.value?.items?.push(data)
|
||||
} catch (e: any) {
|
||||
} catch (e: CustomAxiosError | any) {
|
||||
if (e.isAxiosError && !(<CustomAxiosError>e.ignore)) {
|
||||
throw e
|
||||
}
|
||||
|
@ -74,7 +73,7 @@ const updateItem = async (
|
|||
1,
|
||||
data
|
||||
)
|
||||
} catch (e: any) {
|
||||
} catch (e: CustomAxiosError | any) {
|
||||
if (e.isAxiosError && !(<CustomAxiosError>e.ignore)) {
|
||||
throw e
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ const {
|
|||
} = useWishlistStore()
|
||||
|
||||
const title = computed(() => {
|
||||
return state.value.title
|
||||
return state.value?.title
|
||||
? t('common.title.text', { title: state.value.title })
|
||||
: t('common.loading.text')
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { Form } from 'vee-validate'
|
||||
import { useForm } from 'vee-validate'
|
||||
import { object, string } from 'yup'
|
||||
import { useAuth } from '@/composables'
|
||||
import IconLogin from '@/components/icons/IconLogin.vue'
|
||||
|
@ -17,10 +17,14 @@ const schema = object({
|
|||
),
|
||||
})
|
||||
|
||||
const onSubmit = (values: any): void => {
|
||||
setToken(values['api-key'])
|
||||
const { handleSubmit, meta } = useForm({
|
||||
validationSchema: schema,
|
||||
})
|
||||
|
||||
const onSubmit = handleSubmit((values) => {
|
||||
setToken(values['api-key'] as string)
|
||||
router.push('/')
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -31,12 +35,7 @@ const onSubmit = (values: any): void => {
|
|||
<h1 class="text-semibold mb-8 text-center text-3xl">
|
||||
{{ t('pages.login-view.main.title.text') }}
|
||||
</h1>
|
||||
<Form
|
||||
@submit="onSubmit"
|
||||
:validation-schema="schema"
|
||||
v-slot="{ meta }"
|
||||
class="w-full flex-col space-y-3"
|
||||
>
|
||||
<form @submit="onSubmit" class="w-full flex-col space-y-3">
|
||||
<InputText
|
||||
name="api-key"
|
||||
type="text"
|
||||
|
@ -50,7 +49,7 @@ const onSubmit = (values: any): void => {
|
|||
:disabled="!meta.dirty || !meta.valid"
|
||||
>{{ t('pages.login-view.main.form.submit.text') }}</ButtonBase
|
||||
>
|
||||
</Form>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
Loading…
Add table
Reference in a new issue