From 5341d638c730929bcf46ae7e7b0f8fc23252bb54 Mon Sep 17 00:00:00 2001 From: Armin Talaie Date: Sat, 28 Dec 2024 01:14:18 -0800 Subject: [PATCH] updated admin dashboard --- src/app/portal/admin/forms/[id]/layout.tsx | 4 + .../forms/[id]/submissions/AnalyticsPage.tsx | 2 +- .../admin/forms/[id]/submissions/columns.tsx | 5 +- .../forms/[id]/submissions/data-table.tsx | 104 ++++++++++++------ .../[id]/submissions/dataTableWrapper.tsx | 6 +- .../forms/[id]/submissions/formDataChart.tsx | 2 +- .../admin/forms/[id]/submissions/page.tsx | 10 +- .../forms/[id]/{user => support}/page.tsx | 87 +++++++++------ src/app/portal/loading.tsx | 2 +- src/components/layouts/formTabView.tsx | 10 +- src/components/primitives/table.tsx | 14 +-- 11 files changed, 151 insertions(+), 95 deletions(-) rename src/app/portal/admin/forms/[id]/{user => support}/page.tsx (56%) diff --git a/src/app/portal/admin/forms/[id]/layout.tsx b/src/app/portal/admin/forms/[id]/layout.tsx index 9a32bd6f..5dee4b14 100644 --- a/src/app/portal/admin/forms/[id]/layout.tsx +++ b/src/app/portal/admin/forms/[id]/layout.tsx @@ -17,6 +17,10 @@ export default async function Layout({ label: "Submissions", route: `/portal/admin/forms/${params.id}/submissions`, }, + { + label: "Support", + route: `/portal/admin/forms/${params.id}/support`, + }, ]; return ( diff --git a/src/app/portal/admin/forms/[id]/submissions/AnalyticsPage.tsx b/src/app/portal/admin/forms/[id]/submissions/AnalyticsPage.tsx index fe5495e6..01a8d0dd 100644 --- a/src/app/portal/admin/forms/[id]/submissions/AnalyticsPage.tsx +++ b/src/app/portal/admin/forms/[id]/submissions/AnalyticsPage.tsx @@ -21,7 +21,7 @@ export default function AnalyticsPage({ }); return ( -
+
{data.analyticsData.map((chartData, index) => ( ( return [ { accessorKey: "popover", - header: "Actions", + header: "", enableColumnFilter: false, size: 300, maxSize: 300, cell: ({ row }) => { return ( -
+
diff --git a/src/app/portal/admin/forms/[id]/submissions/data-table.tsx b/src/app/portal/admin/forms/[id]/submissions/data-table.tsx index 2161df7e..51c2d65f 100644 --- a/src/app/portal/admin/forms/[id]/submissions/data-table.tsx +++ b/src/app/portal/admin/forms/[id]/submissions/data-table.tsx @@ -31,7 +31,31 @@ import { } from "@/app/portal/admin/forms/[id]/submissions/columns"; import MultiSelect from "@/components/general/multiSelect"; -const getCommonPinningStyles = (column: Column): CSSProperties => { +// const getCommonPinningStyles = (column: Column): CSSProperties => { +// const isPinned = column.getIsPinned(); +// const isLastLeftPinnedColumn = +// isPinned === "left" && column.getIsLastColumn("left"); +// const isFirstRightPinnedColumn = +// isPinned === "right" && column.getIsFirstColumn("right"); + +// return { +// ...(isLastLeftPinnedColumn +// ? { borderRight: `1px solid var(--background-500)` } +// : {}), +// ...(isFirstRightPinnedColumn +// ? { borderLeft: `1px solid var(--background-500)` } +// : {}), +// left: isPinned === "left" ? `${column.getStart("left")}px` : undefined, +// right: isPinned === "right" ? `${column.getAfter("right")}px` : undefined, +// opacity: isPinned ? 0.95 : 1, +// position: isPinned ? "sticky" : "relative", +// width: column.getSize() ? column.getSize() : "500px", +// zIndex: isPinned ? 1 : 0, +// maxWidth: column.getSize() ? column.getSize() : "500px", +// }; +// }; + +const getCommonPinningStyles = (column: Column): CSSProperties => { const isPinned = column.getIsPinned(); const isLastLeftPinnedColumn = isPinned === "left" && column.getIsLastColumn("left"); @@ -39,19 +63,13 @@ const getCommonPinningStyles = (column: Column): CSSProperties => { isPinned === "right" && column.getIsFirstColumn("right"); return { - ...(isLastLeftPinnedColumn - ? { borderRight: `1px solid var(--background-500)` } - : {}), - ...(isFirstRightPinnedColumn - ? { borderLeft: `1px solid var(--background-500)` } - : {}), + boxShadow: undefined, left: isPinned === "left" ? `${column.getStart("left")}px` : undefined, right: isPinned === "right" ? `${column.getAfter("right")}px` : undefined, opacity: isPinned ? 0.95 : 1, position: isPinned ? "sticky" : "relative", - width: column.getSize() ? column.getSize() : "500px", - // zIndex: isPinned ? 1 : 0, - maxWidth: column.getSize() ? column.getSize() : "500px", + width: column.getSize(), + zIndex: isPinned ? 1 : 0, }; }; @@ -81,6 +99,9 @@ export function DataTable({ debugColumns: false, enableColumnFilters: true, state: { + // columnPinning: { + // left: ["popover"], + // }, columnFilters, columnVisibility, sorting, @@ -89,34 +110,25 @@ export function DataTable({ }); return ( -
+
{table.getFilteredRowModel().rows.length} {"Results"}
- {config.view?.showFilter && ( - [] - } - columnFilters={columnFilters} - setColumnFilters={setColumnFilters} - /> - )}
)}
+ {config.view?.showFilter && ( + [] + } + columnFilters={columnFilters} + setColumnFilters={setColumnFilters} + /> + )}
{table.getFilteredRowModel().rows.length > 0 && tabView === "chart" && ( @@ -144,19 +167,21 @@ export function DataTable({ .rows.map((row) => row.original)} /> )} - {tabView === "table" && ( -
- - +
+
+ {table.getHeaderGroups().map((headerGroup) => ( - + {headerGroup.headers.map((header) => { return ( ))} - + {table.getRowModel().rows?.length ? ( table.getRowModel().rows.map((row) => ( ({ {row.getVisibleCells().map((cell) => (
@@ -172,12 +197,12 @@ export function DataTable({
{flexRender( @@ -232,7 +257,8 @@ function TableFilter({ ; + return ( + + ); }; diff --git a/src/app/portal/admin/forms/[id]/submissions/dataTableWrapper.tsx b/src/app/portal/admin/forms/[id]/submissions/dataTableWrapper.tsx index e994b996..2b8dac6e 100644 --- a/src/app/portal/admin/forms/[id]/submissions/dataTableWrapper.tsx +++ b/src/app/portal/admin/forms/[id]/submissions/dataTableWrapper.tsx @@ -9,7 +9,7 @@ import { ReferenceMap, } from "@/app/portal/admin/forms/[id]/submissions/columns"; import useApplicantPopover from "@/components/forms/applications/applicantPopover"; -import { useContext } from "react"; +import { Fragment, useContext } from "react"; import { formContext } from "@/components/layouts/formTabView"; export type DataTableProps = { @@ -76,7 +76,7 @@ export default function DataTableWrapper({ }; return ( -
+ {applicantPopover} ({ refMap={refMap} config={config} /> -
+ ); } diff --git a/src/app/portal/admin/forms/[id]/submissions/formDataChart.tsx b/src/app/portal/admin/forms/[id]/submissions/formDataChart.tsx index 947bf275..9ccef9ca 100644 --- a/src/app/portal/admin/forms/[id]/submissions/formDataChart.tsx +++ b/src/app/portal/admin/forms/[id]/submissions/formDataChart.tsx @@ -32,7 +32,7 @@ export function FormChart({ }); return ( - + {chartInfo.title} diff --git a/src/app/portal/admin/forms/[id]/submissions/page.tsx b/src/app/portal/admin/forms/[id]/submissions/page.tsx index 21c51957..7f777105 100644 --- a/src/app/portal/admin/forms/[id]/submissions/page.tsx +++ b/src/app/portal/admin/forms/[id]/submissions/page.tsx @@ -5,13 +5,5 @@ import { formContext } from "@/components/layouts/formTabView"; export default function FormSubmissionsPage() { const { formFields, submissions } = useContext(formContext); - return ( -
-
- - -
- ); + return ; } diff --git a/src/app/portal/admin/forms/[id]/user/page.tsx b/src/app/portal/admin/forms/[id]/support/page.tsx similarity index 56% rename from src/app/portal/admin/forms/[id]/user/page.tsx rename to src/app/portal/admin/forms/[id]/support/page.tsx index 67af7e7d..4e81ee67 100644 --- a/src/app/portal/admin/forms/[id]/user/page.tsx +++ b/src/app/portal/admin/forms/[id]/support/page.tsx @@ -8,6 +8,7 @@ import { useEffect, useState } from "react"; import { Application } from "@/lib/types/questions"; import ApplicationForm from "@/components/forms/applications/applicationForm"; import { Button } from "@/components/primitives/button"; +import { XIcon } from "lucide-react"; export default function SubmissionAsUser() { const [form, setForm] = useState
(null); @@ -20,6 +21,10 @@ export default function SubmissionAsUser() { init(); }, []); + if (!params || !params.id) { + return null; + } + async function init() { const form = await getForm(Number(params.id)); const submissions = await getSubmissions(Number(params.id), false); @@ -36,41 +41,59 @@ export default function SubmissionAsUser() { return (
- - - {app && form && ( -
-

{`${app.details.firstName || "User"}'s application`}

@@ -87,7 +110,7 @@ export default function SubmissionAsUser() { : "User has already submitted"}
-
+
+
diff --git a/src/components/layouts/formTabView.tsx b/src/components/layouts/formTabView.tsx index 58f5798b..be06ed88 100644 --- a/src/components/layouts/formTabView.tsx +++ b/src/components/layouts/formTabView.tsx @@ -61,7 +61,11 @@ export default function FormTabView({ mergeNewData, }} > -
+
-
+
{children}
diff --git a/src/components/primitives/table.tsx b/src/components/primitives/table.tsx index 1e3120a8..cace4351 100644 --- a/src/components/primitives/table.tsx +++ b/src/components/primitives/table.tsx @@ -6,13 +6,13 @@ const Table = React.forwardRef< HTMLTableElement, React.HTMLAttributes >(({ className, ...props }, ref) => ( -
- - + //
+
+ // )); Table.displayName = "Table";