Skip to content

Commit 2971b5a

Browse files
authored
chore(admin-ui): migrate components to apsara v1 (#1039)
* chore: migrate super admins table to v1 * chore: update datatable of preferences page to v1 * chore: migrate webhooks table to v1 * chore: migrate roles table to v1 * chore: remove unused old user list page * chore: migrate plans table to v1 * chore: migrate products table to v1 * chore: update css variables * chore: remove groups pages * chore: remove unused components * chore: update import to v1
1 parent 0e2eaf8 commit 2971b5a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+468
-1193
lines changed

ui/src/components/DialogTable.tsx

Lines changed: 0 additions & 31 deletions
This file was deleted.

ui/src/components/TableLoader/index.tsx

Lines changed: 0 additions & 28 deletions
This file was deleted.

ui/src/components/sheet/header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ export function SheetHeader({ title, onClick }: SheetHeaderProps) {
2424
const styles = {
2525
header: {
2626
padding: "18px 32px",
27-
borderBottom: "1px solid var(--border-base)",
27+
borderBottom: "1px solid var(--rs-color-border-base-primary)",
2828
},
2929
};
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import { Link } from "react-router-dom";
2-
import { ApsaraColumnDef } from "@raystack/apsara";
3-
import { V1Beta1Plan } from "@raystack/frontier";
2+
import { type DataTableColumnDef } from "@raystack/apsara/v1";
3+
import type { V1Beta1Plan } from "@raystack/frontier";
44

5-
export const getColumns: () => ApsaraColumnDef<V1Beta1Plan>[] = () => {
5+
export const getColumns: () => DataTableColumnDef<
6+
V1Beta1Plan,
7+
unknown
8+
>[] = () => {
69
return [
710
{
811
header: "ID",
912
accessorKey: "id",
1013
filterVariant: "text",
1114
cell: ({ row, getValue }) => (
12-
<Link to={`/plans/${row.getValue("id")}`}>{getValue()}</Link>
15+
<Link to={`/plans/${row.getValue("id")}`}>{getValue() as string}</Link>
1316
),
1417
},
1518
{
@@ -23,22 +26,16 @@ export const getColumns: () => ApsaraColumnDef<V1Beta1Plan>[] = () => {
2326
accessorKey: "interval",
2427
filterVariant: "text",
2528
cell: (info) => info.getValue(),
26-
footer: (props) => props.column.id,
2729
},
2830
{
2931
header: "Created At",
3032
accessorKey: "created_at",
31-
meta: {
32-
headerFilter: false,
33-
},
3433
cell: (info) =>
3534
new Date(info.getValue() as Date).toLocaleString("en", {
3635
month: "long",
3736
day: "numeric",
3837
year: "numeric",
3938
}),
40-
filterVariant: "date",
41-
footer: (props) => props.column.id,
4239
},
4340
];
4441
};

ui/src/containers/billingplans.list/details.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
1-
import { Grid } from "@raystack/apsara";
2-
import { Flex, Text } from "@raystack/apsara/v1";
1+
import { Flex, Text, Grid } from "@raystack/apsara/v1";
32
import { usePlan } from ".";
43
export default function PlanDetails() {
54
const { plan } = usePlan();
65

76
return (
8-
<Flex
9-
direction="column"
10-
gap="large"
11-
style={{
12-
width: "320px",
13-
height: "calc(100vh - 60px)",
14-
borderLeft: "1px solid var(--border-base)",
15-
padding: "var(--pd-16)",
16-
}}
17-
>
7+
<Flex direction="column" gap="large">
188
<Text size={4}>{plan?.name}</Text>
199
<Flex direction="column" gap="large">
2010
<Grid columns={2} gap="small">
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { DataTable, useTable } from "@raystack/apsara";
1+
import { DataTable } from "@raystack/apsara/v1";
22
import PageHeader from "~/components/page-header";
3+
import styles from "./plans.module.css";
34

45
export const PlanHeader = ({ header }: any) => {
5-
const { filteredColumns } = useTable();
6-
const isFiltered = filteredColumns.length > 0;
7-
86
return (
9-
<PageHeader title={header.title} breadcrumb={header?.breadcrumb || []}>
10-
{isFiltered ? <DataTable.ClearFilter /> : <DataTable.FilterOptions />}
11-
<DataTable.ViewOptions />
12-
<DataTable.GloabalSearch placeholder="Search plans..." />
7+
<PageHeader
8+
title={header.title}
9+
breadcrumb={header?.breadcrumb || []}
10+
className={styles.header}
11+
>
12+
<DataTable.Search size="small" placeholder="Search plans..." />
1313
</PageHeader>
1414
);
1515
};

ui/src/containers/billingplans.list/index.tsx

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
import { DataTable } from "@raystack/apsara";
2-
import { EmptyState, Flex } from "@raystack/apsara/v1";
1+
import { EmptyState, Flex, DataTable, Sheet } from "@raystack/apsara/v1";
32
import { useEffect, useState } from "react";
4-
import { Outlet, useOutletContext, useParams } from "react-router-dom";
3+
import {
4+
Outlet,
5+
useNavigate,
6+
useOutletContext,
7+
useParams,
8+
} from "react-router-dom";
59

6-
import { V1Beta1Plan } from "@raystack/frontier";
10+
import type { V1Beta1Plan } from "@raystack/frontier";
711
import { reduceByKey } from "~/utils/helper";
812
import { getColumns } from "./columns";
913
import { PlanHeader } from "./header";
1014
import { ExclamationTriangleIcon } from "@radix-ui/react-icons";
1115
import { api } from "~/api";
16+
import styles from "./plans.module.css";
17+
import PageTitle from "~/components/page-title";
18+
import { SheetHeader } from "~/components/sheet/header";
1219

1320
const pageHeader = {
1421
title: "Plans",
@@ -38,45 +45,45 @@ export default function PlanList() {
3845

3946
let { planId } = useParams();
4047

41-
const userMapByName = reduceByKey(plans ?? [], "id");
48+
const planMapByName = reduceByKey(plans ?? [], "id");
4249

43-
const tableStyle = plans?.length
44-
? { width: "100%" }
45-
: { width: "100%", height: "100%" };
50+
const columns = getColumns();
4651

47-
const planList = isPlansLoading
48-
? [...new Array(5)].map((_, i) => ({
49-
name: i.toString(),
50-
title: "",
51-
}))
52-
: plans;
52+
const navigate = useNavigate();
5353

54-
const columns = getColumns();
54+
function onClose() {
55+
navigate("/plans");
56+
}
5557

5658
return (
57-
<Flex direction="row" style={{ height: "100%", width: "100%" }}>
58-
<DataTable
59-
data={planList ?? []}
60-
// @ts-ignore
61-
columns={columns}
62-
emptyState={noDataChildren}
63-
parentStyle={{ height: "calc(100vh - 60px)" }}
64-
style={tableStyle}
65-
isLoading={isPlansLoading}
66-
>
67-
<DataTable.Toolbar>
68-
<PlanHeader header={pageHeader} />
69-
<DataTable.FilterChips style={{ padding: "8px 24px" }} />
70-
</DataTable.Toolbar>
71-
<DataTable.DetailContainer>
72-
<Outlet
73-
context={{
74-
user: planId ? userMapByName[planId] : null,
75-
}}
76-
/>
77-
</DataTable.DetailContainer>
78-
</DataTable>
79-
</Flex>
59+
<DataTable
60+
data={plans}
61+
columns={columns}
62+
isLoading={isPlansLoading}
63+
mode="client"
64+
defaultSort={{ name: "title", order: "asc" }}
65+
>
66+
<Flex direction="column">
67+
<PageTitle title="Plans" />
68+
<PlanHeader header={pageHeader} />
69+
<DataTable.Content
70+
emptyState={noDataChildren}
71+
classNames={{ root: styles.tableRoot, table: styles.table }}
72+
/>
73+
</Flex>
74+
<Sheet open={planId !== undefined}>
75+
<Sheet.Content className={styles.sheetContent}>
76+
<SheetHeader title="Plan Details" onClick={onClose} />
77+
<Flex className={styles.sheetContentBody}>
78+
<Outlet
79+
context={{
80+
plan: planId ? planMapByName[planId] : null,
81+
}}
82+
/>
83+
</Flex>
84+
</Sheet.Content>
85+
</Sheet>
86+
</DataTable>
8087
);
8188
}
8289

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.tableRoot {
2+
width: 100%;
3+
}
4+
.tableWrapper {
5+
width: 100%;
6+
}
7+
8+
.table {
9+
table-layout: fixed;
10+
}
11+
12+
.header {
13+
background-color: var(--rs-color-background-base-primary);
14+
border-bottom: 1px solid var(--rs-color-border-base-primary);
15+
}
16+
17+
.sheetContent {
18+
width: 400px;
19+
padding: 0;
20+
}
21+
22+
.sheetContentBody {
23+
padding: var(--rs-space-5);
24+
}

0 commit comments

Comments
 (0)