@c-rex/templates 0.1.7 → 0.1.9

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/src/home/page.tsx DELETED
@@ -1,87 +0,0 @@
1
- "use client";
2
-
3
- import React, { FC } from "react";
4
- import { informationUnitsResponse } from "@c-rex/interfaces";
5
- import { call, getFromCookieString } from "@c-rex/utils";
6
- import { Button } from "@c-rex/ui/button";
7
- import { AutoComplete } from "@c-rex/components/autocomplete";
8
- import { ResultList } from "@c-rex/components/result-list";
9
- import { useTranslations } from 'next-intl'
10
- import { parseAsInteger, parseAsString, useQueryStates } from 'nuqs'
11
- import { DialogFilter } from "@c-rex/components/dialog-filter";
12
- import { CONTENT_LANG_KEY } from "@c-rex/constants";
13
- import { useAppConfig } from "@c-rex/contexts/config-provider";
14
-
15
- interface HomePageProps {
16
- data: informationUnitsResponse;
17
- selectedLanguages: string[];
18
- }
19
-
20
- export const HomePage: FC<HomePageProps> = ({ data, selectedLanguages }) => {
21
- const { configs, availableLanguagesAndCountries: availableLanguages, contentLang } = useAppConfig()
22
- const t = useTranslations();
23
- const [params, setParams] = useQueryStates({
24
- search: {
25
- defaultValue: "",
26
- parse(value) {
27
- return value
28
- },
29
- },
30
- operator: parseAsString,
31
- language: parseAsString,
32
- page: parseAsInteger,
33
- }, {
34
- history: 'push',
35
- shallow: false,
36
- });
37
-
38
- const { search } = params;
39
-
40
- const onSearch = (value: string): Promise<string[]> => {
41
- return call<string[]>("InformationUnitsService.getSuggestions", { query: value, language: contentLang });
42
- }
43
-
44
- const onSelect = (value: string) => {
45
- //show loading
46
-
47
- const cookie = getFromCookieString(document.cookie, CONTENT_LANG_KEY)
48
-
49
- setParams({
50
- search: value,
51
- operator: "OR",
52
- page: 1,
53
- language: cookie,
54
- });
55
- };
56
-
57
- return (
58
- <div className="container">
59
- <div className="grid grid-cols-12 gap-4 py-6">
60
- <div className="col-span-12 sm:col-span-9 md:col-span-10">
61
- <AutoComplete
62
- initialValue={search}
63
- onSearch={onSearch}
64
- onSelect={onSelect}
65
- />
66
- </div>
67
- <div className="col-span-12 sm:col-span-3 md:col-span-2">
68
- <div className="flex justify-end">
69
- <DialogFilter
70
- startSelectedLanguages={selectedLanguages}
71
- availableLanguages={availableLanguages}
72
- trigger={(
73
- <Button variant="default">{t("filters")}</Button>
74
- )}
75
- />
76
- </div>
77
- </div>
78
- </div>
79
-
80
- <ResultList
81
- configs={configs}
82
- items={data.items}
83
- pagination={data.pageInfo}
84
- />
85
- </div>
86
- );
87
- };