@tenancy.nz/feature-ui 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/cjs/components/AgentDetailsCard.cjs +55 -0
  2. package/dist/cjs/components/AnalyticsBox.cjs +58 -0
  3. package/dist/cjs/components/AnalyticsSection.cjs +209 -0
  4. package/dist/cjs/components/BookingChart.cjs +124 -0
  5. package/dist/cjs/components/BookingChart.styled.cjs +100 -0
  6. package/dist/cjs/components/BookingTable.cjs +44 -0
  7. package/dist/cjs/components/BookingTableRow.cjs +63 -0
  8. package/dist/cjs/components/BookingTableRow.styled.cjs +42 -0
  9. package/dist/cjs/components/BookingTableRowHeader.cjs +27 -0
  10. package/dist/cjs/components/BookingTableRowSkeleton.cjs +30 -0
  11. package/dist/cjs/components/CheckedIcon.cjs +17 -0
  12. package/dist/cjs/components/EnquiriesDoughnutChart.cjs +167 -0
  13. package/dist/cjs/components/GridList.cjs +87 -0
  14. package/dist/cjs/components/Hidden.cjs +15 -0
  15. package/dist/cjs/components/IconLabel.cjs +36 -0
  16. package/dist/cjs/components/NotesCard.cjs +39 -0
  17. package/dist/cjs/components/PropertyCard.cjs +137 -0
  18. package/dist/cjs/components/PropertyCard.styled.cjs +76 -0
  19. package/dist/cjs/index.cjs +36 -0
  20. package/dist/esm/components/AgentDetailsCard.js +51 -0
  21. package/dist/esm/components/AnalyticsBox.js +54 -0
  22. package/dist/esm/components/AnalyticsSection.js +205 -0
  23. package/dist/esm/components/BookingChart.js +120 -0
  24. package/dist/esm/components/BookingChart.styled.js +94 -0
  25. package/dist/esm/components/BookingTable.js +40 -0
  26. package/dist/esm/components/BookingTableRow.js +59 -0
  27. package/dist/esm/components/BookingTableRow.styled.js +40 -0
  28. package/dist/esm/components/BookingTableRowHeader.js +23 -0
  29. package/dist/esm/components/BookingTableRowSkeleton.js +26 -0
  30. package/dist/esm/components/CheckedIcon.js +13 -0
  31. package/dist/esm/components/EnquiriesDoughnutChart.js +163 -0
  32. package/dist/esm/components/GridList.js +83 -0
  33. package/dist/esm/components/Hidden.js +11 -0
  34. package/dist/esm/components/IconLabel.js +32 -0
  35. package/dist/esm/components/NotesCard.js +35 -0
  36. package/dist/esm/components/PropertyCard.js +133 -0
  37. package/dist/esm/components/PropertyCard.styled.js +72 -0
  38. package/dist/esm/index.js +16 -0
  39. package/package.json +5 -5
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ 'use strict';
3
+
4
+ var AgentDetailsCard = require('./components/AgentDetailsCard.cjs');
5
+ var AnalyticsBox = require('./components/AnalyticsBox.cjs');
6
+ var AnalyticsSection = require('./components/AnalyticsSection.cjs');
7
+ var BookingChart = require('./components/BookingChart.cjs');
8
+ var BookingTable = require('./components/BookingTable.cjs');
9
+ var BookingTableRow = require('./components/BookingTableRow.cjs');
10
+ var BookingTableRowHeader = require('./components/BookingTableRowHeader.cjs');
11
+ var BookingTableRowSkeleton = require('./components/BookingTableRowSkeleton.cjs');
12
+ var CheckedIcon = require('./components/CheckedIcon.cjs');
13
+ var EnquiriesDoughnutChart = require('./components/EnquiriesDoughnutChart.cjs');
14
+ var GridList = require('./components/GridList.cjs');
15
+ var Hidden = require('./components/Hidden.cjs');
16
+ var IconLabel = require('./components/IconLabel.cjs');
17
+ var NotesCard = require('./components/NotesCard.cjs');
18
+ var PropertyCard = require('./components/PropertyCard.cjs');
19
+
20
+
21
+
22
+ exports.AgentDetailsCard = AgentDetailsCard.default;
23
+ exports.AnalyticsBox = AnalyticsBox.default;
24
+ exports.AnalyticsSection = AnalyticsSection.default;
25
+ exports.BookingChart = BookingChart.default;
26
+ exports.BookingTable = BookingTable.default;
27
+ exports.BookingTableRow = BookingTableRow.default;
28
+ exports.BookingTableRowHeader = BookingTableRowHeader.default;
29
+ exports.BookingTableRowSkeleton = BookingTableRowSkeleton.default;
30
+ exports.CheckedIcon = CheckedIcon.default;
31
+ exports.EnquiriesDoughnutChart = EnquiriesDoughnutChart.default;
32
+ exports.GridList = GridList.default;
33
+ exports.Hidden = Hidden.default;
34
+ exports.IconLabel = IconLabel.default;
35
+ exports.NotesCard = NotesCard.default;
36
+ exports.PropertyCard = PropertyCard.default;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import 'react';
4
+ import { Box, Skeleton, Heading, Text } from '@tenancy.nz/ui';
5
+ import { UserIcon, PhoneIcon, EnvelopeIcon } from '@tenancy.nz/icons';
6
+ import IconLabel from './IconLabel.js';
7
+
8
+ function AgentDetailsCard({
9
+ email = void 0,
10
+ loading = false,
11
+ logo = void 0,
12
+ name = void 0,
13
+ phone = void 0
14
+ }) {
15
+ return /* @__PURE__ */ jsxs(Box, { display: "flex", gap: "8px", align: "flex-start", children: [
16
+ /* @__PURE__ */ jsxs(Box, { display: "flex", gap: "8px", direction: "column", width: "100%", children: [
17
+ loading ? /* @__PURE__ */ jsx(Skeleton, { width: "75%", height: "22px", variant: "text" }) : /* @__PURE__ */ jsx(IconLabel, { color: "tertiary.main", startIcon: /* @__PURE__ */ jsx(UserIcon, { size: "24px" }), children: /* @__PURE__ */ jsx(Heading, { as: "h5", weight: "700", children: name }) }),
18
+ loading ? /* @__PURE__ */ jsx(Skeleton, { width: "55%", height: "18px", variant: "text" }) : /* @__PURE__ */ jsx(
19
+ IconLabel,
20
+ {
21
+ color: "tertiary.main",
22
+ startIcon: /* @__PURE__ */ jsx(PhoneIcon, { size: "24px" }),
23
+ children: /* @__PURE__ */ jsx(Text, { as: "span", color: "text.primary", variant: "body1", weight: "400", children: phone })
24
+ }
25
+ ),
26
+ loading ? /* @__PURE__ */ jsx(Skeleton, { width: "55%", height: "18px", variant: "text" }) : /* @__PURE__ */ jsx(
27
+ IconLabel,
28
+ {
29
+ color: "tertiary.main",
30
+ startIcon: /* @__PURE__ */ jsx(EnvelopeIcon, { size: "24px" }),
31
+ children: /* @__PURE__ */ jsx(Text, { as: "span", color: "text.primary", variant: "body1", weight: "400", children: email })
32
+ }
33
+ )
34
+ ] }),
35
+ loading && /* @__PURE__ */ jsx(Box, { flex: "0 0 40px", children: /* @__PURE__ */ jsx(Skeleton, { width: "40px", height: "40px", variant: "rectangular" }) }),
36
+ logo && !loading && /* @__PURE__ */ jsx(
37
+ Box,
38
+ {
39
+ width: "40px",
40
+ height: "40px",
41
+ sx: {
42
+ flex: "0 0 40px",
43
+ "> img": { maxWidth: "100%", maxHeight: "100%" }
44
+ },
45
+ children: /* @__PURE__ */ jsx("img", { src: logo, alt: "Agency Logo" })
46
+ }
47
+ )
48
+ ] });
49
+ }
50
+
51
+ export { AgentDetailsCard as default };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import 'react';
4
+ import { Paper, Box, Heading, Text } from '@tenancy.nz/ui';
5
+
6
+ function AnalyticsBox({
7
+ width,
8
+ minWidth,
9
+ maxWidth,
10
+ height,
11
+ border,
12
+ label,
13
+ amount,
14
+ text,
15
+ ...rest
16
+ }) {
17
+ return /* @__PURE__ */ jsx(
18
+ Paper,
19
+ {
20
+ ...rest,
21
+ sx: {
22
+ maxWidth,
23
+ width,
24
+ minWidth,
25
+ border,
26
+ height: height || "100%",
27
+ display: "flex",
28
+ alignItems: "center",
29
+ justifyContent: "center",
30
+ padding: "16px"
31
+ },
32
+ children: /* @__PURE__ */ jsxs(Box, { children: [
33
+ /* @__PURE__ */ jsx(Heading, { align: "center", weight: "700", as: "h3", gutterBottom: true, children: amount }),
34
+ /* @__PURE__ */ jsx(Text, { align: "center", weight: "400", variant: "body2", children: label }),
35
+ text && /* @__PURE__ */ jsx(
36
+ Text,
37
+ {
38
+ align: "center",
39
+ weight: "400",
40
+ sx: {
41
+ fontSize: { xs: 8, sm: 10, xl: 14 },
42
+ lineHeight: "15.6px",
43
+ maxWidth: "366px",
44
+ mt: "8px"
45
+ },
46
+ children: text
47
+ }
48
+ )
49
+ ] })
50
+ }
51
+ );
52
+ }
53
+
54
+ export { AnalyticsBox as default };
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import 'react';
4
+ import { useMediaQuery, Box, Paper, Text } from '@tenancy.nz/ui';
5
+ import AnalyticsBox from './AnalyticsBox.js';
6
+ import EnquiriesDoughnutChart from './EnquiriesDoughnutChart.js';
7
+
8
+ function AnalyticsSection({
9
+ viewingsCount,
10
+ bookingsCount,
11
+ attendeesCount,
12
+ cancellationsCount,
13
+ applicationsCount,
14
+ averageRent,
15
+ textUsage,
16
+ tradeMeEnquiriesCount,
17
+ bookMeEnquiriesCount,
18
+ manualEnquiryCount,
19
+ agreementsCount,
20
+ agreementsFinalisedCount,
21
+ filterDaysCount
22
+ }) {
23
+ const isXlUp = useMediaQuery((theme) => theme.breakpoints.up("xl"));
24
+ return /* @__PURE__ */ jsxs(
25
+ Box,
26
+ {
27
+ display: "flex",
28
+ align: "stretch",
29
+ direction: { xs: "column-reverse", mlg: "row" },
30
+ gap: "27px",
31
+ children: [
32
+ /* @__PURE__ */ jsx(Box, { width: "100%", maxWidth: { xs: "100%", mob: "340px", xl: "463px" }, children: /* @__PURE__ */ jsx(Paper, { style: { width: "100%", position: "relative", height: "100%" }, children: /* @__PURE__ */ jsx(Box, { mt: "20px", height: "100%", children: /* @__PURE__ */ jsx(
33
+ EnquiriesDoughnutChart,
34
+ {
35
+ tradeMeEnquiriesCount,
36
+ bookMeEnquiriesCount,
37
+ manualEnquiryCount
38
+ }
39
+ ) }) }) }),
40
+ /* @__PURE__ */ jsx(Box, { width: "100%", children: /* @__PURE__ */ jsxs(Box, { display: "flex", direction: "row", width: "100%", gap: 6, children: [
41
+ /* @__PURE__ */ jsxs(Box, { flex: 3, children: [
42
+ /* @__PURE__ */ jsxs(Box, { display: "flex", gap: 6, children: [
43
+ /* @__PURE__ */ jsx(
44
+ AnalyticsBox,
45
+ {
46
+ label: "Viewings",
47
+ amount: viewingsCount,
48
+ width: "100%",
49
+ height: isXlUp ? "157px" : "125px"
50
+ }
51
+ ),
52
+ /* @__PURE__ */ jsx(
53
+ AnalyticsBox,
54
+ {
55
+ label: "Bookings",
56
+ amount: bookingsCount,
57
+ width: "100%",
58
+ height: isXlUp ? "157px" : "125px"
59
+ }
60
+ ),
61
+ /* @__PURE__ */ jsx(
62
+ AnalyticsBox,
63
+ {
64
+ label: "Attendees",
65
+ amount: attendeesCount,
66
+ width: "100%",
67
+ border: "3px solid #6FD3C0",
68
+ height: isXlUp ? "157px" : "125px"
69
+ }
70
+ )
71
+ ] }),
72
+ /* @__PURE__ */ jsxs(Box, { display: "flex", width: "100%", gap: 6, mt: 6, children: [
73
+ /* @__PURE__ */ jsx(
74
+ AnalyticsBox,
75
+ {
76
+ label: "Converted Properties",
77
+ amount: agreementsCount,
78
+ width: "100%",
79
+ height: isXlUp ? "157px" : "125px",
80
+ text: /* @__PURE__ */ jsxs(Box, { as: "span", maxWidth: "276px", children: [
81
+ "Properties that have had a viewing in the last",
82
+ " ",
83
+ /* @__PURE__ */ jsx(
84
+ Text,
85
+ {
86
+ as: "span",
87
+ display: "inline",
88
+ weight: "700",
89
+ fontSize: "inherit",
90
+ children: filterDaysCount
91
+ }
92
+ ),
93
+ " ",
94
+ "days where an agreement has been",
95
+ " ",
96
+ /* @__PURE__ */ jsx(
97
+ Text,
98
+ {
99
+ as: "span",
100
+ display: "inline",
101
+ weight: "700",
102
+ fontSize: "inherit",
103
+ children: "created"
104
+ }
105
+ )
106
+ ] })
107
+ }
108
+ ),
109
+ /* @__PURE__ */ jsx(
110
+ AnalyticsBox,
111
+ {
112
+ label: "Converted Properties",
113
+ amount: agreementsFinalisedCount,
114
+ width: "100%",
115
+ height: isXlUp ? "157px" : "125px",
116
+ text: /* @__PURE__ */ jsxs(Box, { as: "span", maxWidth: "276px", children: [
117
+ "Properties that have had a viewing in the last",
118
+ " ",
119
+ /* @__PURE__ */ jsx(
120
+ Text,
121
+ {
122
+ as: "span",
123
+ display: "inline",
124
+ weight: "700",
125
+ fontSize: "inherit",
126
+ children: filterDaysCount
127
+ }
128
+ ),
129
+ " ",
130
+ "days where an agreement has been",
131
+ " ",
132
+ /* @__PURE__ */ jsx(
133
+ Text,
134
+ {
135
+ as: "span",
136
+ display: "inline",
137
+ weight: "700",
138
+ fontSize: "inherit",
139
+ children: "finalised"
140
+ }
141
+ )
142
+ ] })
143
+ }
144
+ )
145
+ ] })
146
+ ] }),
147
+ /* @__PURE__ */ jsxs(Box, { flex: 2, children: [
148
+ /* @__PURE__ */ jsxs(Box, { display: "flex", gap: 6, children: [
149
+ /* @__PURE__ */ jsx(
150
+ AnalyticsBox,
151
+ {
152
+ label: "Cancellations",
153
+ amount: cancellationsCount,
154
+ width: "100%",
155
+ border: "3px solid #ED0D8D",
156
+ height: isXlUp ? "157px" : "125px"
157
+ }
158
+ ),
159
+ /* @__PURE__ */ jsx(
160
+ AnalyticsBox,
161
+ {
162
+ label: "Applications",
163
+ amount: applicationsCount,
164
+ width: "100%",
165
+ border: "3px solid #F5C440",
166
+ height: isXlUp ? "157px" : "125px"
167
+ }
168
+ )
169
+ ] }),
170
+ /* @__PURE__ */ jsxs(Box, { display: "flex", gap: 6, mt: 6, children: [
171
+ /* @__PURE__ */ jsx(
172
+ AnalyticsBox,
173
+ {
174
+ label: /* @__PURE__ */ jsxs("span", { children: [
175
+ "Average",
176
+ /* @__PURE__ */ jsx("br", {}),
177
+ " Rent"
178
+ ] }),
179
+ amount: averageRent,
180
+ width: "100%",
181
+ height: isXlUp ? "157px" : "125px"
182
+ }
183
+ ),
184
+ /* @__PURE__ */ jsx(
185
+ AnalyticsBox,
186
+ {
187
+ label: /* @__PURE__ */ jsxs("span", { children: [
188
+ "Text Usage",
189
+ /* @__PURE__ */ jsx("br", {}),
190
+ " Total"
191
+ ] }),
192
+ amount: textUsage,
193
+ width: "100%",
194
+ height: isXlUp ? "157px" : "125px"
195
+ }
196
+ )
197
+ ] })
198
+ ] })
199
+ ] }) })
200
+ ]
201
+ }
202
+ );
203
+ }
204
+
205
+ export { AnalyticsSection as default };
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useMemo } from 'react';
4
+ import { Box } from '@tenancy.nz/ui';
5
+ import { Chart } from 'primereact/chart';
6
+ import { StyledBookingChartStack, StyledBookingChartLegend, StyledBookingChartButton } from './BookingChart.styled.js';
7
+
8
+ const defaultOptions = {
9
+ scaleFontColor: "black",
10
+ legend: {
11
+ display: false
12
+ },
13
+ plugins: {
14
+ datalabels: {
15
+ align: "centre",
16
+ font: {
17
+ weight: "700",
18
+ size: 12,
19
+ family: "Montserrat, sans-serif"
20
+ },
21
+ display: (ctx) => ctx.dataset.data[ctx.dataIndex] > 0
22
+ }
23
+ },
24
+ scales: {
25
+ xAxes: [
26
+ {
27
+ gridLines: {
28
+ labelString: "Date",
29
+ display: false
30
+ },
31
+ ticks: {
32
+ fontSize: 13,
33
+ family: "Montserrat, sans-serif",
34
+ fontWeight: "bold"
35
+ },
36
+ stacked: true
37
+ }
38
+ ],
39
+ yAxes: [
40
+ {
41
+ scaleLabel: {
42
+ display: true,
43
+ labelString: "Total bookings",
44
+ fontFamily: "Montserrat, sans-serif",
45
+ fontSize: 13,
46
+ fontStyle: "600"
47
+ },
48
+ ticks: {
49
+ min: 0,
50
+ stepSize: 5,
51
+ fontSize: 13,
52
+ fontWeight: 500
53
+ },
54
+ gridLines: {
55
+ display: false
56
+ },
57
+ stacked: true
58
+ }
59
+ ]
60
+ }
61
+ };
62
+ function BookingChart({
63
+ data,
64
+ labels,
65
+ mode = "day",
66
+ options = {},
67
+ onModeChange = void 0
68
+ }) {
69
+ const legends = useMemo(
70
+ () => data.map(({ label, backgroundColor }) => [label, backgroundColor]).filter(
71
+ ([label], i, items) => items.findIndex(([l]) => l === label) === i
72
+ ),
73
+ [data]
74
+ );
75
+ return /* @__PURE__ */ jsxs(Box, { display: "flex", direction: "column", gap: "16px", width: "100%", children: [
76
+ legends.length > 0 && /* @__PURE__ */ jsx(StyledBookingChartStack, { children: legends.map(([label, backgroundColor]) => /* @__PURE__ */ jsx(StyledBookingChartLegend, { color: backgroundColor, children: label }, label)) }),
77
+ /* @__PURE__ */ jsx(Box, { width: "100%", overflow: "hidden", children: /* @__PURE__ */ jsx(
78
+ Chart,
79
+ {
80
+ type: "bar",
81
+ data: {
82
+ labels,
83
+ datasets: data
84
+ },
85
+ options: { ...defaultOptions, ...options }
86
+ }
87
+ ) }),
88
+ onModeChange && /* @__PURE__ */ jsxs(StyledBookingChartStack, { children: [
89
+ /* @__PURE__ */ jsx(
90
+ StyledBookingChartButton,
91
+ {
92
+ onClick: onModeChange,
93
+ active: mode === "day",
94
+ value: "day",
95
+ children: "Day"
96
+ }
97
+ ),
98
+ /* @__PURE__ */ jsx(
99
+ StyledBookingChartButton,
100
+ {
101
+ onClick: onModeChange,
102
+ active: mode === "week",
103
+ value: "week",
104
+ children: "Week"
105
+ }
106
+ ),
107
+ /* @__PURE__ */ jsx(
108
+ StyledBookingChartButton,
109
+ {
110
+ onClick: onModeChange,
111
+ active: mode === "month",
112
+ value: "month",
113
+ children: "Month"
114
+ }
115
+ )
116
+ ] })
117
+ ] });
118
+ }
119
+
120
+ export { BookingChart as default };
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ import { css } from '@emotion/react';
3
+ import styled from '@emotion/styled';
4
+
5
+ const StyledBookingChartStack = styled.div`
6
+ display: flex;
7
+ flex-wrap: wrap;
8
+ gap: 8px;
9
+ padding: 0;
10
+ margin: 0;
11
+ list-style: none;
12
+ font-size: 12px;
13
+ justify-content: center;
14
+ color: #000;
15
+ width: 100%;
16
+ `;
17
+ const StyledBookingChartLegend = styled("span", {
18
+ shouldForwardProp: (prop) => !["color"].includes(prop)
19
+ })`
20
+ font-weight: 500;
21
+ display: flex;
22
+ align-items: center;
23
+ gap: 6px;
24
+
25
+ &::before {
26
+ content: '';
27
+ display: inline-flex;
28
+ width: 32px;
29
+ height: 18px;
30
+ background-color: ${(props) => props.color};
31
+ border-radius: 4px;
32
+ }
33
+ `;
34
+ const StyledBookingChartButton = styled("button", {
35
+ shouldForwardProp: (prop) => !["color"].includes(prop)
36
+ })`
37
+ font-weight: 500;
38
+ display: flex;
39
+ align-items: center;
40
+ padding: 6px 10px;
41
+ font-size: 14px;
42
+ border-radius: 4px;
43
+ font-family: inherit;
44
+ border: 1px solid ${({ theme }) => theme.palette.primary.main};
45
+ box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.1);
46
+ background-color: ${({ active, theme }) => active ? "#CEF3ED" : theme.palette.background.paper};
47
+ cursor: pointer;
48
+
49
+ &:hover {
50
+ background-color: ${({ active, theme }) => !active ? theme.palette.grey[100] : null};
51
+ }
52
+ `;
53
+ const StyledPropertyDetailsBox = styled.div`
54
+ display: flex;
55
+ width: 100%;
56
+ align-items: flex-start;
57
+ padding: 16px 24px 16px 20px;
58
+ flex-direction: column;
59
+
60
+ ${({ theme }) => css`
61
+ ${theme.breakpoints.up("sm")} {
62
+ flex-direction: row;
63
+ align-items: center;
64
+ }
65
+ `}
66
+
67
+ @media print {
68
+ flex-direction: row;
69
+ align-items: center;
70
+ }
71
+ `;
72
+ const StyledPropertyAmenitiesBox = styled.div`
73
+ padding-right: 25px;
74
+ display: flex;
75
+ flex-direction: column;
76
+ margin-top: 5px;
77
+
78
+ gap: 18px;
79
+ min-width: 170px;
80
+ height: 100%;
81
+ justify-content: space-between;
82
+
83
+ ${({ theme }) => `
84
+ @media (min-width: ${theme.breakpoints.values.md}px) {
85
+ align-items: flex-end;
86
+ }
87
+ `}
88
+
89
+ @media print {
90
+ align-items: flex-end;
91
+ }
92
+ `;
93
+
94
+ export { StyledBookingChartButton, StyledBookingChartLegend, StyledBookingChartStack, StyledPropertyAmenitiesBox, StyledPropertyDetailsBox };
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
+ import 'react';
4
+ import { uid } from 'react-uid';
5
+ import { Box, Paper, Heading } from '@tenancy.nz/ui';
6
+ import BookingTableRowHeader from './BookingTableRowHeader.js';
7
+ import BookingTableRow from './BookingTableRow.js';
8
+ import BookingTableRowSkeleton from './BookingTableRowSkeleton.js';
9
+
10
+ function BookingTable({ data, loading = false }) {
11
+ return /* @__PURE__ */ jsx(Box, { sx: { overflowX: "auto", scrollBehavior: "smooth" }, children: /* @__PURE__ */ jsx(Box, { sx: { minWidth: "1024px" }, children: /* @__PURE__ */ jsxs(Paper, { outlined: true, overflow: false, children: [
12
+ /* @__PURE__ */ jsx(Box, { bgcolor: "grey.50", children: /* @__PURE__ */ jsx(BookingTableRowHeader, {}) }),
13
+ /* @__PURE__ */ jsxs(Box, { children: [
14
+ !loading && data.map((booking, index) => /* @__PURE__ */ jsx(
15
+ BookingTableRow,
16
+ {
17
+ firstName: booking.firstName,
18
+ lastName: booking.lastName,
19
+ notes: booking.notes,
20
+ tenantNotes: booking.tenantNotes,
21
+ status: booking.status,
22
+ attended: booking.attended,
23
+ suitable: booking.suitable,
24
+ applicationSent: booking.applicationSent,
25
+ applicationReceived: booking.applicationReceived
26
+ },
27
+ uid(booking, index)
28
+ )),
29
+ loading && /* @__PURE__ */ jsxs(Fragment, { children: [
30
+ /* @__PURE__ */ jsx(BookingTableRowSkeleton, {}),
31
+ /* @__PURE__ */ jsx(BookingTableRowSkeleton, {}),
32
+ /* @__PURE__ */ jsx(BookingTableRowSkeleton, {}),
33
+ /* @__PURE__ */ jsx(BookingTableRowSkeleton, {})
34
+ ] }),
35
+ !loading && data.length === 0 && /* @__PURE__ */ jsx(Heading, { as: "h4", align: "center", sx: { margin: "16px 0" }, children: "No bookings" })
36
+ ] })
37
+ ] }) }) });
38
+ }
39
+
40
+ export { BookingTable as default };
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import 'react';
4
+ import { Grid, Text, Tag } from '@tenancy.nz/ui';
5
+ import CheckedIcon from './CheckedIcon.js';
6
+ import { StyledBookingTableRowCell } from './BookingTableRow.styled.js';
7
+
8
+ const tagMap = (status) => {
9
+ if (status === "confirmed") {
10
+ return /* @__PURE__ */ jsx(Tag, { color: "success", label: "Confirmed" });
11
+ }
12
+ if (status === "cancelled") {
13
+ return /* @__PURE__ */ jsx(Tag, { color: "error", label: "Cancelled" });
14
+ }
15
+ return /* @__PURE__ */ jsx(Tag, { color: "info", label: "Registered" });
16
+ };
17
+ function BookingTableRow({
18
+ applicationReceived = false,
19
+ applicationSent = false,
20
+ attended = false,
21
+ firstName,
22
+ lastName,
23
+ notes = void 0,
24
+ status,
25
+ suitable = false,
26
+ tenantNotes = void 0
27
+ }) {
28
+ return /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 0, children: [
29
+ /* @__PURE__ */ jsxs(Grid, { item: true, container: true, xs: 6, children: [
30
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 3, md: 3, children: /* @__PURE__ */ jsxs(StyledBookingTableRowCell, { children: [
31
+ firstName,
32
+ " ",
33
+ lastName
34
+ ] }) }),
35
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 6, md: 7, children: /* @__PURE__ */ jsx(StyledBookingTableRowCell, { children: /* @__PURE__ */ jsxs(Text, { as: "div", variant: "body2", children: [
36
+ notes && /* @__PURE__ */ jsxs(Text, { variant: "inherit", paragraph: !!tenantNotes, children: [
37
+ /* @__PURE__ */ jsx("strong", { children: "Property Manager Note" }),
38
+ " ",
39
+ /* @__PURE__ */ jsx("br", {}),
40
+ notes
41
+ ] }),
42
+ tenantNotes && /* @__PURE__ */ jsxs(Text, { variant: "inherit", children: [
43
+ /* @__PURE__ */ jsx("strong", { children: "Tenant Feedback" }),
44
+ /* @__PURE__ */ jsx("br", {}),
45
+ tenantNotes
46
+ ] })
47
+ ] }) }) }),
48
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 3, md: 2, children: /* @__PURE__ */ jsx(StyledBookingTableRowCell, { children: /* @__PURE__ */ jsx("span", { children: tagMap(status) }) }) })
49
+ ] }),
50
+ /* @__PURE__ */ jsxs(Grid, { item: true, container: true, xs: 6, children: [
51
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 3, children: /* @__PURE__ */ jsx(StyledBookingTableRowCell, { align: "center", children: /* @__PURE__ */ jsx(CheckedIcon, { value: attended }) }) }),
52
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 3, children: /* @__PURE__ */ jsx(StyledBookingTableRowCell, { align: "center", children: /* @__PURE__ */ jsx(CheckedIcon, { value: suitable }) }) }),
53
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 3, children: /* @__PURE__ */ jsx(StyledBookingTableRowCell, { align: "center", children: /* @__PURE__ */ jsx(CheckedIcon, { value: applicationSent }) }) }),
54
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 3, children: /* @__PURE__ */ jsx(StyledBookingTableRowCell, { align: "center", children: /* @__PURE__ */ jsx(CheckedIcon, { value: applicationReceived }) }) })
55
+ ] })
56
+ ] });
57
+ }
58
+
59
+ export { BookingTableRow as default };