mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 14:08:11 +00:00
fix: the request approaval pricing ui
This commit is contained in:
@@ -299,12 +299,7 @@ function DraftBookingView({
|
|||||||
[booking.files],
|
[booking.files],
|
||||||
);
|
);
|
||||||
|
|
||||||
const pricingQuery = useQuery(
|
const pricing = booking.pricingBreakdown;
|
||||||
api.bookings.generatePrice.queryOptions({
|
|
||||||
input: { id: booking.id },
|
|
||||||
enabled: !!booking.id,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
const uploadMutation = useMutation({
|
const uploadMutation = useMutation({
|
||||||
mutationFn: (files: Record<string, File | File[] | null>) =>
|
mutationFn: (files: Record<string, File | File[] | null>) =>
|
||||||
@@ -499,7 +494,7 @@ function DraftBookingView({
|
|||||||
|
|
||||||
<Card
|
<Card
|
||||||
className={cn(
|
className={cn(
|
||||||
pricingQuery.isSuccess ? "border-primary/20 bg-primary/5" : "",
|
pricing ? "border-primary/20 bg-primary/5" : "",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
@@ -512,28 +507,7 @@ function DraftBookingView({
|
|||||||
</CardDescription>
|
</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
{pricingQuery.isLoading ? (
|
{pricing ? (
|
||||||
<div className="flex flex-col items-center gap-3 py-6 text-center">
|
|
||||||
<LoaderCircle className="size-6 animate-spin text-primary" />
|
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
Calculating price…
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
) : pricingQuery.isError ? (
|
|
||||||
<div className="flex flex-col items-center gap-3 py-6 text-center">
|
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
Could not calculate price.
|
|
||||||
</p>
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
onClick={() => pricingQuery.refetch()}
|
|
||||||
>
|
|
||||||
Retry
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
) : pricingQuery.data ? (
|
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<div className="overflow-hidden rounded-lg border">
|
<div className="overflow-hidden rounded-lg border">
|
||||||
<table className="w-full text-left text-xs">
|
<table className="w-full text-left text-xs">
|
||||||
@@ -546,7 +520,7 @@ function DraftBookingView({
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody className="divide-y">
|
<tbody className="divide-y">
|
||||||
{pricingQuery.data.lineItems.map((item, i) => (
|
{pricing.lineItems.map((item, i) => (
|
||||||
<tr key={i}>
|
<tr key={i}>
|
||||||
<td className="px-4 py-2 text-foreground">
|
<td className="px-4 py-2 text-foreground">
|
||||||
{item.description}
|
{item.description}
|
||||||
@@ -561,29 +535,19 @@ function DraftBookingView({
|
|||||||
Total Estimated Cost
|
Total Estimated Cost
|
||||||
</td>
|
</td>
|
||||||
<td className="px-4 py-2 text-right text-foreground">
|
<td className="px-4 py-2 text-right text-foreground">
|
||||||
{pricingQuery.data.totalAmount.toLocaleString()}{" "}
|
{pricing.totalAmount.toLocaleString()}{" "}
|
||||||
{pricingQuery.data.currency}
|
{pricing.currency}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{pricingQuery.data.warnings.length > 0 && (
|
|
||||||
<div className="flex flex-col gap-2 rounded-lg border border-amber-200 bg-amber-50 p-3">
|
|
||||||
{pricingQuery.data.warnings.map((w, i) => (
|
|
||||||
<p
|
|
||||||
key={i}
|
|
||||||
className="flex items-start gap-2 text-xs text-amber-800"
|
|
||||||
>
|
|
||||||
<AlertTriangle className="mt-0.5 size-3 shrink-0" />
|
|
||||||
{w}
|
|
||||||
</p>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : (
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
Pricing will be calculated after submission.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|||||||
@@ -244,6 +244,21 @@ export interface IBooking extends BaseEntity {
|
|||||||
|
|
||||||
latestChangeRequestNote?: string | null;
|
latestChangeRequestNote?: string | null;
|
||||||
contractSummary?: string | null;
|
contractSummary?: string | null;
|
||||||
|
pricingBreakdown?: PricingBreakdown | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PricingBreakdownLineItem {
|
||||||
|
code: string;
|
||||||
|
amount: number;
|
||||||
|
currency: string;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PricingBreakdown {
|
||||||
|
currency: string;
|
||||||
|
lineItems: PricingBreakdownLineItem[];
|
||||||
|
generatedAt: string;
|
||||||
|
totalAmount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IInvoice extends BaseEntity {
|
export interface IInvoice extends BaseEntity {
|
||||||
|
|||||||
Reference in New Issue
Block a user