Skip to content

Commit

Permalink
Various UI tweaks (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
denniskigen authored Nov 30, 2023
1 parent 94ccfd8 commit 21d2703
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import React from 'react';
import { useTranslation } from 'react-i18next';
import BillingHeader from '../billing-header/billing-header.component';
import MetricsCards from '../metrics-cards/metrics-cards.component';
import styles from './billing-dashboard.scss';
import BillsTable from '../bills-table/bills-table.component';
import styles from './billing-dashboard.scss';

export function BillingDashboard() {
const { t } = useTranslation();

return (
<>
<main className={styles.container}>
<BillingHeader title={t('home', 'Home')} />
<MetricsCards />
<main className={styles.container}>
<main className={styles.billsTableContainer}>
<BillsTable />
</main>
</>
</main>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
@use '@carbon/type';

.container {
height: calc(100vh - 3rem);
}

.billsTableContainer {
margin: 2rem 1rem;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const BillsTable = () => {
<FilterableTableHeader
handleSearch={handleSearch}
isValidating={isValidating}
layout={layout}
responsiveSize={responsiveSize}
t={t}
/>
Expand Down Expand Up @@ -148,6 +149,7 @@ const BillsTable = () => {
<FilterableTableHeader
handleSearch={handleSearch}
isValidating={isValidating}
layout={layout}
responsiveSize={responsiveSize}
t={t}
/>
Expand All @@ -159,7 +161,7 @@ const BillsTable = () => {
useZebraStyles={rowData?.length > 1 ? true : false}>
{({ rows, headers, getRowProps, getTableProps }) => (
<TableContainer>
<Table {...getTableProps()} aria-label="sample table">
<Table {...getTableProps()} aria-label="bill list">
<TableHead>
<TableRow>
{headers.map((header) => (
Expand Down Expand Up @@ -232,11 +234,7 @@ const BillsTable = () => {
);
};

export default BillsTable;

function FilterableTableHeader({ handleSearch, isValidating, responsiveSize, t }) {
const layout = useLayoutType();

function FilterableTableHeader({ layout, handleSearch, isValidating, responsiveSize, t }) {
return (
<>
<div className={styles.headerContainer}>
Expand All @@ -260,3 +258,5 @@ function FilterableTableHeader({ handleSearch, isValidating, responsiveSize, t }
</>
);
}

export default BillsTable;
1 change: 1 addition & 0 deletions packages/esm-billing-app/src/bills-table/bills-table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
.billListContainer {
background-color: $ui-02;
border: 1px solid $ui-03;
border-bottom: none;
width: 100%;
margin: 0 auto;
max-width: 95vw;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { useConfig, usePagination } from '@openmrs/esm-framework';
import { fireEvent, render, screen } from '@testing-library/react';
import { useBills } from '../billing.resource';
import BillsTable from './bills-table.component';

Expand Down
24 changes: 0 additions & 24 deletions packages/esm-billing-app/src/invoice/invoce.component.tsx

This file was deleted.

80 changes: 80 additions & 0 deletions packages/esm-billing-app/src/invoice/invoice.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React from 'react';
import { Button, InlineLoading } from '@carbon/react';
import { ArrowLeft } from '@carbon/react/icons';
import { ExtensionSlot, isDesktop, navigate, useLayoutType, usePatient } from '@openmrs/esm-framework';
import { useParams } from 'react-router-dom';
import styles from './invoice.scss';

type InvoiceProps = {};

const Invoice: React.FC<InvoiceProps> = () => {
const params = useParams();
const layout = useLayoutType();
const { patient, patientUuid, isLoading } = usePatient(params?.patientUuid);

const invoiceDetails = {
'Invoice Number': '#105986',
'Billing Date & Time': 'Thu 04 Nov, 2023 01:20 pm',
'Total Amount': 'Ksh. 1000',
'Invoice Status': 'Pending',
};

const navigateToDashboard = () =>
navigate({
to: window.getOpenmrsSpaBase() + 'home/billing',
});

if (isLoading) {
return (
<div className={styles.invoiceContainer}>
<InlineLoading
className={styles.loader}
status="active"
iconDescription="Loading"
description="Loading patient header..."
/>
</div>
);
}

return (
<div className={styles.invoiceContainer}>
<ExtensionSlot name="patient-header-slot" state={{ patient, patientUuid }} />

<section className={styles.details}>
{Object.entries(invoiceDetails).map(([label, value]) => (
<InvoiceDetails key={label} label={label} value={value} />
))}
</section>

{isDesktop(layout) && (
<div className={styles.backButton}>
<Button
kind="ghost"
renderIcon={(props) => <ArrowLeft size={24} {...props} />}
iconDescription="Return to billing dashboard"
size="sm"
onClick={navigateToDashboard}>
<span>Back to dashboard</span>
</Button>
</div>
)}
</div>
);
};

interface InvoiceDetailsProps {
label: string;
value: string;
}

function InvoiceDetails({ label, value }: InvoiceDetailsProps) {
return (
<div>
<h1 className={styles.label}>{label}</h1>
<span className={styles.value}>{value}</span>
</div>
);
}

export default Invoice;
48 changes: 47 additions & 1 deletion packages/esm-billing-app/src/invoice/invoice.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,52 @@
@use '@carbon/colors';
@use '@carbon/layout';
@use '@carbon/type';

.invoiceContainer {
margin: layout.$spacing-03 layout.$spacing-05;
background-color: colors.$gray-10;
height: calc(100vh - 3rem);
}

.loader {
display: flex;
min-height: layout.$spacing-09;
justify-content: center;
}

.details {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
margin: layout.$spacing-05;
}

.label {
@include type.type-style('body-compact-02');
color: colors.$gray-70;
}

.value {
@include type.type-style('heading-03');
display: inline-block;
margin-top: layout.$spacing-04;
}

.backButton {
margin: layout.$spacing-04;

button {
display: flex;
padding-left: 0 !important;

svg {
order: 1;
margin-right: layout.$spacing-03;
margin-left: 0 !important;
}

span {
order: 2;
}
}
}
11 changes: 10 additions & 1 deletion packages/esm-billing-app/src/left-panel-link.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ function LinkExtension({ config }: { config: LinkConfig }) {
const location = useLocation();
const spaBasePath = window.getOpenmrsSpaBase() + 'home';

const urlSegment = useMemo(() => decodeURIComponent(last(location.pathname.split('/'))), [location.pathname]);
let urlSegment = useMemo(() => decodeURIComponent(last(location.pathname.split('/'))), [location.pathname]);

const isUUID = (value) => {
const regex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/;
return regex.test(value);
};

if (isUUID(urlSegment)) {
urlSegment = 'billing';
}

return (
<ConfigurableLink
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-billing-app/src/root.component.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import { BillingDashboard } from './billing-dashboard/billing-dashboard.component';
import Invoice from './invoice/invoce.component';
import Invoice from './invoice/invoice.component';

const RootComponent: React.FC = () => {
const baseName = window.getOpenmrsSpaBase() + 'home/billing';
Expand Down

0 comments on commit 21d2703

Please sign in to comment.