fix: TS errors, serialize calls, unused imports, pre-commit hook
Build & Deploy / build (push) Successful in 32s
Build & Deploy / docker (push) Successful in 1m42s

This commit is contained in:
Kevin
2026-07-07 20:49:52 +02:00
parent 15d3a13d0a
commit c4cad4f875
16 changed files with 27 additions and 101 deletions
+3 -3
View File
@@ -9,7 +9,7 @@ export default class ComponentsController {
async index({ inertia, auth }: HttpContext) {
const user = await auth.authenticate()
const components = await Component.query().preload('type').where('userId', user.id)
return inertia.render('components/index', { components: components.map((c) => c.serialize({ relations: true })) })
return inertia.render('components/index', { components: components.map((c) => c.serialize()) })
}
async create({ inertia }: HttpContext) {
@@ -40,7 +40,7 @@ export default class ComponentsController {
.where('userId', user.id)
.andWhere('id', componentId)
.firstOrFail()
return inertia.render('components/show', { component: component.serialize({ relations: true }) })
return inertia.render('components/show', { component: component.serialize() })
}
async edit({ params, auth, inertia }: HttpContext) {
@@ -53,7 +53,7 @@ export default class ComponentsController {
.andWhere('id', componentId)
.firstOrFail()
return inertia.render('components/edit', {
component: component.serialize({ relations: true }),
component: component.serialize(),
types: types.map((t) => t.serialize()),
})
}
+4 -4
View File
@@ -19,7 +19,7 @@ export default class ComputersController {
picturesQuery.where('order', 1)
})
return inertia.render('computers/index', { computers: computers.map((c) => c.serialize({ relations: true })) })
return inertia.render('computers/index', { computers: computers.map((c) => c.serialize()) })
}
async create({ auth, inertia }: HttpContext) {
@@ -29,7 +29,7 @@ export default class ComputersController {
.where('userId', user.id)
.whereNull('computerId')
.preload('type')
return inertia.render('computers/create', { components: components.map((c) => c.serialize({ relations: true })), states: states.map((s) => s.serialize()) })
return inertia.render('computers/create', { components: components.map((c) => c.serialize()), states: states.map((s) => s.serialize()) })
}
async store({ auth, request, response }: HttpContext) {
@@ -60,7 +60,7 @@ export default class ComputersController {
.where('user_id', user.id)
.andWhere('id', computerId)
.firstOrFail()
return inertia.render('computers/show', { computer: computer.serialize({ relations: true }) })
return inertia.render('computers/show', { computer: computer.serialize() })
}
async edit({ params, inertia, auth }: HttpContext) {
@@ -86,7 +86,7 @@ export default class ComputersController {
'id',
computer.components.map((c) => c.id)
)
return inertia.render('computers/edit', { computer: computer.serialize({ relations: true }), availableComponents: availableComponents.map((c) => c.serialize({ relations: true })), states: states.map((s) => s.serialize()) })
return inertia.render('computers/edit', { computer: computer.serialize(), availableComponents: availableComponents.map((c) => c.serialize()), states: states.map((s) => s.serialize()) })
}
async update({ params, request, response }: HttpContext) {
-1
View File
@@ -1,4 +1,3 @@
import app from '@adonisjs/core/services/app'
import { defineConfig } from '@adonisjs/core/http'
/**
-1
View File
@@ -1,5 +1,4 @@
import env from '#start/env'
import app from '@adonisjs/core/services/app'
import { defineConfig, stores } from '@adonisjs/session'
const sessionConfig = defineConfig({
+2 -2
View File
@@ -415,9 +415,9 @@ export class StreamSchema extends BaseModel {
declare udpForwarding: number
}
export class UserSchema extends BaseModel {
export class NpmUserSchema extends BaseModel {
static $columns = ['avatar', 'createdOn', 'email', 'id', 'isDeleted', 'isDisabled', 'modifiedOn', 'name', 'nickname', 'roles'] as const
$columns = UserSchema.$columns
$columns = NpmUserSchema.$columns
@column()
declare avatar: string
@column.dateTime()
-21
View File
@@ -1,35 +1,14 @@
<script lang="ts" setup>
import { Link } from '@adonisjs/inertia/vue'
import { useForm } from '@inertiajs/vue3'
import { computed } from 'vue'
import EmptyLayout from '~/pages/layout/emptyLayout.vue'
defineOptions({ layout: EmptyLayout })
const props = defineProps<{ errors?: Record<string, string> }>()
const vineErrors = computed(() => {
if (props.errors && !Array.isArray(props.errors)) {
return props.errors
}
return {}
})
const authError = computed(() => {
if (props.errors && !Array.isArray(props.errors)) {
return props.errors
}
return null
})
const form = useForm({
email: '',
password: '',
})
function getErrorMessage(field: string): string | null {
return vineErrors.value[field] || null
}
</script>
<template>
+1 -1
View File
@@ -21,7 +21,7 @@ const form = useForm({
<p class="text-sm text-gray-600 mt-2">Join PC Creator today</p>
</div>
<Form route="new_account.store" #default="{ processing, errors }">
<Form route="new_account.store" #default="{ processing }">
<div class="space-y-4 sm:space-y-6">
<div>
<label class="block">
+2 -15
View File
@@ -1,11 +1,10 @@
<script setup lang="ts">
import { computed, reactive } from 'vue'
import { reactive } from 'vue'
import { Link } from '@adonisjs/inertia/vue'
import { useForm } from '@inertiajs/vue3'
import CustomSelect from '~/pages/widgets/CustomSelect.vue'
const props = defineProps<{ types: any[]; errors?: Record<string, string> }>()
const errors = computed(() => props.errors || {})
defineProps<{ types: any[]; errors?: Record<string, string> }>()
const form = reactive({
name: '',
price: 0,
@@ -14,18 +13,6 @@ const form = reactive({
quantity: 1,
})
function getErrorMessage(field: string): string | null {
return errors.value[field] || null
}
function formatDateForMySQL(date: string) {
const d = new Date(date)
const year = d.getFullYear()
const month = String(d.getMonth() + 1).padStart(2, '0')
const day = String(d.getDate()).padStart(2, '0')
form.purchase_date = `${year}-${month}-${day}`
}
function submitForm() {
const inertiaForm = useForm(form)
inertiaForm.post('/components')
+1 -14
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, reactive } from 'vue'
import { reactive } from 'vue'
import { Link } from '@adonisjs/inertia/vue'
import { usePage } from '@inertiajs/vue3'
import CustomSelect from '~/pages/widgets/CustomSelect.vue'
@@ -11,7 +11,6 @@ const { props } = usePage<{
errors?: Record<string, string>
}>()
const { component, types, origin } = props
const errors = computed(() => props.errors || {})
const form = reactive({
id: component.id,
@@ -21,18 +20,6 @@ const form = reactive({
purchaseDate: component.purchaseDate,
origin: origin,
})
function getErrorMessage(field: string): string | null {
return errors.value[field] || null
}
function formatDateForMySQL(date: string) {
const d = new Date(date)
const year = d.getFullYear()
const month = String(d.getMonth() + 1).padStart(2, '0')
const day = String(d.getDate()).padStart(2, '0')
form.purchase_date = `${year}-${month}-${day}`
}
</script>
<template>
-5
View File
@@ -9,7 +9,6 @@ const { props } = usePage<{
errors: Record<string, string>
}>()
const { components, states } = props
const errors = computed(() => props.errors || {})
const componentTypeOrder = [
'Processor',
@@ -48,10 +47,6 @@ const form = reactive({
globalScore: 0,
componentsId: [] as number[],
})
function getErrorMessage(field: string): string | null {
return errors.value[field] || null
}
</script>
<template>
+2 -11
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, reactive } from 'vue'
import { reactive } from 'vue'
import { Link } from '@adonisjs/inertia/vue'
import { router, usePage } from '@inertiajs/vue3'
@@ -9,8 +9,7 @@ const { props } = usePage<{
states: any[]
errors?: Record<string, string>
}>()
const { computer, availableComponents, states } = props
const errors = computed(() => props.errors || {})
const { computer, states } = props
const form = reactive({
id: computer.id,
@@ -23,17 +22,9 @@ const form = reactive({
componentsId: computer.components.map((c: any) => c.id),
})
function updateComponents(componentsId: number[]) {
form.componentsId = componentsId
}
function deleteComputer(id: number) {
router.delete(`/computers/${id}`)
}
function getErrorMessage(field: string): string | null {
return errors.value[field] || null
}
</script>
<template>
+1 -1
View File
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { Link } from '@adonisjs/inertia/vue'
const { props } = defineProps<{ computer: any }>()
const { computer } = defineProps<{ computer: any }>()
</script>
<template>
-2
View File
@@ -1,12 +1,10 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import { useSidebar } from '~/composables/useSidebar'
import { Link } from '@adonisjs/inertia/vue'
import { usePage } from '@inertiajs/vue3'
import { userProfileIcon } from '~/assets/icons'
const dropdownOpen = ref(false)
const { isOpen } = useSidebar()
const page = usePage()
+2 -16
View File
@@ -1,6 +1,3 @@
import { PageProps } from '@adonisjs/inertia/types'
import { InertiaAppProps } from '@inertiajs/vue3/types/app'
interface ComponentType {
id: number
name: string
@@ -39,13 +36,13 @@ export type Component = {
type: ComponentType
}
interface ServerImage {
export interface ServerImage {
id: number
link: string
order: number
}
interface NewImage {
export interface NewImage {
file: File
order: number
}
@@ -63,15 +60,4 @@ export type UIAuthError = {
message: string
}
interface SharedProps extends PageProps {
auth: {
user: {
id: number
name: string
email: string
}
}
}
export type PageWithSharedProps = InertiaAppProps<SharedProps>
export type Image = ServerImage | NewImage
+6
View File
@@ -1,4 +1,10 @@
<script setup lang="ts">
type UIAuthError = {
status: number
code: string
message: string
}
defineProps<{
authError?: UIAuthError
}>()
+3 -4
View File
@@ -84,8 +84,7 @@
import { computed, ref, watch } from 'vue'
import { crossIcon } from '~/assets/icons'
import { Navigation, Pagination } from 'vue3-carousel'
import type { NewImage, ServerImage } from '../../../app/types/UItypes'
import type { Image } from '~/pages/types/UITypes'
import type { Image, NewImage, ServerImage } from '~/pages/types/UITypes'
const props = defineProps<{
galleryId: string
@@ -134,12 +133,12 @@ function addImage() {
function removeImage(image: Image) {
if ('id' in image) {
const index = serverImages.value.findIndex((img) => img.id === image.id)
const index = serverImages.value.findIndex((img: ServerImage) => img.id === image.id)
if (index !== -1) {
serverImages.value.splice(index, 1)
}
} else {
const index = newImages.value.findIndex((img) => img.file === image.file)
const index = newImages.value.findIndex((img: NewImage) => img.file === image.file)
if (index !== -1) {
newImages.value.splice(index, 1)
}