update front ts 2
This commit is contained in:
parent
a6fc5bab7a
commit
d3bb9a8b3b
@ -16,34 +16,48 @@ import { useState } from "react"
|
|||||||
import { Eye, ArrowUpDown } from "lucide-react"
|
import { Eye, ArrowUpDown } from "lucide-react"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
|
|
||||||
type Product = {
|
export default function Purchases() {
|
||||||
title: string
|
const { data: purchases = [], isLoading: purchasesLoading } = useQuery<Purchase[]>({
|
||||||
width?: number
|
queryKey: ['purchases'],
|
||||||
height?: number
|
queryFn: () => purchaseService.getAll()
|
||||||
year?: string
|
})
|
||||||
dateAcquisition: string
|
|
||||||
artist: {
|
|
||||||
firstName?: string
|
|
||||||
lastName: string
|
|
||||||
}
|
|
||||||
imageName?: string
|
|
||||||
client?: {
|
|
||||||
url: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type PurchaseProduct = {
|
const { data: clients = [], isLoading: clientsLoading } = useQuery<Client[]>({
|
||||||
product: Product
|
queryKey: ['clients'],
|
||||||
}
|
queryFn: clientService.getAll
|
||||||
|
})
|
||||||
|
|
||||||
interface Purchase {
|
const [selectedClient, setSelectedClient] = useState<string>('all')
|
||||||
products: PurchaseProduct[]
|
|
||||||
customer: {
|
const filteredPurchases = selectedClient === 'all'
|
||||||
id: number
|
? purchases
|
||||||
contactFirstName: string
|
: purchases.filter((p: Purchase) => p.customer.name === selectedClient)
|
||||||
contactLastName: string
|
|
||||||
}
|
if (purchasesLoading || clientsLoading) return <div>Chargement...</div>
|
||||||
amountTotal: number
|
|
||||||
|
return (
|
||||||
|
<div className="container mx-auto p4 py-10 p4">
|
||||||
|
<div className="mb-4">
|
||||||
|
<Select value={selectedClient} onValueChange={setSelectedClient}>
|
||||||
|
<SelectTrigger className="w-[280px]">
|
||||||
|
<SelectValue placeholder="Sélectionner un client" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectGroup>
|
||||||
|
<SelectLabel>Clients</SelectLabel>
|
||||||
|
<SelectItem value="all">Tous les clients</SelectItem>
|
||||||
|
{clients.map((client) => (
|
||||||
|
<SelectItem key={client.id} value={client.id.toString()}>
|
||||||
|
{client.name}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectGroup>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
<DataTable columns={columns} data={filteredPurchases} />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnDef<Purchase>[] = [
|
const columns: ColumnDef<Purchase>[] = [
|
||||||
@ -131,48 +145,4 @@ const columns: ColumnDef<Purchase>[] = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
export default function Purchases() {
|
|
||||||
const { data: purchases = [], isLoading: purchasesLoading } = useQuery<Purchase[]>({
|
|
||||||
queryKey: ['purchases'],
|
|
||||||
queryFn: purchaseService.getAll
|
|
||||||
})
|
|
||||||
|
|
||||||
const { data: clients = [], isLoading: clientsLoading } = useQuery<Client[]>({
|
|
||||||
queryKey: ['clients'],
|
|
||||||
queryFn: clientService.getAll
|
|
||||||
})
|
|
||||||
|
|
||||||
const [selectedClient, setSelectedClient] = useState<string>('all')
|
|
||||||
|
|
||||||
const filteredPurchases = selectedClient === 'all'
|
|
||||||
? purchases
|
|
||||||
: purchases.filter(p => p.customer.id === parseInt(selectedClient))
|
|
||||||
|
|
||||||
if (purchasesLoading || clientsLoading) return <div>Chargement...</div>
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="container mx-auto p4 py-10 p4">
|
|
||||||
<div className="mb-4">
|
|
||||||
<Select value={selectedClient} onValueChange={setSelectedClient}>
|
|
||||||
<SelectTrigger className="w-[280px]">
|
|
||||||
<SelectValue placeholder="Sélectionner un client" />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectGroup>
|
|
||||||
<SelectLabel>Clients</SelectLabel>
|
|
||||||
<SelectItem value="all">Tous les clients</SelectItem>
|
|
||||||
{clients.map((client) => (
|
|
||||||
<SelectItem key={client.id} value={client.id.toString()}>
|
|
||||||
{client.name}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectGroup>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
<DataTable columns={columns} data={filteredPurchases} />
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -14,12 +14,21 @@ export type Purchase = {
|
|||||||
product: {
|
product: {
|
||||||
code: string
|
code: string
|
||||||
title: string
|
title: string
|
||||||
|
width: number
|
||||||
|
height: number
|
||||||
|
year: string
|
||||||
|
dateAcquisition: string
|
||||||
|
imageName: string
|
||||||
|
client: {
|
||||||
|
url: string
|
||||||
|
}
|
||||||
artist: {
|
artist: {
|
||||||
firstName: string
|
firstName: string
|
||||||
lastName: string
|
lastName: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
acquisitionPrice: number
|
acquisitionPrice: number
|
||||||
|
dateAcquisition: string
|
||||||
}>
|
}>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
frontend/tsconfig.app.tsbuildinfo
Normal file
1
frontend/tsconfig.app.tsbuildinfo
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/components/header.tsx","./src/components/table.tsx","./src/components/theme-provider.tsx","./src/components/ui/button.tsx","./src/components/ui/card.tsx","./src/components/ui/dropdown-menu.tsx","./src/components/ui/input.tsx","./src/components/ui/label.tsx","./src/components/ui/select.tsx","./src/components/ui/table.tsx","./src/lib/utils.ts","./src/pages/dashboard.tsx","./src/pages/login.tsx","./src/services/auth.service.ts","./src/services/client.service.ts","./src/services/purchase.service.ts"],"version":"5.6.3"}
|
||||||
Loading…
x
Reference in New Issue
Block a user