mirror of
https://github.com/sakaljurgis/best-choice.git
synced 2026-07-08 21:47:40 +00:00
add shared
This commit is contained in:
@@ -1,35 +1,14 @@
|
||||
import type { PaginatedResponse } from '@shared/models/pagination';
|
||||
import type {
|
||||
ItemPrice,
|
||||
PriceCondition,
|
||||
PriceSourceType
|
||||
} from '@shared/models/item-price';
|
||||
import { apiFetch } from './http-client';
|
||||
|
||||
export type PriceCondition = 'new' | 'used';
|
||||
export type PriceSourceType = 'url' | 'manual';
|
||||
export type { PriceCondition, PriceSourceType };
|
||||
|
||||
export interface ItemPrice {
|
||||
id: string;
|
||||
itemId: string;
|
||||
condition: PriceCondition;
|
||||
amount: number;
|
||||
currency: string;
|
||||
sourceType: PriceSourceType;
|
||||
sourceUrlId: string | null;
|
||||
sourceUrl: string | null;
|
||||
sourceNote: string | null;
|
||||
note: string | null;
|
||||
observedAt: string;
|
||||
isPrimary: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
interface ListResponseMeta {
|
||||
limit: number;
|
||||
offset: number;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface ItemPricesResponse {
|
||||
data: ItemPrice[];
|
||||
meta: ListResponseMeta;
|
||||
}
|
||||
export type ItemPricesResponse = PaginatedResponse<ItemPrice>;
|
||||
|
||||
export interface FetchItemPricesParams {
|
||||
limit?: number;
|
||||
|
||||
+3
-43
@@ -1,48 +1,8 @@
|
||||
import type { PaginatedResponse } from '@shared/models/pagination';
|
||||
import type { Item, ItemStatus } from '@shared/models/item';
|
||||
import { apiFetch } from './http-client';
|
||||
|
||||
export type ItemStatus = 'active' | 'rejected';
|
||||
|
||||
export interface Item {
|
||||
id: string;
|
||||
projectId: string;
|
||||
manufacturer: string | null;
|
||||
model: string;
|
||||
sourceUrlId: string | null;
|
||||
sourceUrl: string | null;
|
||||
status: ItemStatus;
|
||||
note: string | null;
|
||||
attributes: Record<string, unknown>;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
priceSummary: ItemPriceSummary | null;
|
||||
}
|
||||
|
||||
export interface ItemPriceSummary {
|
||||
minAmount: number;
|
||||
maxAmount: number;
|
||||
currency: string | null;
|
||||
priceCount: number;
|
||||
hasMixedCurrency: boolean;
|
||||
newMinAmount: number | null;
|
||||
newCount: number;
|
||||
newCurrency: string | null;
|
||||
newHasMixedCurrency: boolean;
|
||||
usedMinAmount: number | null;
|
||||
usedCount: number;
|
||||
usedCurrency: string | null;
|
||||
usedHasMixedCurrency: boolean;
|
||||
}
|
||||
|
||||
interface ListResponseMeta {
|
||||
limit: number;
|
||||
offset: number;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface ProjectItemsResponse {
|
||||
data: Item[];
|
||||
meta: ListResponseMeta;
|
||||
}
|
||||
export type ProjectItemsResponse = PaginatedResponse<Item>;
|
||||
|
||||
export interface FetchProjectItemsParams {
|
||||
limit?: number;
|
||||
|
||||
@@ -1,28 +1,8 @@
|
||||
import type { PaginatedResponse } from '@shared/models/pagination';
|
||||
import type { Project, ProjectStatus } from '@shared/models/project';
|
||||
import { apiFetch } from './http-client';
|
||||
|
||||
export type ProjectStatus = 'active' | 'archived';
|
||||
|
||||
export interface Project {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
status: ProjectStatus;
|
||||
attributes: string[];
|
||||
priorityRules: unknown;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
interface ListResponseMeta {
|
||||
limit: number;
|
||||
offset: number;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface ProjectsListResponse {
|
||||
data: Project[];
|
||||
meta: ListResponseMeta;
|
||||
}
|
||||
export type ProjectsListResponse = PaginatedResponse<Project>;
|
||||
|
||||
export interface FetchProjectsParams {
|
||||
limit?: number;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect } from 'react';
|
||||
import type { Item } from '../../api/items';
|
||||
import type { Item } from '@shared/models/item';
|
||||
import { ItemPricesPanel } from './item-prices-panel';
|
||||
|
||||
interface ItemPricesModalProps {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import type { Item } from '@shared/models/item';
|
||||
import {
|
||||
useCreateItemMutation,
|
||||
useUpdateItemMutation,
|
||||
@@ -11,7 +12,6 @@ import {
|
||||
importItemFromUrl,
|
||||
type CreateItemPayload,
|
||||
type ImportedItemData,
|
||||
type Item,
|
||||
type UpdateItemPayload
|
||||
} from '../../api/items';
|
||||
import { ItemFormModal } from '../../components/item-form-modal';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
import type { ProjectStatus } from '../../api/projects';
|
||||
import type { ProjectStatus } from '@shared/models/project';
|
||||
|
||||
interface ProjectHeaderProps {
|
||||
name: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { ExternalLink, Pencil } from 'lucide-react';
|
||||
import type { Item } from '../../api/items';
|
||||
import type { Item } from '@shared/models/item';
|
||||
|
||||
interface ProjectItemsSectionProps {
|
||||
items: Item[];
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
fetchProjects,
|
||||
updateProject,
|
||||
type CreateProjectPayload,
|
||||
type Project,
|
||||
type ProjectsListResponse,
|
||||
type UpdateProjectPayload
|
||||
} from '../api/projects';
|
||||
@@ -16,6 +15,7 @@ import {
|
||||
type ProjectItemsResponse,
|
||||
type UpdateItemPayload
|
||||
} from '../api/items';
|
||||
import type { Project } from '@shared/models/project';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
|
||||
const DEFAULT_LIMIT = 50;
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
"jsx": "react-jsx",
|
||||
"types": ["vite/client"],
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"baseUrl": "./src"
|
||||
"baseUrl": "./src",
|
||||
"paths": {
|
||||
"@shared/*": ["../../shared/*.d.ts"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
|
||||
@@ -14,6 +14,14 @@ export default defineConfig(({ mode }) => {
|
||||
port: clientPort,
|
||||
proxy: {
|
||||
'/api': proxyTarget
|
||||
},
|
||||
fs: {
|
||||
allow: [path.resolve(__dirname, '..')]
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@shared': path.resolve(__dirname, '../shared')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user