Skip to content

Commit

Permalink
style components
Browse files Browse the repository at this point in the history
  • Loading branch information
SophieLab committed Oct 10, 2024
1 parent 23fc1fa commit da99752
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/admin/users/oauth/OauthTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const OauthTable = ({ data = [], onDelete }: Oauth2TableProps) => {
}
]
return (
<div className="pb-6 mx-5 mt-4">
<div className="pb-6 mx-5">
<Table
data={data}
columns={columns}
Expand Down
30 changes: 14 additions & 16 deletions src/admin/users/roles/Roles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Roles = () => {
const { toastSuccess, toastError } = useCustomToast();
const { confirm } = useConfirm();

const [showRoleForm, setShowRoleForm] = useState<'create' | 'edit' | null>(null);
const [showCreateRoleForm, setShowCreateRoleForm] = useState(false);
const [roleToEdit, setRoleToEdit] = useState<Role | null>(null);

const { data: roles, isPending: isLoadingRoles } = useCustomQuery<Role[]>(
Expand Down Expand Up @@ -43,7 +43,6 @@ const Roles = () => {
const handleEditRole = (roleName: string) => {
const role = findRole(roleName);
setRoleToEdit(role);
setShowRoleForm('edit');
};

const deleteRoleHandler = async (roleName: string) => {
Expand All @@ -68,37 +67,36 @@ const Roles = () => {
onDelete={deleteRoleHandler}
/>

{showRoleForm === 'edit' && (
{roleToEdit && (
<EditRole
key={roleToEdit?.name}
title={"Edit Role"}
className="bg-gray-200"
onClose={() => { setShowRoleForm(null); setRoleToEdit(null); }}
className="px-4 mb-4 bg-gray-200" onClose={() => setRoleToEdit(null)}
role={roleToEdit || undefined}
/>
)}

<CardFooter className="p-0 border-t rounded-b-lg bg-light">
<div className="flex justify-center w-full">
{!showRoleForm ? (
<CardFooter className="p-0 mt-4 border-t rounded-b-lg bg-light"> {/* Added mt-4 for extra spacing */} <div className="flex justify-center w-full">
{showCreateRoleForm && (
<CreateRole
title={"Create Role"}
className="w-full p-4"
onClose={() => setShowCreateRoleForm(false)}
/>
)}
{!showCreateRoleForm && (
<Button
color={Colors.success}
onClick={() => setShowRoleForm('create')}
onClick={() => setShowCreateRoleForm(true)}
className="flex justify-center gap-4 mt-4 mb-4 w-52 hover:successHover"
>
Create Role
</Button>
) : (
<CreateRole
title={"Create Role"}
className="w-full p-4"
onClose={() => setShowRoleForm(null)}
/>
)}
</div>
</CardFooter>
</div>
);
};

export default Roles;
export default Roles;
2 changes: 1 addition & 1 deletion src/content/ContentRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const ContentRoot: React.FC = () => {

<div className="flex flex-wrap gap-2 mb-4">
<Button
color={Colors.primary}
color={Colors.blueCustom}
className="flex items-center text-sm transition-transform duration-200 bg-blue-700 hover:scale-105"
onClick={handleSendAnonymizeList}
>
Expand Down
15 changes: 8 additions & 7 deletions src/import/create/CreateRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,22 @@ const CreateRoot: React.FC = () => {

return (
<>
<div className="w-full space-y-3 md:flex md:space-x-3 p-6">
<div className="w-full p-6 space-y-3 md:flex md:space-x-3">
<CreateDrop files={files} onDrop={handleFilesUploaded} />
</div>

<div className="flex flex-col justify-center border-indigo-100 shadow-inner p-3 bg-light">
<div className="flex flex-col justify-center p-3 border-indigo-100 shadow-inner bg-light">
<CreateForm
title="Define DICOM Tags"
onAddTag={handleAddTag}
/>
<TagTable
data={tags}
onDeleteTag={handleTagDelete}
/>
<CreateForm
title="Define DICOM Tags"
onAddTag={handleAddTag}
/>

</div>
<div className="flex bg-white justify-center p-3">
<div className="flex justify-center p-3 bg-white">
<Button
color={tags.length > 0 ? Colors.primary : Colors.almond}
onClick={handleCreateDicoms}
Expand Down
6 changes: 4 additions & 2 deletions src/import/create/TagTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const TagTable: React.FC<TagTableProps> = ({ data, onDeleteTag }) => {
id: 'delete',
header: 'Actions',
cell: ({ row }) => (
<div className='w-full flex justify-center'>
<div className='flex justify-center w-full'>
<DeleteButton
onClick={() => onDeleteTag(row.original.name)}
/>
Expand All @@ -36,11 +36,13 @@ const TagTable: React.FC<TagTableProps> = ({ data, onDeleteTag }) => {
return (
<div className="w-full mt-4">
<Table
headerColor={Colors.warning}
headerColor={Colors.light}
columns={columns}
data={data}
className="bg-gray-100"
enableSorting


/>
</div>
);
Expand Down
16 changes: 9 additions & 7 deletions src/query/QueryRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,23 @@ const QueryRoot = ({ className }: QueryFormProps) => {
/>
</FormCard>

{/* Section for results */}
{/* Section for results and series tables */}
<div className="flex flex-col w-full p-4 bg-white shadow-md rounded-3xl">
<div className="flex items-center justify-between mb-4">
<div className="text-2xl font-bold text-primary">Results</div>
<div className="text-lg text-gray-600">
{studies.length} {studies.length === 1 ? "study" : "studies"} found
</div>
</div>

</div>
<div className="2xl:col-span-7">
<ResultsTable results={studies} onRowClick={handleRowClick} />
</div>
<div className="2xl:col-span-5">
<SeriesTable series={series} />

<div className="grid grid-cols-1 gap-4 2xl:grid-cols-2">
<div className="2xl:col-span-1">
<ResultsTable results={studies} onRowClick={handleRowClick} />
</div>
<div className="2xl:col-span-1">
<SeriesTable series={series} />
</div>
</div>
</div>
);
Expand Down
24 changes: 18 additions & 6 deletions src/query/ResultsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ 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;
onRowClick: (studyInstanceUID: string, originAET: string) => void;
};

const ResultsTable = ({ results, onRowClick }: ResultsTableProps) => {
const [selectedRows, setSelectedRows] = useState<Record<string, boolean>>({});
const rows = useMemo(() => results, [results]);

const columns: ColumnDef<QueryResponse>[] = useMemo(() => [
Expand Down Expand Up @@ -38,9 +39,7 @@ const ResultsTable = ({ results, onRowClick }: ResultsTableProps) => {
header: "Retrieve",
cell: ({ row }: { row: any }) => {
return (
<div
className="flex justify-center"
>
<div className="flex justify-center">
<RetrieveButton
answerId={row.original.answerId}
answerNumber={row.original.answerNumber}
Expand All @@ -50,16 +49,29 @@ const ResultsTable = ({ results, onRowClick }: ResultsTableProps) => {
}
},
], []);
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 (
<Table
columns={columns}
data={rows ?? []}
enableColumnFilters={true}
onRowClick={handleRowClick}
getRowClasses={getRowClasses}
headerTextSize="xs"
headerColor={Colors.white}
className="bg-gray-100"
Expand Down
2 changes: 1 addition & 1 deletion src/query/SeriesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const SeriesTable = ({ series }: SeriesTableProps) => {
columns={columns}
data={rows ?? []}
headerTextSize="xs"
headerColor={Colors.almond}
headerColor={Colors.light}
className="text-xs bg-gray-100"


Expand Down

0 comments on commit da99752

Please sign in to comment.