@c-rex/templates 0.1.0 → 0.1.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.
- package/package.json +1 -1
- package/src/home/layout.tsx +10 -2
- package/src/home/page.tsx +24 -25
package/package.json
CHANGED
package/src/home/layout.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { informationUnits } from "@c-rex/interfaces";
|
|
2
|
+
import { ConfigInterface, informationUnits } from "@c-rex/interfaces";
|
|
3
3
|
import { InformationUnitsService, LanguageService } from "@c-rex/services";
|
|
4
|
-
import { getConfigs } from "@c-rex/utils/next-cookies";
|
|
4
|
+
import { getConfigs, getCookie } from "@c-rex/utils/next-cookies";
|
|
5
5
|
import { HomePage } from "./page";
|
|
6
|
+
import { SDK_CONFIG_KEY } from "@c-rex/constants";
|
|
6
7
|
|
|
7
8
|
interface SearchParams {
|
|
8
9
|
search?: string;
|
|
@@ -68,10 +69,17 @@ const loadData = async ({
|
|
|
68
69
|
|
|
69
70
|
export const HomeLayout = async ({ searchParams }: HomeProps) => {
|
|
70
71
|
const { data, filters: { selectedLanguages, availableLanguages } } = await loadData(searchParams);
|
|
72
|
+
const jsonConfigs = await getCookie(SDK_CONFIG_KEY);
|
|
73
|
+
if (!jsonConfigs) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const configs: ConfigInterface = JSON.parse(jsonConfigs);
|
|
71
78
|
|
|
72
79
|
return (
|
|
73
80
|
<HomePage
|
|
74
81
|
data={data}
|
|
82
|
+
configs={configs}
|
|
75
83
|
selectedLanguages={selectedLanguages}
|
|
76
84
|
availableLanguages={availableLanguages}
|
|
77
85
|
/>
|
package/src/home/page.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import React, { FC } from "react";
|
|
4
|
-
import { informationUnits } from "@c-rex/interfaces";
|
|
4
|
+
import { ConfigInterface, informationUnits } from "@c-rex/interfaces";
|
|
5
5
|
import { call } from "@c-rex/utils";
|
|
6
6
|
import { Button } from "@c-rex/ui/button";
|
|
7
7
|
import { AutoComplete } from "@c-rex/components/autocomplete";
|
|
@@ -11,18 +11,19 @@ import { parseAsInteger, parseAsString, useQueryStates } from 'nuqs'
|
|
|
11
11
|
import { DialogFilter } from "@c-rex/components/dialog-filter";
|
|
12
12
|
import { getCookie } from "@c-rex/utils/next-cookies";
|
|
13
13
|
import { CONTENT_LANG_KEY } from "@c-rex/constants";
|
|
14
|
-
import { SearchProvider } from "@c-rex/contexts/search";
|
|
15
14
|
|
|
16
15
|
interface HomePageProps {
|
|
17
16
|
data: informationUnits;
|
|
18
17
|
selectedLanguages: string[];
|
|
19
18
|
availableLanguages: any;
|
|
19
|
+
configs: ConfigInterface
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export const HomePage: FC<HomePageProps> = ({
|
|
23
23
|
data,
|
|
24
24
|
selectedLanguages,
|
|
25
25
|
availableLanguages,
|
|
26
|
+
configs
|
|
26
27
|
}) => {
|
|
27
28
|
const t = useTranslations();
|
|
28
29
|
const [params, setParams] = useQueryStates({
|
|
@@ -58,32 +59,30 @@ export const HomePage: FC<HomePageProps> = ({
|
|
|
58
59
|
};
|
|
59
60
|
|
|
60
61
|
return (
|
|
61
|
-
<
|
|
62
|
-
<div className="
|
|
63
|
-
<div className="
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<div className="
|
|
72
|
-
<
|
|
73
|
-
<DialogFilter
|
|
62
|
+
<div className="container">
|
|
63
|
+
<div className="grid grid-cols-12 gap-4 py-6">
|
|
64
|
+
<div className="col-span-12 sm:col-span-9 md:col-span-10">
|
|
65
|
+
<AutoComplete
|
|
66
|
+
initialValue={search}
|
|
67
|
+
onSearch={onSearch}
|
|
68
|
+
onSelect={onSelect}
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
<div className="col-span-12 sm:col-span-3 md:col-span-2">
|
|
72
|
+
<div className="flex justify-end">
|
|
73
|
+
<DialogFilter
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
</div>
|
|
75
|
+
startSelectedLanguages={selectedLanguages}
|
|
76
|
+
availableLanguages={availableLanguages}
|
|
77
|
+
trigger={(
|
|
78
|
+
<Button variant="default">{t("filters")}</Button>
|
|
79
|
+
)}
|
|
80
|
+
/>
|
|
82
81
|
</div>
|
|
83
82
|
</div>
|
|
84
|
-
|
|
85
|
-
<ResultList items={data.items} />
|
|
86
83
|
</div>
|
|
87
|
-
|
|
84
|
+
|
|
85
|
+
<ResultList items={data.items} configs={configs} />
|
|
86
|
+
</div>
|
|
88
87
|
);
|
|
89
88
|
};
|