Skip to content

Commit

Permalink
[ui] Add hierarchy to sector filter (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
hhssb authored May 31, 2024
2 parents 9f09709 + e246929 commit f95adfb
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 36 deletions.
2 changes: 1 addition & 1 deletion app/src/app/api/search/export/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function GET(request: Request) {

searchParams.set(
"select",
"tax_ident, name, unit_type, primary_activity_category_id, physical_region_id, employees, physical_country_iso_2, sector_code, sector_name, legal_form_code, legal_form_name"
"tax_ident, name, unit_type, primary_activity_category_id, physical_region_id, employees, turnover, physical_country_iso_2, sector_code, sector_name, legal_form_code, legal_form_name"
);

const statisticalUnitsResponse = await getStatisticalUnits(searchParams);
Expand Down
4 changes: 2 additions & 2 deletions app/src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import { StatisticalVariableCountCard } from "@/app/dashboard/statistical-variab
import { Database, Gauge } from "lucide-react";

export const metadata: Metadata = {
title: "StatBus | Dashboard",
title: "Statbus | Dashboard",
};

export default async function Dashboard() {
return (
<main className="mx-auto flex max-w-5xl flex-col px-2 py-8 md:py-24 w-full space-y-8 lg:space-y-12">
<h1 className="text-center text-2xl">StatBus Status Dashboard</h1>
<h1 className="text-center text-2xl">Statbus Status Dashboard</h1>

<DashboardSection
title="Data Metrics"
Expand Down
6 changes: 3 additions & 3 deletions app/src/app/getting-started/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export default function GettingStartedLayout({
readonly progress: React.ReactNode;
}) {
return (
<main className="w-full mx-auto max-w-screen-xl px-2 py-8 md:py-24 grid xl:grid-cols-12 gap-8">
<aside className="p-6 col-span-12 xl:col-span-4 bg-ssb-light">
<main className="w-full mx-auto max-w-screen-xl px-2 py-8 md:py-24 grid lg:grid-cols-12 gap-8">
<aside className="p-6 col-span-12 lg:col-span-4 bg-ssb-light">
{progress}
</aside>
<div className="flex-1 col-span-12 xl:col-span-8">
<div className="flex-1 col-span-12 lg:col-span-8">
<div className="max-w-2xl mx-auto">{children}</div>
</div>
</main>
Expand Down
2 changes: 1 addition & 1 deletion app/src/app/getting-started/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default async function GettingStartedPage() {
<div className="space-y-6 text-center">
<h1 className="text-center text-2xl">Welcome</h1>
<p>
In this onboarding guide we will try to help you get going with StatBus.
In this onboarding guide we will try to help you get going with Statbus.
We will assist you in selecting an activity standard and you will get to
upload your first region data set.
</p>
Expand Down
8 changes: 4 additions & 4 deletions app/src/app/getting-started/summary/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ export default async function OnboardingCompletedPage() {
<h1 className="text-center text-2xl">Summary</h1>
<p className="leading-loose">
The following steps needs to be complete in order to have a fully
functional StatBus. If you have not completed some of the steps, you can
functional Statbus. If you have not completed some of the steps, you can
click the links to complete the steps.
</p>

<div className="space-y-6">
<SummaryBlock
success={!!settings?.[0]?.activity_category_standard}
successText={`You have configured StatBus to use the activity category standard ${settings?.[0]?.activity_category_standard?.name}.`}
successText={`You have configured Statbus to use the activity category standard ${settings?.[0]?.activity_category_standard?.name}.`}
failureText={
"You have not configured StatBus to use an activity category standard"
"You have not configured Statbus to use an activity category standard"
}
failureLink={"/getting-started/activity-standard"}
/>
Expand Down Expand Up @@ -71,7 +71,7 @@ export default async function OnboardingCompletedPage() {
numberOfLegalUnits ? (
<div className="text-center">
<Link className="underline" href="/">
Start using StatBus
Start using Statbus
</Link>
</div>
) : null}
Expand Down
2 changes: 1 addition & 1 deletion app/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import TimeContextProvider from "@/app/time-context-provider";
const inter = Inter({ subsets: ["latin"] });

export const metadata: Metadata = {
title: "StatBus",
title: "Statbus",
description: "Simple To Use, Simple To Understand, Simply useful!",
};

Expand Down
2 changes: 1 addition & 1 deletion app/src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function LoginPage() {
<div className="sm:mx-auto sm:w-full sm:max-w-sm">
<Image
src={logo}
alt="StatBus Logo"
alt="Statbus Logo"
width={32}
height={32}
className="mx-auto h-10 w-auto"
Expand Down
2 changes: 1 addition & 1 deletion app/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Metadata } from "next";
import Dashboard from "@/app/dashboard/page";

export const metadata: Metadata = {
title: "StatBus | Home",
title: "Statbus | Home",
};

export default async function Home() {
Expand Down
4 changes: 2 additions & 2 deletions app/src/app/reports/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DrillDown } from "@/app/reports/types/drill-down";
import { createServerLogger } from "@/lib/server-logger";

export const metadata: Metadata = {
title: "StatBus | Reports",
title: "Statbus | Reports",
};

export default async function ReportsPage() {
Expand All @@ -28,7 +28,7 @@ export default async function ReportsPage() {

return (
<main className="mx-auto flex w-full max-w-5xl flex-col px-2 py-8 md:py-24">
<h1 className="mb-3 text-center text-2xl">StatBus Data Drilldown</h1>
<h1 className="mb-3 text-center text-2xl">Statbus Data Drilldown</h1>
<p className="mb-12 text-center">
Gain data insights by drilling through the bar charts below
</p>
Expand Down
12 changes: 5 additions & 7 deletions app/src/app/search/filters/sector/sector-filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ interface IProps {

export default async function SectorFilter({ urlSearchParam }: IProps) {
const client = createClient();
const sectors = await client
.from("sector_used")
.select()
.not("code", "is", null);
const sectors = await client.from("sector_used").select();

return (
<SectorOptions
options={
sectors.data?.map(({ code, name }) => ({
label: `${code} ${name}`,
value: code,
sectors.data?.map(({ code, path, name }) => ({
label: code ? `${code} ${name}` : `${name}`,
value: path as string,
humanReadableValue: code ? `${code} ${name}` : `${name}`,
})) ?? []
}
selected={urlSearchParam ? urlSearchParam.split(",") : []}
Expand Down
18 changes: 10 additions & 8 deletions app/src/app/search/filters/sector/sector-options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ export default function SectorOptions({
values: { [SECTOR]: selected = [] },
},
} = useSearchContext();

const buildQuery = (values: (string | null)[]) => {
const path = values[0];
if (path) return `cd.${path}`;
if (path === null) return "is.null";
return null;
};
const toggle = useCallback(
({ value }: SearchFilterOption) => {
const next = selected.includes(value)
? selected.filter((v) => v !== value)
: [...selected, value];

const values = selected.includes(value) ? [] : [value];
dispatch({
type: "set_query",
payload: {
name: SECTOR,
query: next.length ? `in.(${next.join(",")})` : null,
values: next,
query: buildQuery(values),
values,
},
});
},
Expand All @@ -53,7 +55,7 @@ export default function SectorOptions({
type: "set_query",
payload: {
name: SECTOR,
query: `in.(${initialSelected.join(",")})`,
query: buildQuery(initialSelected),
values: initialSelected,
},
});
Expand Down
2 changes: 1 addition & 1 deletion app/src/app/search/filters/url-search-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export const UNIT_TYPE = "unit_type";
export const INVALID_CODES = "invalid_codes";
export const REGION = "physical_region_path";
export const LEGAL_FORM = "legal_form_code";
export const SECTOR = "sector_code";
export const SECTOR = "sector_path";
export const ACTIVITY_CATEGORY_PATH = "primary_activity_category_path";
2 changes: 1 addition & 1 deletion app/src/app/search/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { CartProvider } from "@/app/search/cart-provider";
import { createClient } from "@/lib/supabase/server";

export const metadata: Metadata = {
title: "StatBus | Search statistical units",
title: "Statbus | Search statistical units",
};

export default async function SearchPage({
Expand Down
13 changes: 12 additions & 1 deletion app/src/components/command-palette/command-palette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ export function CommandPalette() {
};

const keydown = (e: KeyboardEvent) => {
if (e.key === "k" && (e.metaKey || e.ctrlKey) && e.shiftKey) {
if (
(e.key === "k" || e.key === "K") &&
(e.metaKey || e.ctrlKey) &&
e.shiftKey
) {
e.preventDefault();
open();
}
Expand Down Expand Up @@ -147,6 +151,13 @@ export function CommandPalette() {
<Upload className="mr-2 h-4 w-4" />
<span>Upload Legal Units</span>
</CommandItem>
<CommandItem
onSelect={() => navigate("/getting-started/upload-establishments")}
value="Upload Establishments"
>
<Upload className="mr-2 h-4 w-4" />
<span>Upload Establishments</span>
</CommandItem>
<CommandItem onSelect={() => navigate("/profile")} value="Profile">
<User className="mr-2 h-4 w-4" />
<span>Profile</span>
Expand Down
4 changes: 2 additions & 2 deletions app/src/components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function NavbarSkeleton() {
return (
<header className="bg-ssb-dark text-white">
<div className="mx-auto flex max-w-screen-xl items-center justify-between gap-4 p-2 lg:px-4">
<Image src={logo} alt="StatBus Logo" className="h-10 w-10" />
<Image src={logo} alt="Statbus Logo" className="h-10 w-10" />
</div>
</header>
);
Expand All @@ -26,7 +26,7 @@ export default async function Navbar() {
<header className="bg-ssb-dark text-white">
<div className="mx-auto flex max-w-screen-xl items-center justify-between gap-4 p-2 lg:px-4">
<a href="/" className="flex items-center space-x-3 rtl:space-x-reverse">
<Image src={logo} alt="StatBus Logo" className="h-10 w-10" />
<Image src={logo} alt="Statbus Logo" className="h-10 w-10" />
</a>
{session.data.session?.user && (
<div className="flex-1 space-x-3 flex items-center justify-end">
Expand Down

0 comments on commit f95adfb

Please sign in to comment.