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