From da9975253643e1c44116869c62f9967a8d14559a Mon Sep 17 00:00:00 2001 From: Sophie Labyt Date: Thu, 10 Oct 2024 15:30:10 +0200 Subject: [PATCH] style components --- src/admin/users/oauth/OauthTable.tsx | 2 +- src/admin/users/roles/Roles.tsx | 30 +++++++++++++--------------- src/content/ContentRoot.tsx | 2 +- src/import/create/CreateRoot.tsx | 15 +++++++------- src/import/create/TagTable.tsx | 6 ++++-- src/query/QueryRoot.tsx | 16 ++++++++------- src/query/ResultsTable.tsx | 24 ++++++++++++++++------ src/query/SeriesTable.tsx | 2 +- 8 files changed, 56 insertions(+), 41 deletions(-) diff --git a/src/admin/users/oauth/OauthTable.tsx b/src/admin/users/oauth/OauthTable.tsx index 455b81e7..d67ab361 100644 --- a/src/admin/users/oauth/OauthTable.tsx +++ b/src/admin/users/oauth/OauthTable.tsx @@ -41,7 +41,7 @@ const OauthTable = ({ data = [], onDelete }: Oauth2TableProps) => { } ] return ( -
+
{ const { toastSuccess, toastError } = useCustomToast(); const { confirm } = useConfirm(); - const [showRoleForm, setShowRoleForm] = useState<'create' | 'edit' | null>(null); + const [showCreateRoleForm, setShowCreateRoleForm] = useState(false); const [roleToEdit, setRoleToEdit] = useState(null); const { data: roles, isPending: isLoadingRoles } = useCustomQuery( @@ -43,7 +43,6 @@ const Roles = () => { const handleEditRole = (roleName: string) => { const role = findRole(roleName); setRoleToEdit(role); - setShowRoleForm('edit'); }; const deleteRoleHandler = async (roleName: string) => { @@ -68,32 +67,31 @@ const Roles = () => { onDelete={deleteRoleHandler} /> - {showRoleForm === 'edit' && ( + {roleToEdit && ( { setShowRoleForm(null); setRoleToEdit(null); }} + className="px-4 mb-4 bg-gray-200" onClose={() => setRoleToEdit(null)} role={roleToEdit || undefined} /> )} - -
- {!showRoleForm ? ( + {/* Added mt-4 for extra spacing */}
+ {showCreateRoleForm && ( + setShowCreateRoleForm(false)} + /> + )} + {!showCreateRoleForm && ( - ) : ( - setShowRoleForm(null)} - /> )}
@@ -101,4 +99,4 @@ const Roles = () => { ); }; -export default Roles; +export default Roles; \ No newline at end of file diff --git a/src/content/ContentRoot.tsx b/src/content/ContentRoot.tsx index c3385de8..b9b8673c 100644 --- a/src/content/ContentRoot.tsx +++ b/src/content/ContentRoot.tsx @@ -164,7 +164,7 @@ const ContentRoot: React.FC = () => {
); diff --git a/src/query/QueryRoot.tsx b/src/query/QueryRoot.tsx index d6543a10..6f5ca362 100644 --- a/src/query/QueryRoot.tsx +++ b/src/query/QueryRoot.tsx @@ -89,7 +89,7 @@ const QueryRoot = ({ className }: QueryFormProps) => { /> - {/* Section for results */} + {/* Section for results and series tables */}
Results
@@ -97,13 +97,15 @@ const QueryRoot = ({ className }: QueryFormProps) => { {studies.length} {studies.length === 1 ? "study" : "studies"} found
- - -
-
-
- + +
+
+ +
+
+ +
); diff --git a/src/query/ResultsTable.tsx b/src/query/ResultsTable.tsx index 5ee1d3fe..869d67bd 100644 --- a/src/query/ResultsTable.tsx +++ b/src/query/ResultsTable.tsx @@ -3,7 +3,7 @@ import { ColumnDef } from "@tanstack/react-table"; import { QueryResponse } from "../utils/types"; import { Colors } from "../utils"; import RetrieveButton from './RetrieveButton'; -import { useMemo } from "react"; +import { useMemo, useState } from "react"; type ResultsTableProps = { results: QueryResponse[] | null; @@ -11,6 +11,7 @@ type ResultsTableProps = { }; const ResultsTable = ({ results, onRowClick }: ResultsTableProps) => { + const [selectedRows, setSelectedRows] = useState>({}); const rows = useMemo(() => results, [results]); const columns: ColumnDef[] = useMemo(() => [ @@ -38,9 +39,7 @@ const ResultsTable = ({ results, onRowClick }: ResultsTableProps) => { header: "Retrieve", cell: ({ row }: { row: any }) => { return ( -
+
{ } }, ], []); - - const handleRowClick = (row: any) => { + + const handleRowClick = (row: QueryResponse) => { onRowClick(row.studyInstanceUID, row.originAET); + setSelectedRows(prev => ({ + ...prev, + [row.studyInstanceUID]: !prev[row.studyInstanceUID] // Toggle selection + })); }; + + const getRowClasses = (row: QueryResponse) => { + if (selectedRows[row.studyInstanceUID]) { + return 'bg-primary hover:cursor-pointer'; + } + return 'hover:bg-indigo-100 hover:cursor-pointer'; + }; + return (
{ columns={columns} data={rows ?? []} headerTextSize="xs" - headerColor={Colors.almond} + headerColor={Colors.light} className="text-xs bg-gray-100"