-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathTicketShow.tsx
48 lines (45 loc) · 1.34 KB
/
TicketShow.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import {
Show,
TextField,
ReferenceManyField,
DateField,
ReferenceField,
SimpleShowLayout,
useRecordContext,
} from "react-admin";
import { Box } from "@mui/material";
import { MessageList } from "./MessageList";
import { StatusField } from "./StatusField";
import { useAddReaderToTicket } from "./useAddReaderToTicket";
import { ActivityDetail } from "./ActivityDetail";
export const TicketShow = () => {
useAddReaderToTicket();
return (
<Show aside={<ShowAside />}>
<SimpleShowLayout>
<TextField source="subject" label="" variant="h5" sx={{ ml: "72px" }} />
<ReferenceManyField
label={false}
reference="messages"
target="ticket_id"
sort={{ field: "timestamp", order: "ASC" }}
>
<MessageList />
</ReferenceManyField>
</SimpleShowLayout>
</Show>
);
};
const ShowAside = () => {
const record = useRecordContext();
if (!record) return <Box minWidth={200} flexShrink={0} />;
return (
<SimpleShowLayout sx={{ minWidth: 200, flexShrink: 0 }}>
<StatusField label="Status" />
<DateField source="updated_at" showTime />
<ReferenceField source="customer_id" reference="customers" link="show" />
<ReferenceField source="product_id" reference="products" link="show" />
<ActivityDetail />
</SimpleShowLayout>
);
};