@c-rex/templates 0.1.0 → 0.1.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-rex/templates",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -18,9 +18,13 @@
18
18
  "types": "./src/home/page.tsx",
19
19
  "import": "./src/home/page.tsx"
20
20
  },
21
- "./info/page": {
22
- "types": "./src/info/page.tsx",
23
- "import": "./src/info/page.tsx"
21
+ "./articles/info/page": {
22
+ "types": "./src/articles/info/page.tsx",
23
+ "import": "./src/articles/info/page.tsx"
24
+ },
25
+ "./articles/documents/page": {
26
+ "types": "./src/articles/documents/page.tsx",
27
+ "import": "./src/articles/documents/page.tsx"
24
28
  },
25
29
  "./layout": {
26
30
  "types": "./src/layout.tsx",
@@ -28,7 +32,8 @@
28
32
  }
29
33
  },
30
34
  "scripts": {
31
- "lint": "eslint . --max-warnings 0"
35
+ "lint": "eslint .",
36
+ "lint:fix": "eslint . --fix"
32
37
  },
33
38
  "devDependencies": {
34
39
  "@c-rex/eslint-config": "*",
@@ -0,0 +1,56 @@
1
+ import React from "react";
2
+ import { SidebarInset, SidebarProvider } from "@c-rex/ui/sidebar";
3
+ import { AppSidebar } from "@c-rex/components/sidebar";
4
+ import { Breadcrumb } from "@c-rex/components/breadcrumb";
5
+ import { loadArticleData } from "@c-rex/utils";
6
+
7
+ export const DocumentsPageTemplate = async ({ params }: { params: { id: string } }) => {
8
+ const { documentURL, availableVersions: availableVersionsAux, title } = await loadArticleData(params.id)
9
+
10
+ const availableVersions = availableVersionsAux.map((item) => {
11
+ return {
12
+ link: `/documents/${item.shortId}`,
13
+ ...item,
14
+ }
15
+ })
16
+
17
+ return (
18
+ <SidebarProvider>
19
+ <title>{title}</title>
20
+ <AppSidebar
21
+ data={[]}
22
+ availableVersions={availableVersions}
23
+ className="top-20"
24
+ side="right"
25
+ variant="floating"
26
+ collapsible="icon"
27
+ />
28
+ <SidebarInset>
29
+ <div className="container flex flex-col">
30
+ <header className="flex h-16 shrink-0 items-center justify-between">
31
+ <div className="flex shrink-0 items-center">
32
+ <Breadcrumb items={[
33
+ {
34
+ link: "/",
35
+ label: title,
36
+ id: "title",
37
+ active: false,
38
+ children: [],
39
+ }
40
+ ]} />
41
+ </div>
42
+ </header>
43
+
44
+ <div style={{ width: '100%', height: '90.6vh' }}>
45
+ <iframe
46
+ width="100%"
47
+ height="100%"
48
+ style={{ border: 'none' }}
49
+ src={documentURL}
50
+ />
51
+ </div>
52
+ </div>
53
+ </SidebarInset>
54
+ </SidebarProvider>
55
+ );
56
+ };
@@ -1,28 +1,31 @@
1
- "use client";
2
-
3
- import React, { FC } from "react";
4
- import { TreeOfContent } from "@c-rex/interfaces";
1
+ import React from "react";
5
2
  import { SidebarInset, SidebarProvider } from "@c-rex/ui/sidebar";
6
3
  import { AppSidebar } from "@c-rex/components/sidebar";
7
4
  import { Breadcrumb } from "@c-rex/components/breadcrumb";
5
+ import { loadArticleData } from "@c-rex/utils";
6
+
7
+ export const InfoPageTemplate = async ({ params }: { params: { id: string } }) => {
8
+ const {
9
+ availableVersions: availableVersionsAux,
10
+ title,
11
+ treeOfContent,
12
+ breadcrumbItems,
13
+ htmlContent
14
+ } = await loadArticleData(params.id)
8
15
 
9
- interface InfoPageTemplateProps {
10
- htmlContent: string;
11
- breadcrumbItems: TreeOfContent[];
12
- sidebarItems: TreeOfContent[];
13
- availableVersions: any
14
- }
16
+ const availableVersions = availableVersionsAux.map((item) => {
17
+ return {
18
+ link: `/topics/${item.shortId}`,
19
+ ...item,
20
+ }
21
+ })
15
22
 
16
- export const InfoPageTemplate: FC<InfoPageTemplateProps> = ({
17
- htmlContent,
18
- breadcrumbItems,
19
- sidebarItems,
20
- availableVersions
21
- }) => {
22
23
  return (
23
24
  <SidebarProvider>
25
+ <title>{title}</title>
26
+
24
27
  <AppSidebar
25
- data={sidebarItems}
28
+ data={treeOfContent}
26
29
  availableVersions={availableVersions}
27
30
  className="top-20"
28
31
  side="right"
@@ -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;
@@ -50,7 +51,7 @@ const loadData = async ({
50
51
  data = await service.getList({
51
52
  queries: searchValue.split(" ").join(","),
52
53
  page: pageAux,
53
- fields: [],
54
+ fields: ["renditions", "class", "languages", "labels"],
54
55
  languages: selectedLanguages
55
56
  });
56
57
  }
@@ -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
- <SearchProvider>
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
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
- startSelectedLanguages={selectedLanguages}
76
- availableLanguages={availableLanguages}
77
- trigger={(
78
- <Button variant="default">{t("filters")}</Button>
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
- </SearchProvider>
84
+
85
+ <ResultList items={data.items} configs={configs} />
86
+ </div>
88
87
  );
89
88
  };