Files
portal/app/resources/js/views/projects/NewProjectDialog.story.vue
T
Дмитрий 55a9d3fe00 fix(types): unify Project interface + NavItem.countKey + drop legacy Record
vue-tsc was emitting 9 errors from two issues:

1. ProjectCard.vue had a local `interface Project` missing region_mask /
   region_mode / delivery_days_mask, while stores/projectsStore.ts
   exported the canonical one with those fields. ProjectsView.vue passed
   the canonical Project to ProjectCard handler signatures which expected
   the local incomplete one → 5× TS2322.

2. EditProjectDialog passed `project: Project | Record<string, unknown>`
   to NewProjectDialog which expected `Record<string, unknown> | null`.
   Project lacks an index signature → TS2322.

3. AppSidebar.vue template referenced `item.countKey` not declared in
   NavItem interface → 2× TS2339.

Changes:
- ProjectCard.vue: drop local Project, import from projectsStore.
- NewProjectDialog.vue: project prop type → Project | null (was Record).
  Drop `as { id: number }` cast on PATCH URL.
- EditProjectDialog.vue: project prop type → Project | null.
- AppSidebar.vue: add `countKey?: string` to NavItem.
- projectsStore.ts: make region_mask/region_mode/delivery_days_mask
  optional (backward-compat for mock fixtures; production rows always
  populate them by schema).
- Test/story fixtures expanded with delivered_today/is_active/archived_at/
  sync_status to match strict Project shape.

Verification:
- npx vue-tsc --noEmit → 0 errors (was 9).
- npx vitest run on 5 affected specs → 16/16 passed + 2 skipped.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 20:15:26 +03:00

35 lines
988 B
Vue

<template>
<Story title="NewProjectDialog">
<Variant title="Site tab (create mode)">
<NewProjectDialog v-model="open" mode="create" />
</Variant>
<Variant title="SMS tab (create mode)">
<NewProjectDialog v-model="open" mode="create" />
</Variant>
<Variant title="Edit mode (readonly signal_type)">
<NewProjectDialog v-model="open" mode="edit" :project="sampleProject" />
</Variant>
</Story>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import NewProjectDialog from './NewProjectDialog.vue';
const open = ref(true);
const sampleProject = {
id: 1,
name: 'Окна СПб',
signal_type: 'site' as const,
signal_identifier: 'okna.ru',
daily_limit_target: 50,
delivered_today: 12,
is_active: true,
archived_at: null,
sync_status: 'ok' as const,
region_mask: 0,
region_mode: 'include' as const,
delivery_days_mask: 127,
};
</script>