@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/package.json +25 -17
- package/src/{articles/blog → blog/article}/page.tsx +5 -5
- package/src/{articles → blog/article}/utils.ts +28 -17
- package/src/blog/home/layout.tsx +59 -0
- package/src/blog/home/page.tsx +323 -0
- package/src/doc/articles/documents.tsx +38 -0
- package/src/{articles/topics/page.tsx → doc/articles/topics.tsx} +10 -6
- package/src/doc/articles/utils.ts +142 -0
- package/src/{articles → doc/articles}/wrapper.tsx +13 -7
- package/src/doc/home/layout.tsx +59 -0
- package/src/doc/home/page.tsx +324 -0
- package/src/articles/documents/page.tsx +0 -21
- package/src/home/layout.tsx +0 -56
- package/src/home/page.tsx +0 -87
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c-rex/templates",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"src"
|
|
@@ -10,29 +10,37 @@
|
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
|
-
"./home/layout": {
|
|
14
|
-
"types": "./src/home/layout.tsx",
|
|
15
|
-
"import": "./src/home/layout.tsx"
|
|
13
|
+
"./doc/home/layout": {
|
|
14
|
+
"types": "./src/doc/home/layout.tsx",
|
|
15
|
+
"import": "./src/doc/home/layout.tsx"
|
|
16
16
|
},
|
|
17
|
-
"./home/page": {
|
|
18
|
-
"types": "./src/home/page.tsx",
|
|
19
|
-
"import": "./src/home/page.tsx"
|
|
17
|
+
"./doc/home/page": {
|
|
18
|
+
"types": "./src/doc/home/page.tsx",
|
|
19
|
+
"import": "./src/doc/home/page.tsx"
|
|
20
20
|
},
|
|
21
|
-
"./articles/topics
|
|
22
|
-
"types": "./src/articles/topics
|
|
23
|
-
"import": "./src/articles/topics
|
|
21
|
+
"./doc/articles/topics": {
|
|
22
|
+
"types": "./src/doc/articles/topics.tsx",
|
|
23
|
+
"import": "./src/doc/articles/topics.tsx"
|
|
24
24
|
},
|
|
25
|
-
"./articles/
|
|
26
|
-
"types": "./src/articles/
|
|
27
|
-
"import": "./src/articles/
|
|
28
|
-
},
|
|
29
|
-
"./articles/documents/page": {
|
|
30
|
-
"types": "./src/articles/documents/page.tsx",
|
|
31
|
-
"import": "./src/articles/documents/page.tsx"
|
|
25
|
+
"./doc/articles/documents": {
|
|
26
|
+
"types": "./src/doc/articles/documents.tsx",
|
|
27
|
+
"import": "./src/doc/articles/documents.tsx"
|
|
32
28
|
},
|
|
33
29
|
"./layout": {
|
|
34
30
|
"types": "./src/layout.tsx",
|
|
35
31
|
"import": "./src/layout.tsx"
|
|
32
|
+
},
|
|
33
|
+
"./blog/article": {
|
|
34
|
+
"types": "./src/blog/article/page.tsx",
|
|
35
|
+
"import": "./src/blog/article/page.tsx"
|
|
36
|
+
},
|
|
37
|
+
"./blog/home/page": {
|
|
38
|
+
"types": "./src/blog/home/page.tsx",
|
|
39
|
+
"import": "./src/blog/home/page.tsx"
|
|
40
|
+
},
|
|
41
|
+
"./blog/home/layout": {
|
|
42
|
+
"types": "./src/blog/home/layout.tsx",
|
|
43
|
+
"import": "./src/blog/home/layout.tsx"
|
|
36
44
|
}
|
|
37
45
|
},
|
|
38
46
|
"scripts": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extractHtmlContent, getInfoWithCache, getPrimaryInfo } from "
|
|
1
|
+
import { extractHtmlContent, getInfoWithCache, getPrimaryInfo } from "./utils";
|
|
2
2
|
import { BLOG_TYPE_AND_LINK } from "@c-rex/constants";
|
|
3
3
|
import { PageWrapper } from "@c-rex/components/page-wrapper";
|
|
4
4
|
import { Metadata } from "next";
|
|
@@ -30,23 +30,23 @@ export const generateMetadata = async (
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export const BlogPageTemplate = async ({ params }: { params: { id: string } }) => {
|
|
33
|
-
const { htmlContent,
|
|
33
|
+
const { htmlContent, articleLang, availableVersions } = await getInfoWithCache(params.id, BLOG_TYPE_AND_LINK, infoCache);
|
|
34
34
|
const { articleHtml } = extractHtmlContent(htmlContent)
|
|
35
35
|
|
|
36
36
|
return (
|
|
37
|
-
<PageWrapper title="">
|
|
37
|
+
<PageWrapper title="" pageType="BLOG">
|
|
38
38
|
<SidebarProvider>
|
|
39
39
|
|
|
40
40
|
<CheckArticleLangToast availableVersions={availableVersions} />
|
|
41
41
|
|
|
42
42
|
<AppSidebar
|
|
43
|
-
lang={
|
|
43
|
+
lang={articleLang}
|
|
44
44
|
data={[]}
|
|
45
45
|
availableVersions={availableVersions}
|
|
46
46
|
/>
|
|
47
47
|
<SidebarInset>
|
|
48
48
|
<div className="container flex flex-col">
|
|
49
|
-
<RenderArticle htmlContent={articleHtml} contentLang={
|
|
49
|
+
<RenderArticle htmlContent={articleHtml} contentLang={articleLang} />
|
|
50
50
|
</div>
|
|
51
51
|
</SidebarInset>
|
|
52
52
|
</SidebarProvider>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DirectoryNodesService, InformationUnitsService, RenditionsService } from "@c-rex/services";
|
|
2
2
|
import { DOCUMENTS_TYPE_AND_LINK, TOPICS_TYPE_AND_LINK } from "@c-rex/constants";
|
|
3
|
-
import { DirectoryNodes, SidebarAvailableVersionsInterface } from "@c-rex/interfaces";
|
|
3
|
+
import { DirectoryNodes, informationUnitsResponseItem, SidebarAvailableVersionsInterface } from "@c-rex/interfaces";
|
|
4
4
|
import * as cheerio from 'cheerio'
|
|
5
5
|
import { BLOG_TYPE_AND_LINK } from "@c-rex/constants";
|
|
6
6
|
|
|
@@ -13,7 +13,9 @@ import { BLOG_TYPE_AND_LINK } from "@c-rex/constants";
|
|
|
13
13
|
export const getPrimaryInfo = async (id: string, type: string): Promise<{
|
|
14
14
|
htmlContent: string,
|
|
15
15
|
title: string,
|
|
16
|
-
|
|
16
|
+
articleLang: string,
|
|
17
|
+
packageId: string,
|
|
18
|
+
documentLang: string,
|
|
17
19
|
availableVersions: SidebarAvailableVersionsInterface[]
|
|
18
20
|
}> => {
|
|
19
21
|
const renditionService = new RenditionsService();
|
|
@@ -21,25 +23,28 @@ export const getPrimaryInfo = async (id: string, type: string): Promise<{
|
|
|
21
23
|
const informationUnitsItem = await informationService.getItem({ id });
|
|
22
24
|
|
|
23
25
|
let title = informationUnitsItem.labels[0]?.value
|
|
24
|
-
const lang = informationUnitsItem.languages[0];
|
|
25
26
|
const versionOf = informationUnitsItem.versionOf.shortId
|
|
27
|
+
let documentLang = ""
|
|
28
|
+
const articleLang = informationUnitsItem.languages[0];
|
|
26
29
|
|
|
27
|
-
const
|
|
30
|
+
const promiseList: any = [
|
|
28
31
|
informationService.getList({
|
|
29
|
-
|
|
32
|
+
restrict: [`versionOf.shortId=${versionOf}`],
|
|
30
33
|
fields: ["renditions", "class", "languages", "labels"],
|
|
31
34
|
}),
|
|
32
|
-
|
|
33
|
-
])
|
|
35
|
+
]
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
const rootNode = await getRootNode(informationUnitsItem.directoryNodes)
|
|
36
38
|
|
|
37
39
|
if (rootNode != null) {
|
|
38
40
|
title = rootNode.informationUnits[0]?.labels[0]?.value;
|
|
41
|
+
documentLang = rootNode.informationUnits[0]?.labels[0]?.language as string;
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
if ([TOPICS_TYPE_AND_LINK, BLOG_TYPE_AND_LINK].includes(type)) {
|
|
42
|
-
|
|
45
|
+
promiseList.push(
|
|
46
|
+
renditionService.getHTMLRendition({ renditions: informationUnitsItem.renditions })
|
|
47
|
+
)
|
|
43
48
|
|
|
44
49
|
} else if (rootNode != null && type == DOCUMENTS_TYPE_AND_LINK) {
|
|
45
50
|
|
|
@@ -48,33 +53,39 @@ export const getPrimaryInfo = async (id: string, type: string): Promise<{
|
|
|
48
53
|
const directoryId = rootNode.childNodes[0]?.shortId as string;
|
|
49
54
|
|
|
50
55
|
const response = await service.getItem(directoryId);
|
|
56
|
+
|
|
51
57
|
const infoId = response.informationUnits[0]?.shortId;
|
|
52
58
|
|
|
53
59
|
const childInformationUnit = await informationService.getItem({ id: infoId as string });
|
|
54
60
|
|
|
55
|
-
|
|
61
|
+
promiseList.push(
|
|
62
|
+
renditionService.getHTMLRendition({ renditions: childInformationUnit.renditions })
|
|
63
|
+
)
|
|
56
64
|
}
|
|
57
65
|
|
|
58
|
-
const
|
|
66
|
+
const [versions, htmlContent] = await Promise.all(promiseList)
|
|
67
|
+
|
|
68
|
+
const availableVersions = versions.items.map((item: informationUnitsResponseItem) => {
|
|
59
69
|
return {
|
|
60
70
|
shortId: item.shortId,
|
|
61
71
|
link: `/${type}/${item.shortId}`,
|
|
62
72
|
lang: item.language,
|
|
63
73
|
country: item.language.split("-")[1],
|
|
64
|
-
active: item.language ===
|
|
74
|
+
active: item.language === articleLang,
|
|
65
75
|
}
|
|
66
|
-
}).sort((a, b) => {
|
|
76
|
+
}).sort((a: SidebarAvailableVersionsInterface, b: SidebarAvailableVersionsInterface) => {
|
|
67
77
|
if (a.lang < b.lang) return -1;
|
|
68
78
|
if (a.lang > b.lang) return 1;
|
|
69
79
|
return 0;
|
|
70
|
-
})
|
|
71
|
-
.filter(item => item.lang.toLocaleLowerCase() !== "pl-pl") as SidebarAvailableVersionsInterface[];
|
|
80
|
+
}) as SidebarAvailableVersionsInterface[];
|
|
72
81
|
|
|
73
82
|
return {
|
|
74
83
|
htmlContent,
|
|
84
|
+
packageId: informationUnitsItem.packages[0]?.shortId as string,
|
|
75
85
|
title: title as string,
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
articleLang: articleLang as string,
|
|
87
|
+
documentLang: documentLang as string,
|
|
88
|
+
availableVersions,
|
|
78
89
|
}
|
|
79
90
|
}
|
|
80
91
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { informationUnitsResponse } from "@c-rex/interfaces";
|
|
2
|
+
import { InformationUnitsService } from "@c-rex/services";
|
|
3
|
+
import { HomePage } from "./page";
|
|
4
|
+
import { PageWrapper } from "@c-rex/components/page-wrapper";
|
|
5
|
+
import { WildCardType } from "@c-rex/types";
|
|
6
|
+
|
|
7
|
+
interface HomeProps {
|
|
8
|
+
searchParams: {
|
|
9
|
+
search?: string;
|
|
10
|
+
page: string;
|
|
11
|
+
language: string;
|
|
12
|
+
wildcard: string;
|
|
13
|
+
operator: string;
|
|
14
|
+
like: string;
|
|
15
|
+
packages?: string;
|
|
16
|
+
filter?: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const HomeLayout = async ({ searchParams }: HomeProps) => {
|
|
21
|
+
const { search, page, language, wildcard, operator, like, packages, filter } = searchParams;
|
|
22
|
+
|
|
23
|
+
let data = {
|
|
24
|
+
items: [],
|
|
25
|
+
pageInfo: {
|
|
26
|
+
pageCount: 0,
|
|
27
|
+
pageNumber: 0
|
|
28
|
+
}
|
|
29
|
+
} as unknown as informationUnitsResponse;
|
|
30
|
+
|
|
31
|
+
if (search !== undefined) {
|
|
32
|
+
|
|
33
|
+
const filters: string[] = filter?.split(",") || []
|
|
34
|
+
const restrict: string[] = []
|
|
35
|
+
|
|
36
|
+
if (packages && packages.length > 0) {
|
|
37
|
+
restrict.push(`packages.shortId=${packages}`)
|
|
38
|
+
}
|
|
39
|
+
const service = new InformationUnitsService();
|
|
40
|
+
|
|
41
|
+
data = await service.getList({
|
|
42
|
+
queries: search,
|
|
43
|
+
page: Number(page),
|
|
44
|
+
fields: ["renditions", "class", "languages", "labels"],
|
|
45
|
+
languages: language.split(","),
|
|
46
|
+
wildcard: wildcard as WildCardType,
|
|
47
|
+
restrict: restrict,
|
|
48
|
+
operator: operator,
|
|
49
|
+
like: Boolean(like === "true"),
|
|
50
|
+
filters: filters
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<PageWrapper title="" pageType="HOME">
|
|
56
|
+
<HomePage data={data} />
|
|
57
|
+
</PageWrapper>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { FC, useEffect, useState } from "react";
|
|
4
|
+
import { Trash2, X } from "lucide-react"
|
|
5
|
+
import { useTranslations } from 'next-intl'
|
|
6
|
+
import { parseAsBoolean, parseAsInteger, parseAsString, useQueryStates } from 'nuqs'
|
|
7
|
+
import { informationUnitsResponse } from "@c-rex/interfaces";
|
|
8
|
+
import { Button } from "@c-rex/ui/button";
|
|
9
|
+
import { Badge } from "@c-rex/ui/badge";
|
|
10
|
+
import {
|
|
11
|
+
SidebarContent,
|
|
12
|
+
SidebarGroup,
|
|
13
|
+
SidebarGroupContent,
|
|
14
|
+
SidebarGroupLabel,
|
|
15
|
+
SidebarHeader,
|
|
16
|
+
SidebarMenu,
|
|
17
|
+
SidebarMenuSub,
|
|
18
|
+
SidebarMenuSubButton,
|
|
19
|
+
SidebarMenuSubItem
|
|
20
|
+
} from "@c-rex/ui/sidebar";
|
|
21
|
+
import { ResultList } from "@c-rex/components/result-list";
|
|
22
|
+
import { DialogFilter } from "@c-rex/components/dialog-filter";
|
|
23
|
+
import { useAppConfig } from "@c-rex/contexts/config-provider";
|
|
24
|
+
import { AutoComplete } from "@c-rex/components/autocomplete";
|
|
25
|
+
import { OPERATOR_OPTIONS, WILD_CARD_OPTIONS } from "@c-rex/constants";
|
|
26
|
+
import { Loading } from "@c-rex/components/loading";
|
|
27
|
+
|
|
28
|
+
interface HomePageProps {
|
|
29
|
+
data: informationUnitsResponse;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type filterModel = {
|
|
33
|
+
key: string
|
|
34
|
+
name?: string
|
|
35
|
+
value: string
|
|
36
|
+
default?: string | boolean | null
|
|
37
|
+
removable: boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const HomePage: FC<HomePageProps> = ({ data }) => {
|
|
41
|
+
const t = useTranslations();
|
|
42
|
+
const { configs } = useAppConfig()
|
|
43
|
+
|
|
44
|
+
const [tags, setTags] = useState<{ [key: string]: any[] }>(data.tags || {});
|
|
45
|
+
const [filters, setFilters] = useState<filterModel[] | null>(null)
|
|
46
|
+
const [disabled, setDisabled] = useState<boolean>(false)
|
|
47
|
+
const [loading, setLoading] = useState<boolean>(true)
|
|
48
|
+
const [params, setParams] = useQueryStates({
|
|
49
|
+
language: parseAsString,
|
|
50
|
+
page: parseAsInteger,
|
|
51
|
+
wildcard: parseAsString,
|
|
52
|
+
operator: parseAsString,
|
|
53
|
+
packages: parseAsString,
|
|
54
|
+
filter: parseAsString,
|
|
55
|
+
like: parseAsBoolean,
|
|
56
|
+
search: {
|
|
57
|
+
defaultValue: "",
|
|
58
|
+
parse(value) {
|
|
59
|
+
return value
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
}, {
|
|
63
|
+
history: 'push',
|
|
64
|
+
shallow: false,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (params.search.length > 0) {
|
|
69
|
+
setDisabled(false)
|
|
70
|
+
generateFiltersObj()
|
|
71
|
+
} else {
|
|
72
|
+
setDisabled(true)
|
|
73
|
+
setFilters(null)
|
|
74
|
+
}
|
|
75
|
+
}, [params])
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
const newTags = { ...data.tags }
|
|
79
|
+
|
|
80
|
+
if (params.filter !== null) {
|
|
81
|
+
const splittedParam = params.filter.split(",")
|
|
82
|
+
|
|
83
|
+
splittedParam.forEach((item) => {
|
|
84
|
+
const aux = item.split(".shortId=")
|
|
85
|
+
const name = aux[0]
|
|
86
|
+
const shortId = aux[1]
|
|
87
|
+
|
|
88
|
+
if (!newTags[name]) {
|
|
89
|
+
newTags[name] = []
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
newTags[name].forEach((el) => {
|
|
93
|
+
if (el.shortId == shortId) {
|
|
94
|
+
el.active = true
|
|
95
|
+
} else {
|
|
96
|
+
el.active = false
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (params.packages !== null && newTags["packages"]) {
|
|
103
|
+
newTags["packages"].forEach((el) => {
|
|
104
|
+
if (el.shortId == params.packages) {
|
|
105
|
+
el.active = true
|
|
106
|
+
} else {
|
|
107
|
+
el.active = false
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
setTags(newTags)
|
|
113
|
+
setLoading(false)
|
|
114
|
+
}, [data])
|
|
115
|
+
|
|
116
|
+
const generateFiltersObj = () => {
|
|
117
|
+
const filters: filterModel[] = [{
|
|
118
|
+
key: "operator",
|
|
119
|
+
name: t("filter.operator"),
|
|
120
|
+
value: `${params?.operator !== OPERATOR_OPTIONS.OR}`,
|
|
121
|
+
default: OPERATOR_OPTIONS.OR,
|
|
122
|
+
removable: params?.operator !== OPERATOR_OPTIONS.OR
|
|
123
|
+
}, {
|
|
124
|
+
key: "like",
|
|
125
|
+
name: t("filter.like"),
|
|
126
|
+
value: `${params.like}`,
|
|
127
|
+
default: false,
|
|
128
|
+
removable: params?.like as boolean
|
|
129
|
+
}, {
|
|
130
|
+
key: "wildcard",
|
|
131
|
+
value: params.wildcard as string,
|
|
132
|
+
default: WILD_CARD_OPTIONS.NONE,
|
|
133
|
+
removable: params?.wildcard !== WILD_CARD_OPTIONS.NONE
|
|
134
|
+
}]
|
|
135
|
+
|
|
136
|
+
const languages = params.language?.split(",")
|
|
137
|
+
languages?.forEach((item) => {
|
|
138
|
+
const aux = languages?.filter(langItem => langItem !== item)
|
|
139
|
+
filters.push({ key: "language", value: item, removable: languages.length > 1, default: aux.join(",") })
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
if (params.filter !== null) {
|
|
143
|
+
const splittedParam = params.filter.split(",")
|
|
144
|
+
|
|
145
|
+
splittedParam.forEach((item, index) => {
|
|
146
|
+
const aux = item.split(".shortId=")
|
|
147
|
+
const name = aux[0]
|
|
148
|
+
const shortId = aux[1]
|
|
149
|
+
|
|
150
|
+
const defaultValue = [...splittedParam]
|
|
151
|
+
defaultValue.splice(index, 1)
|
|
152
|
+
|
|
153
|
+
if (!tags[name]) return;
|
|
154
|
+
|
|
155
|
+
const tag = tags[name].find(el => el.shortId === shortId)
|
|
156
|
+
if (!tag) return;
|
|
157
|
+
|
|
158
|
+
const value = defaultValue.length == 0 ? null : defaultValue.join(",")
|
|
159
|
+
|
|
160
|
+
filters.push({ key: "filter", name: t(`filter.tags.${name}`), value: tag.label, removable: true, default: value })
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (params.packages !== null && tags["packages"]) {
|
|
165
|
+
const packageTag = tags["packages"]?.find(el => el.shortId === params.packages)
|
|
166
|
+
filters.push({
|
|
167
|
+
key: "packages",
|
|
168
|
+
name: t("filter.tags.packages"),
|
|
169
|
+
value: packageTag.label,
|
|
170
|
+
removable: true,
|
|
171
|
+
default: null
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
Object.keys(params)
|
|
176
|
+
.filter(item => !["page", "search", "language", "operator", "like", "wildcard", "filter", "packages"].includes(item))
|
|
177
|
+
.filter(item => params[item] != null)
|
|
178
|
+
.forEach(item => {
|
|
179
|
+
filters.push({ key: item, value: params[item], removable: true, default: null })
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
setFilters(filters)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const updateFilterParam = (key: string, item: any) => {
|
|
186
|
+
setLoading(true)
|
|
187
|
+
if (key === "packages") {
|
|
188
|
+
setParams({ packages: item.shortId })
|
|
189
|
+
return;
|
|
190
|
+
} else {
|
|
191
|
+
const value = `${key}.shortId=${item.shortId}`
|
|
192
|
+
let aux = value
|
|
193
|
+
|
|
194
|
+
if (params.filter != null) {
|
|
195
|
+
const splittedParam = params.filter.split(",")
|
|
196
|
+
const finalValue = [...splittedParam]
|
|
197
|
+
|
|
198
|
+
const hasParams = params.filter.includes(key)
|
|
199
|
+
|
|
200
|
+
if (hasParams) {
|
|
201
|
+
let mainIndex = -1
|
|
202
|
+
|
|
203
|
+
splittedParam.forEach((el, index) => {
|
|
204
|
+
if (el.includes(key)) {
|
|
205
|
+
mainIndex = index
|
|
206
|
+
}
|
|
207
|
+
})
|
|
208
|
+
finalValue[mainIndex] = value
|
|
209
|
+
} else {
|
|
210
|
+
finalValue.push(value)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
aux = finalValue.join(",")
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
setParams({ filter: aux })
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<div className="container">
|
|
222
|
+
{loading && <Loading opacity={true} />}
|
|
223
|
+
|
|
224
|
+
<div className="grid grid-cols-12 gap-4 py-6">
|
|
225
|
+
<div className="col-span-12 sm:col-span-10 md:col-span-10">
|
|
226
|
+
<AutoComplete
|
|
227
|
+
embedded={false}
|
|
228
|
+
initialValue={params.search}
|
|
229
|
+
searchByPackage={false}
|
|
230
|
+
/>
|
|
231
|
+
</div>
|
|
232
|
+
<div className="col-span-12 sm:col-span-2 md:col-span-2">
|
|
233
|
+
<div className="flex justify-end">
|
|
234
|
+
<DialogFilter
|
|
235
|
+
setLoading={setLoading}
|
|
236
|
+
trigger={(
|
|
237
|
+
<Button variant="default" disabled={disabled}>{t("filter.filters")}</Button>
|
|
238
|
+
)}
|
|
239
|
+
/>
|
|
240
|
+
</div>
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
243
|
+
|
|
244
|
+
{filters != null && filters.length > 0 && (
|
|
245
|
+
<div className="pb-4 flex justify-between">
|
|
246
|
+
<div>
|
|
247
|
+
|
|
248
|
+
{filters?.map((item) => (
|
|
249
|
+
<Badge key={`${item.key}-${item?.value}`} variant="outline" className="mr-2 mb-2 h-6">
|
|
250
|
+
{item?.name ? item.name : item.key}: {item.value}
|
|
251
|
+
{item.removable && (
|
|
252
|
+
<Button size="xs" variant="ghost" onClick={() => {
|
|
253
|
+
setLoading(true)
|
|
254
|
+
setParams({ [item.key]: item?.default })
|
|
255
|
+
}}>
|
|
256
|
+
<X className="h-2" />
|
|
257
|
+
</Button>
|
|
258
|
+
)}
|
|
259
|
+
</Badge>
|
|
260
|
+
))}
|
|
261
|
+
|
|
262
|
+
</div>
|
|
263
|
+
<Button
|
|
264
|
+
size="sm"
|
|
265
|
+
variant="outline"
|
|
266
|
+
disabled={params.filter === null}
|
|
267
|
+
onClick={() => {
|
|
268
|
+
setLoading(true)
|
|
269
|
+
setParams({ filter: null, packages: null })
|
|
270
|
+
}}
|
|
271
|
+
>
|
|
272
|
+
{t("filter.clearFilters")}
|
|
273
|
+
<Trash2 className="h-2" />
|
|
274
|
+
</Button>
|
|
275
|
+
</div>
|
|
276
|
+
)}
|
|
277
|
+
|
|
278
|
+
<div className="flex flex-row gap-6 pb-6">
|
|
279
|
+
{data.items.length > 0 && (
|
|
280
|
+
<div className="w-80 bg-sidebar rounded-md border pb-4">
|
|
281
|
+
<SidebarHeader className="text-center font-bold">
|
|
282
|
+
Search Filters
|
|
283
|
+
</SidebarHeader>
|
|
284
|
+
<SidebarContent>
|
|
285
|
+
{Object.entries(tags).map(([key, value]: any) => (
|
|
286
|
+
<SidebarGroup key={key} className="py-0">
|
|
287
|
+
<SidebarGroupLabel>
|
|
288
|
+
{t(`filter.tags.${key}`)}
|
|
289
|
+
</SidebarGroupLabel>
|
|
290
|
+
<SidebarGroupContent>
|
|
291
|
+
<SidebarMenu>
|
|
292
|
+
<SidebarMenuSub>
|
|
293
|
+
{value.map(item => (
|
|
294
|
+
<SidebarMenuSubItem key={item.shortId}>
|
|
295
|
+
<SidebarMenuSubButton
|
|
296
|
+
className="cursor-pointer"
|
|
297
|
+
isActive={item.active}
|
|
298
|
+
onClick={() => updateFilterParam(key, item)}
|
|
299
|
+
>
|
|
300
|
+
{item.label} ({item.hits}/{item.total})
|
|
301
|
+
</SidebarMenuSubButton>
|
|
302
|
+
</SidebarMenuSubItem>
|
|
303
|
+
))}
|
|
304
|
+
</SidebarMenuSub>
|
|
305
|
+
</SidebarMenu>
|
|
306
|
+
</SidebarGroupContent>
|
|
307
|
+
</SidebarGroup>
|
|
308
|
+
))}
|
|
309
|
+
</SidebarContent>
|
|
310
|
+
</div>
|
|
311
|
+
)}
|
|
312
|
+
|
|
313
|
+
<div className="flex-1">
|
|
314
|
+
<ResultList
|
|
315
|
+
configs={configs}
|
|
316
|
+
items={data.items}
|
|
317
|
+
pagination={data.pageInfo}
|
|
318
|
+
/>
|
|
319
|
+
</div>
|
|
320
|
+
</div>
|
|
321
|
+
</div>
|
|
322
|
+
);
|
|
323
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getInfoWithCache, getPrimaryInfo } from "./utils";
|
|
2
|
+
import { ArticleWrapper } from "./wrapper";
|
|
3
|
+
import { PageWrapper } from "@c-rex/components/page-wrapper";
|
|
4
|
+
import { DOCUMENTS_TYPE_AND_LINK } from "@c-rex/constants";
|
|
5
|
+
|
|
6
|
+
const infoCache = new Map<string, Awaited<ReturnType<typeof getPrimaryInfo>>>();
|
|
7
|
+
|
|
8
|
+
export const DocumentsPageTemplate = async ({ params }: { params: { id: string } }) => {
|
|
9
|
+
/*
|
|
10
|
+
const {
|
|
11
|
+
htmlContent,
|
|
12
|
+
title,
|
|
13
|
+
articleLang,
|
|
14
|
+
availableVersions,
|
|
15
|
+
documentLang,
|
|
16
|
+
packageId
|
|
17
|
+
} = await getInfoWithCache(params.id, DOCUMENTS_TYPE_AND_LINK, infoCache);
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const { htmlContent, title, availableVersions, packageId, articleLang, documentLang } = await getPrimaryInfo(params.id, DOCUMENTS_TYPE_AND_LINK);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<PageWrapper title={title} pageType="DOC">
|
|
26
|
+
<ArticleWrapper
|
|
27
|
+
packageId={packageId}
|
|
28
|
+
title={title}
|
|
29
|
+
availableVersions={availableVersions}
|
|
30
|
+
htmlContent={htmlContent}
|
|
31
|
+
articleLang={articleLang}
|
|
32
|
+
documentLang={documentLang}
|
|
33
|
+
id={params.id}
|
|
34
|
+
type={DOCUMENTS_TYPE_AND_LINK}
|
|
35
|
+
/>
|
|
36
|
+
</PageWrapper>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { extractHtmlContent, getInfoWithCache, getPrimaryInfo } from "
|
|
2
|
+
import { extractHtmlContent, getInfoWithCache, getPrimaryInfo } from "./utils";
|
|
3
3
|
import { TOPICS_TYPE_AND_LINK } from "@c-rex/constants";
|
|
4
|
-
import { ArticleWrapper } from "
|
|
4
|
+
import { ArticleWrapper } from "./wrapper";
|
|
5
5
|
import { PageWrapper } from "@c-rex/components/page-wrapper";
|
|
6
6
|
import { Metadata } from "next";
|
|
7
7
|
|
|
@@ -30,17 +30,21 @@ export const TopicsPageTemplate = async ({ params }: { params: { id: string } })
|
|
|
30
30
|
const {
|
|
31
31
|
htmlContent,
|
|
32
32
|
title,
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
availableVersions,
|
|
34
|
+
packageId,
|
|
35
|
+
articleLang,
|
|
36
|
+
documentLang
|
|
35
37
|
} = await getInfoWithCache(params.id, TOPICS_TYPE_AND_LINK, infoCache);
|
|
36
38
|
|
|
37
39
|
const { articleHtml } = extractHtmlContent(htmlContent)
|
|
38
40
|
|
|
39
41
|
return (
|
|
40
|
-
<PageWrapper title={title}>
|
|
42
|
+
<PageWrapper title={title} pageType="DOC">
|
|
41
43
|
<ArticleWrapper
|
|
42
44
|
title={title}
|
|
43
|
-
|
|
45
|
+
documentLang={documentLang}
|
|
46
|
+
articleLang={articleLang}
|
|
47
|
+
packageId={packageId}
|
|
44
48
|
availableVersions={availableVersions}
|
|
45
49
|
htmlContent={articleHtml}
|
|
46
50
|
id={params.id}
|