这是indexloc提供的服务,不要输入任何密码
Skip to content

Implement content overview page #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions hosting/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ module.exports = {
es2021: true,
},

extends: ["eslint:recommended", "plugin:react/recommended", "plugin:@typescript-eslint/recommended", "google"],
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"plugin:@next/next/recommended",
"google",
],

plugins: ["react", "@typescript-eslint", "prettier"],

Expand All @@ -38,7 +45,7 @@ module.exports = {
"max-len": "off",
"require-jsdoc": "off",
"prettier/prettier": "error",
indent: ["error", 2],
indent: ["error", 2, {SwitchCase: 1}],
"operator-linebreak": ["error", "before"],
quotes: "off", // Use config quotes from prettier, so we turn off this rules to avoiding conflict between eslint and prettier
},
Expand Down
23 changes: 14 additions & 9 deletions hosting/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions hosting/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint",
"lint:fix": "next lint --fix",
"prettier:fix": "prettier --write .",
"codecheck": "npm run lint:fix && npm run prettier:fix"
"codecheck": "npm run prettier:fix && npm run lint:fix"
},
"dependencies": {
"apexcharts": "^3.45.2",
Expand All @@ -23,13 +23,14 @@
"react-dom": "^18.3.1"
},
"devDependencies": {
"@next/eslint-plugin-next": "^14.2.3",
"@types/node": "^20",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.10.0",
"@typescript-eslint/parser": "^7.10.0",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint": "^8.57.0",
"eslint-config-google": "^0.14.0",
"eslint-config-next": "14.1.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
47 changes: 47 additions & 0 deletions hosting/src/app/[site]/content/[type]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"use client";
import React from "react";
import Breadcrumb from "@/components/Breadcrumbs/Breadcrumb";
import {Table, TableRowActions, TableRowLabel} from "@/components/Table";
import DefaultLayout from "@/components/Layouts/DefaultLayout";
import {useTanamDocuments} from "@/hooks/useTanamDocuments";
import Alerts from "@/components/common/Alerts";

import {useTanamDocumentType} from "@/hooks/useTanamDocumentTypes";
import Loader from "../../../../components/common/Loader";

export default function ContentOverviewPage() {
const {data: documents, error: docsError} = useTanamDocuments();
const {data: documentType} = useTanamDocumentType();
return (
<DefaultLayout>
{documentType ? <Breadcrumb pageName={documentType.title} /> : <Loader />}

{docsError ? (
<Alerts type="error" title="Error fetching documents" message={docsError.message} />
) : (
<Table
headers={["Id", "Created", "Status", "Actions"]}
rows={documents.map((document, key) => [
<div key={`${key}-${document.id}-id`}>
<h5 className="font-medium text-black dark:text-white">{document.id}</h5>
</div>,
<p key={`${key}-${document.id}-date`} className="text-black dark:text-white">
{document.createdAt.toDate().toUTCString()}
</p>,
<TableRowLabel
key={`${key}-${document.id}-status`}
title={document.status}
status={document.status === "published" ? "success" : "info"}
/>,
<TableRowActions
key={`${key}-${document.id}-actions`}
onView={() => console.log("View", document)}
onDelete={() => console.log("Delete", document)}
onDownload={() => console.log("Download", document)}
/>,
])}
/>
)}
</DefaultLayout>
);
}
2 changes: 1 addition & 1 deletion hosting/src/app/[site]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface RootLayoutProps {
const RootLayout: React.FC<RootLayoutProps> = ({children}) => {
const [loading, setLoading] = useState<boolean>(true);
const [errorMessage, setError] = useState<string>("");
const {siteData, error} = useTanamSite();
const {data: siteData, error} = useTanamSite();

useEffect(() => {
if (siteData || error) {
Expand Down
28 changes: 0 additions & 28 deletions hosting/src/app/[site]/tables/page.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions hosting/src/components/Dashboard/E-commerce.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import ChartOne from "@/components/Charts/ChartOne";
import ChartThree from "@/components/Charts/ChartThree";
import ChartTwo from "@/components/Charts/ChartTwo";
import ChatCard from "@/components/Chat/ChatCard";
import TableOne from "@/components/Tables/TableOne";
import CardDataStats from "@/components/CardDataStats";
import MapOne from "@/components/Maps/MapOne";

Expand Down Expand Up @@ -103,9 +102,6 @@ const ECommerce: React.FC = () => {
<ChartTwo />
<ChartThree />
<MapOne />
<div className="col-span-12 xl:col-span-8">
<TableOne />
</div>
<ChatCard />
</div>
</>
Expand Down
9 changes: 5 additions & 4 deletions hosting/src/components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {DashboardIcon} from "./icons/DashboardIcon";
import {FormsIcon} from "./icons/FormsIcon";
import {ProfileIcon} from "./icons/ProfileIcon";
import {SettingsIcon} from "./icons/SettingsIcon";
import {useTanamSite} from "@/hooks/useTanamSite";

interface SidebarProps {
sidebarOpen: boolean;
Expand All @@ -20,10 +21,10 @@ interface SidebarProps {

const Sidebar = ({sidebarOpen, setSidebarOpen}: SidebarProps) => {
const pathname = usePathname() ?? "/";
const site = pathname.split("/")[1];
const trigger = useRef<any>(null);
const sidebar = useRef<any>(null);
const {data: documentTypes} = useTanamDocumentTypes(site);
const {data: documentTypes} = useTanamDocumentTypes();
const {data: site} = useTanamSite();

const storedSidebarExpanded = "true";

Expand Down Expand Up @@ -87,9 +88,9 @@ const Sidebar = ({sidebarOpen, setSidebarOpen}: SidebarProps) => {
<SidebarExpandableMenu
icon={<FormsIcon />}
title="Content"
isExpanded={pathname.includes("/document-types/")}
isExpanded={pathname.includes("/content/")}
menuItems={documentTypes.map((doc) => ({
href: `/document-types/${doc.id}`,
href: `/${site?.id}/content/${doc.id}`,
title: doc.title,
}))}
/>
Expand Down
60 changes: 60 additions & 0 deletions hosting/src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from "react";

interface TableProps {
headers: string[];
rows: React.ReactNode[][];
}

/**
* A Table component
*
* Example:
* ```tsx
* <Table
* headers={["Id", "Created", "Status", "Actions"]}
* rows={documents.map((document, key) => [
* <div>{document.id}</div>,
* <p>{document.createdAt.toDate().toUTCString()}</p>,
* <TableRowLabel title={document.status} status={document.status === "published" ? "success" : "info"} />,
* <TableRowActions
* onView={() => console.log("View", document)}
* onDelete={() => console.log("Delete", document)}
* onDownload={() => console.log("Download", document)}
* />,
* ])}
* />
* ```
*
* @param {TableProps} param0 Table parameters
* @return {JSX.Element} Table component
*/
export function Table({headers, rows}: TableProps): JSX.Element {
return (
<div className="rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
<div className="max-w-full overflow-x-auto">
<table className="w-full table-auto">
<thead>
<tr className="bg-gray-2 text-left dark:bg-meta-4">
{headers.map((header, index) => (
<th key={index} className="min-w-[150px] px-4 py-4 font-medium text-black dark:text-white">
{header}
</th>
))}
</tr>
</thead>
<tbody>
{rows.map((row, rowIndex) => (
<tr key={rowIndex} className="border-b border-[#eee] dark:border-strokedark">
{row.map((col, colIndex) => (
<td key={`r${rowIndex}c${colIndex}`} className="px-4 py-5 dark:border-strokedark">
{col}
</td>
))}
</tr>
))}
</tbody>
</table>
</div>
</div>
);
}
Loading