Skip to content

Commit

Permalink
Merge pull request #46 from goat-community/feature/scenario
Browse files Browse the repository at this point in the history
feat: add scenario
  • Loading branch information
majkshkurti authored Jul 22, 2024
2 parents b96eefe + 12707c5 commit 7622d5d
Show file tree
Hide file tree
Showing 282 changed files with 21,352 additions and 19,304 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require("./packages/eslint-config-p4b");
module.exports = require("./packages/eslint-config-p4b");
5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const baseConfig = require("./packages/prettier-config/prettier-preset");

module.exports = {
...baseConfig,
};
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@
"i18n-ally.sortKeys": true,
"i18n-ally.keepFulfilled": true,
"i18n-ally.namespace": true,
"i18n-ally.keystyle": "nested"
"i18n-ally.keystyle": "nested",
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint",
"editor.formatOnSave": true
}
2 changes: 1 addition & 1 deletion apps/storybook/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-alpine AS installer
FROM node:20-alpine AS installer
RUN corepack enable && corepack prepare pnpm@8.6.0 --activate

WORKDIR /app
Expand Down
10 changes: 5 additions & 5 deletions apps/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"build": "storybook build"
},
"dependencies": {
"@p4b/keycloak-theme": "*",
"@p4b/ui": "*",
"@p4b/types": "*",
"@p4b/keycloak-theme": "workspace:*",
"@p4b/ui": "workspace:*",
"@p4b/types": "workspace:*",
"next": "v13.4.12",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@p4b/tsconfig": "*",
"@p4b/tsconfig": "workspace:*",
"eslint-config-p4b": "workspace:*",
"eslint-plugin-storybook": "^0.6.12",
"@storybook/addon-a11y": "^7.4.0",
Expand All @@ -41,4 +41,4 @@
"storybook-dark-mode": "^3.0.0",
"file-system-cache": "2.0.0"
}
}
}
3 changes: 2 additions & 1 deletion apps/storybook/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "@/styles/globals.css";
import type { AppProps } from "next/app";

import "@/styles/globals.css";

export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />;
}
3 changes: 2 additions & 1 deletion apps/storybook/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import styles from "@/styles/Home.module.css";
import { Inter } from "next/font/google";
import Head from "next/head";
import Image from "next/image";

import styles from "@/styles/Home.module.css";

const inter = Inter({ subsets: ["latin"] });

export default function Home() {
Expand Down
18 changes: 7 additions & 11 deletions apps/web/.size-limit.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@

let manifest;
try {
manifest = require('./.next/build-manifest.json');
manifest = require("./.next/build-manifest.json");
} catch (e) {
throw new Error(
'Cannot find a NextJs build folder, did you forget to build ?'
);
throw new Error("Cannot find a NextJs build folder, did you forget to build ?");
}
const pages = manifest.pages;

const limitCfg = {
defaultSize: '150kb',
defaultSize: "150kb",
};



const getPageLimits = () => {
let pageLimits = [];
for (const [uri, paths] of Object.entries(pages)) {
Expand All @@ -32,8 +28,8 @@ const getPageLimits = () => {
module.exports = [
...getPageLimits(),
{
name: 'CSS',
path: ['.next/static/css/**/*.css'],
limit: '15 kB',
name: "CSS",
path: [".next/static/css/**/*.css"],
limit: "15 kB",
},
];
];
2 changes: 1 addition & 1 deletion apps/web/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"typescript.tsdk": "../../node_modules/.pnpm/typescript@4.9.5/node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
}
2 changes: 1 addition & 1 deletion apps/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-alpine AS base
FROM node:20-alpine AS base

FROM base AS builder
RUN apk add --no-cache libc6-compat
Expand Down
118 changes: 44 additions & 74 deletions apps/web/app/[lng]/(dashboard)/catalog/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"use client";

import ContentSearchBar from "@/components/dashboard/common/ContentSearchbar";
import { useTranslation } from "@/i18n/client";
import {
Box,
Button,
Expand All @@ -15,37 +13,33 @@ import {
Typography,
debounce,
} from "@mui/material";
import { useRouter } from "next/navigation";
import { parseAsArrayOf, parseAsInteger, parseAsString, useQueryState } from "nuqs";
import { useCallback, useMemo, useState } from "react";

import { ICON_NAME } from "@p4b/ui/components/Icon";

import { useTranslation } from "@/i18n/client";

import { useCatalogLayers, useMetadataAggregated } from "@/lib/api/layers";
import type { PaginatedQueryParams } from "@/lib/validations/common";
import type { GetDatasetSchema } from "@/lib/validations/layer";
import { datasetMetadataAggregated } from "@/lib/validations/layer";
import { ICON_NAME } from "@p4b/ui/components/Icon";
import {
parseAsString,
parseAsArrayOf,
useQueryState,
parseAsInteger,
} from "nuqs";
import type { PaginatedQueryParams } from "@/lib/validations/common";
import FilterPanel from "@/components/dashboard/catalog/FilterPanel";

import EmptySection from "@/components/common/EmptySection";
import { useRouter } from "next/navigation";
import CatalogDatasetCard, { METADATA_HEADER_ICONS } from "@/components/dashboard/catalog/CatalogDatasetCard";
import FilterPanel from "@/components/dashboard/catalog/FilterPanel";
import ContentSearchBar from "@/components/dashboard/common/ContentSearchbar";

const Catalog = () => {
const { t } = useTranslation("common");
const router = useRouter();
const useQueryStateArray = (key: string) =>
useQueryState(key, parseAsArrayOf(parseAsString));
const useQueryStateArray = (key: string) => useQueryState(key, parseAsArrayOf(parseAsString));
const [typeValue, setTypeValue] = useQueryStateArray("type");
const [dataCategoryValue, setDataCategoryValue] =
useQueryStateArray("data_category");
const [distributorNameValue, setDistributorNameValue] =
useQueryStateArray("distributor_name");
const [geographicalCodeValue, setGeographicalCodeValue] =
useQueryStateArray("geographical_code");
const [languageCodeValue, setLanguageCodeValue] =
useQueryStateArray("language_code");
const [dataCategoryValue, setDataCategoryValue] = useQueryStateArray("data_category");
const [distributorNameValue, setDistributorNameValue] = useQueryStateArray("distributor_name");
const [geographicalCodeValue, setGeographicalCodeValue] = useQueryStateArray("geographical_code");
const [languageCodeValue, setLanguageCodeValue] = useQueryStateArray("language_code");
const [licenseValue, setLicenseValue] = useQueryStateArray("license");
const [searchText, setSearchText] = useQueryState("search", parseAsString);

Expand Down Expand Up @@ -89,7 +83,7 @@ const Catalog = () => {
setLanguageCodeValue,
licenseValue,
setLicenseValue,
],
]
);
const datasetSchemaValues = useMemo(() => {
const keys = Object.keys(filterOptions);
Expand All @@ -102,29 +96,21 @@ const Catalog = () => {
},
{
in_catalog: true,
},
}
);
}, [filterOptions]);

const [queryParamPage, setQueryParamPage] = useQueryState(
"page",
parseAsInteger.withDefault(1),
);
const [queryParamPage, setQueryParamPage] = useQueryState("page", parseAsInteger.withDefault(1));

const [datasetSchema, setDatasetSchema] =
useState<GetDatasetSchema>(datasetSchemaValues);
const [datasetSchema, setDatasetSchema] = useState<GetDatasetSchema>(datasetSchemaValues);
const [queryParams, setQueryParams] = useState<PaginatedQueryParams>({
order: "descendent",
order_by: "updated_at",
size: 10,
page: queryParamPage || 1,
});
const { metadata, isLoading: filtersLoading } =
useMetadataAggregated(datasetSchema);
const { layers: datasets, isLoading: datasetsLoading } = useCatalogLayers(
queryParams,
datasetSchema,
);
const { metadata, isLoading: filtersLoading } = useMetadataAggregated(datasetSchema);
const { layers: datasets, isLoading: datasetsLoading } = useCatalogLayers(queryParams, datasetSchema);

const handleToggle = useCallback(
(filterType: string, value: string) => {
Expand All @@ -146,7 +132,7 @@ const Catalog = () => {
}
setDatasetSchema(newDatasetSchema);
},
[datasetSchema, filterOptions],
[datasetSchema, filterOptions]
);

const debouncedSetSearchText = debounce((value) => {
Expand All @@ -168,31 +154,28 @@ const Catalog = () => {
justifyContent: "space-between",
alignItems: "center",
mb: 8,
}}
>
}}>
<Typography variant="h6">{t("catalog")}</Typography>
</Box>
<Grid container justifyContent="space-between" spacing={4}>
<Grid item xs={3}>
<Paper elevation={3}>
<Stack sx={{ mt: 0 }}>
{Object.keys(datasetMetadataAggregated.shape).map(
(key, index) => {
return (
<Stack key={key}>
{index !== 0 && <Divider sx={{ py: 0, my: 0 }} />}
<FilterPanel
filterValues={filterOptions[key].value}
onToggle={(value) => handleToggle(key, value)}
filterType={key}
values={metadata ? metadata[key] : []}
isLoading={filtersLoading}
icon={METADATA_HEADER_ICONS[key]}
/>
</Stack>
);
},
)}
{Object.keys(datasetMetadataAggregated.shape).map((key, index) => {
return (
<Stack key={key}>
{index !== 0 && <Divider sx={{ py: 0, my: 0 }} />}
<FilterPanel
filterValues={filterOptions[key].value}
onToggle={(value) => handleToggle(key, value)}
filterType={key}
values={metadata ? metadata[key] : []}
isLoading={filtersLoading}
icon={METADATA_HEADER_ICONS[key]}
/>
</Stack>
);
})}
</Stack>
</Paper>
</Grid>
Expand All @@ -219,27 +202,19 @@ const Catalog = () => {

{datasets && datasets?.total === 0 && (
<Stack sx={{ mt: 10 }} alignItems="center" spacing={4}>
<EmptySection
label={t("no_catalog_dataset_found")}
icon={ICON_NAME.DATABASE}
/>
<Typography variant="body1">
{t("try_different_filters")}
</Typography>
<EmptySection label={t("no_catalog_dataset_found")} icon={ICON_NAME.DATABASE} />
<Typography variant="body1">{t("try_different_filters")}</Typography>
<Stack spacing={2} direction="column">
<Divider />
<Typography variant="body1">
{t("common:no_catalog_dataset_found_description")}
</Typography>
<Typography variant="body1">{t("common:no_catalog_dataset_found_description")}</Typography>
</Stack>
<Button
variant="outlined"
color="primary"
sx={{ mt: 2 }}
onClick={() => {
window.open("https://plan4better.de/en/contact/", "_blank");
}}
>
}}>
<Typography variant="body1" fontWeight="bold" color="inherit">
{t("contact_us")}
</Typography>
Expand Down Expand Up @@ -271,12 +246,7 @@ const Catalog = () => {
))}

{!datasetsLoading && datasets && datasets?.items.length > 0 && (
<Stack
direction="row"
justifyContent="center"
alignItems="center"
sx={{ p: 4 }}
>
<Stack direction="row" justifyContent="center" alignItems="center" sx={{ p: 4 }}>
<Pagination
count={datasets.pages || 1}
size="large"
Expand Down
Loading

0 comments on commit 7622d5d

Please sign in to comment.