Files
pc_builder/inertia/pages/computers/index.vue
T
Kevin L'Hereec 94f89be605 chore: harden config, strengthen frontend typing, fix UTF-8 mojibake
Security config (3.1):
- config/session.ts: cookie.secure now follows app.inProduction instead of
  being hardcoded to false
- config/shield.ts: enable CSP with baseline directives compatible with
  Vite dev server and Inertia (self + @viteDevUrl/@viteHmrUrl)

Frontend typing (3.2):
- Replace 'any' props with concrete types (Computer, Component, ComponentType,
  ComputerState) across computers/*.vue and components/*.vue, using the
  existing inertia/pages/types/UITypes.ts definitions
- Fix UITypes.ts: export ComponentType/ComputerState, switch from interface
  to type (interfaces are never assignable to Inertia's ComponentProps index
  signature), drop the stale componentTypeId/componentStateId fields that
  didn't match the actual Lucid schema (real field is typeId, no component
  state exists)
- Add an asPageProp() boundary cast in the two controllers: Lucid's
  serialize() returns a loosely typed ModelObject that isn't structurally
  assignable to the concrete page prop shapes (and the inertia/** tree is
  excluded from the backend tsconfig, so real types can't be imported
  directly across that boundary)

UTF-8 mojibake fixes (3.3):
- Repair broken accented characters (├®/├á/├┤ -> é/à/ô, Ôé¼ -> €) left over
  from a bad encoding during the GWT->Inertia migration, across
  ComponentEditor.vue, ComputerComponentsTable.vue, SimpleGallery.vue,
  TableComponent.vue, isAdminMode.ts and the custom directives

Misc cleanup (3.5):
- computer.ts: replace console.warn with the app logger (includes
  computerId) when .cost is accessed without preloading components
2026-07-23 11:10:37 +02:00

48 lines
1.5 KiB
Vue

<script setup lang="ts">
import { Link } from '@adonisjs/inertia/vue'
import type { Computer } from '~/pages/types/UITypes'
defineProps<{ computers: Computer[] }>()
</script>
<template>
<div>
<div class="flex justify-between items-center">
<h3 class="text-3xl font-semibold text-gray-700">Computers</h3>
<Link
href="/computers/create"
type="button"
as="button"
class="inline-flex shrink-0 px-4 py-2 bg-indigo-600 text-white rounded hover:bg-blue-700 transition"
>
Add
</Link>
</div>
<div class="mt-6 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<template v-if="computers.length > 0">
<div
v-for="computer in computers"
:key="computer.id"
class="p-4 border rounded-lg shadow hover:shadow-lg transition"
>
<h4 class="font-semibold text-lg text-gray-800">{{ computer.title }}</h4>
<p class="text-gray-600">State: {{ computer.state?.name }}</p>
<p class="text-indigo-600 font-semibold">Price: ${{ computer.sellPrice }}</p>
<p class="text-gray-500 text-sm">{{ computer.components.length }} components</p>
<Link
:href="`/computers/${computer.id}`"
class="mt-2 inline-block text-indigo-600 hover:text-indigo-700"
>
View Details
</Link>
</div>
</template>
<template v-else>
<p class="text-gray-500">No computers yet. Create one to get started!</p>
</template>
</div>
</div>
</template>