Skip to content

Commit 5ae7e44

Browse files
committed
groupBy domain by default in usage
1 parent a6ea114 commit 5ae7e44

2 files changed

Lines changed: 24 additions & 24 deletions

File tree

apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/usage-chart.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,6 @@ export function UsageChart() {
104104

105105
const filters = useMemo(
106106
() => [
107-
{
108-
key: "folderId",
109-
icon: Folder,
110-
label: "Folder",
111-
options:
112-
folders?.map((folder) => ({
113-
value: folder.id,
114-
icon: (
115-
<FolderIcon
116-
folder={folder}
117-
shape="square"
118-
iconClassName="size-3"
119-
/>
120-
),
121-
label: folder.name,
122-
})) ?? [],
123-
},
124107
{
125108
key: "domain",
126109
icon: Globe2,
@@ -140,17 +123,34 @@ export function UsageChart() {
140123
),
141124
})) ?? [],
142125
},
126+
{
127+
key: "folderId",
128+
icon: Folder,
129+
label: "Folder",
130+
options:
131+
folders?.map((folder) => ({
132+
value: folder.id,
133+
icon: (
134+
<FolderIcon
135+
folder={folder}
136+
shape="square"
137+
iconClassName="size-3"
138+
/>
139+
),
140+
label: folder.name,
141+
})) ?? [],
142+
},
143143
],
144-
[activeResource, folders, domains],
144+
[activeResource, domains, folders],
145145
);
146146

147147
// Active filters
148148
const activeFilters = useMemo(() => {
149149
const filters: { key: string; value: string }[] = [];
150-
if (folderId) filters.push({ key: "folderId", value: folderId });
151150
if (domain) filters.push({ key: "domain", value: domain });
151+
if (folderId) filters.push({ key: "folderId", value: folderId });
152152
return filters;
153-
}, [folderId, domain]);
153+
}, [domain, folderId]);
154154

155155
const chartData = useMemo(
156156
() =>
@@ -341,8 +341,8 @@ export function UsageChart() {
341341
</div>
342342
<ToggleGroup
343343
options={[
344-
{ value: "folderId", label: "Folder" },
345344
{ value: "domain", label: "Domain" },
345+
{ value: "folderId", label: "Folder" },
346346
]}
347347
selected={groupBy}
348348
selectAction={(id) => queryParams({ set: { groupBy: id } })}

apps/web/lib/swr/use-usage-timeseries.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ export function useUsageTimeseries({
4747
};
4848
}, [searchParams, firstDay, lastDay]);
4949

50-
const groupBy: "folderId" | "domain" =
51-
(["folderId", "domain"] as const).find(
50+
const groupBy: "domain" | "folderId" =
51+
(["domain", "folderId"] as const).find(
5252
(gb) => gb === searchParams.get("groupBy"),
53-
) ?? "folderId";
53+
) ?? "domain";
5454

5555
const {
5656
data: usage,

0 commit comments

Comments
 (0)