for no order i removed place order button
This commit is contained in:
parent
1894b1f9a5
commit
2235f2ee68
@ -1,3 +1,4 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
import { orderBookingClient } from '../../api/clients';
|
import { orderBookingClient } from '../../api/clients';
|
||||||
import { ORDER_BOOKING } from '../../api/config';
|
import { ORDER_BOOKING } from '../../api/config';
|
||||||
import type { WiredDetailViewProps } from './OrderDetail';
|
import type { WiredDetailViewProps } from './OrderDetail';
|
||||||
@ -6,9 +7,15 @@ import { Spinner } from '../reusable/Spinner';
|
|||||||
import { EmptyState } from '../reusable/EmptyState';
|
import { EmptyState } from '../reusable/EmptyState';
|
||||||
import { CallCard } from '../cards/CallCard';
|
import { CallCard } from '../cards/CallCard';
|
||||||
|
|
||||||
export function CallDetail({ instanceId }: WiredDetailViewProps) {
|
export function CallDetail({ instanceId, onDataLoad }: WiredDetailViewProps) {
|
||||||
const { data, loading, error } = useDetailViewData(orderBookingClient, ORDER_BOOKING.detailViews.CALLS, instanceId);
|
const { data, loading, error } = useDetailViewData(orderBookingClient, ORDER_BOOKING.detailViews.CALLS, instanceId);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (data && onDataLoad) {
|
||||||
|
onDataLoad(data);
|
||||||
|
}
|
||||||
|
}, [data, onDataLoad]);
|
||||||
|
|
||||||
if (error) return <EmptyState title="Couldn't load record" hint={error} />;
|
if (error) return <EmptyState title="Couldn't load record" hint={error} />;
|
||||||
if (loading) return <div className="py-8 flex justify-center"><Spinner label="Loading Call Details..." /></div>;
|
if (loading) return <div className="py-8 flex justify-center"><Spinner label="Loading Call Details..." /></div>;
|
||||||
if (!data) return <EmptyState title="No details found" />;
|
if (!data) return <EmptyState title="No details found" />;
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
import { orderBookingClient } from '../../api/clients';
|
import { orderBookingClient } from '../../api/clients';
|
||||||
import { ORDER_BOOKING } from '../../api/config';
|
import { ORDER_BOOKING } from '../../api/config';
|
||||||
import { useDetailViewData } from './useDetailViewData';
|
import { useDetailViewData } from './useDetailViewData';
|
||||||
@ -6,15 +7,22 @@ import { OrderCard } from '../cards/OrderCard';
|
|||||||
export interface WiredDetailViewProps {
|
export interface WiredDetailViewProps {
|
||||||
instanceId: string | number;
|
instanceId: string | number;
|
||||||
columns?: 1 | 2 | 3;
|
columns?: 1 | 2 | 3;
|
||||||
|
onDataLoad?: (data: any) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function OrderDetail({ instanceId }: WiredDetailViewProps) {
|
export function OrderDetail({ instanceId, onDataLoad }: WiredDetailViewProps) {
|
||||||
const { data, config, loading, error } = useDetailViewData(
|
const { data, config, loading, error } = useDetailViewData(
|
||||||
orderBookingClient,
|
orderBookingClient,
|
||||||
ORDER_BOOKING.detailViews.ORDERS,
|
ORDER_BOOKING.detailViews.ORDERS,
|
||||||
instanceId
|
instanceId
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (data && onDataLoad) {
|
||||||
|
onDataLoad(data);
|
||||||
|
}
|
||||||
|
}, [data, onDataLoad]);
|
||||||
|
|
||||||
if (loading) return <div className="p-4 text-gray-500">Loading Order Details...</div>;
|
if (loading) return <div className="p-4 text-gray-500">Loading Order Details...</div>;
|
||||||
if (error) return <div className="p-4 text-red-500">{error}</div>;
|
if (error) return <div className="p-4 text-red-500">{error}</div>;
|
||||||
if (!data) return <div className="p-4 text-gray-500">No data found.</div>;
|
if (!data) return <div className="p-4 text-gray-500">No data found.</div>;
|
||||||
|
|||||||
@ -112,7 +112,7 @@ export function CallsPage() {
|
|||||||
>
|
>
|
||||||
{instanceId != null && (
|
{instanceId != null && (
|
||||||
<>
|
<>
|
||||||
<CallDetail instanceId={instanceId} />
|
<CallDetail instanceId={instanceId} onDataLoad={setSelectedRow} />
|
||||||
<div className="absolute bottom-6 right-6 flex flex-col items-end gap-3 z-50">
|
<div className="absolute bottom-6 right-6 flex flex-col items-end gap-3 z-50">
|
||||||
{isFabOpen && (
|
{isFabOpen && (
|
||||||
<div className="flex flex-col gap-2 bg-white p-3 rounded-sm shadow-xl border border-border-subtle animate-in fade-in slide-in-from-bottom-2">
|
<div className="flex flex-col gap-2 bg-white p-3 rounded-sm shadow-xl border border-border-subtle animate-in fade-in slide-in-from-bottom-2">
|
||||||
@ -143,6 +143,8 @@ export function CallsPage() {
|
|||||||
Place Order
|
Place Order
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
} else if (stateName.includes('no order') || stateName.includes('non-productive') || stateName.includes('non productive')) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Button size="sm" onClick={(e) => {
|
<Button size="sm" onClick={(e) => {
|
||||||
|
|||||||
@ -114,7 +114,7 @@ export function OrdersPage() {
|
|||||||
>
|
>
|
||||||
{instanceId != null && (
|
{instanceId != null && (
|
||||||
<>
|
<>
|
||||||
<OrderDetail instanceId={instanceId} />
|
<OrderDetail instanceId={instanceId} onDataLoad={setSelectedRow} />
|
||||||
<div className="absolute bottom-6 right-6 flex flex-col items-end gap-3 z-50">
|
<div className="absolute bottom-6 right-6 flex flex-col items-end gap-3 z-50">
|
||||||
{isFabOpen && (
|
{isFabOpen && (
|
||||||
<div className="flex flex-col gap-2 bg-white p-3 rounded-sm shadow-xl border border-border-subtle animate-in fade-in slide-in-from-bottom-2">
|
<div className="flex flex-col gap-2 bg-white p-3 rounded-sm shadow-xl border border-border-subtle animate-in fade-in slide-in-from-bottom-2">
|
||||||
@ -145,6 +145,8 @@ export function OrdersPage() {
|
|||||||
Place Order
|
Place Order
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
} else if (stateName.includes('no order') || stateName.includes('non-productive') || stateName.includes('non productive')) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Button size="sm" onClick={(e) => {
|
<Button size="sm" onClick={(e) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user