Skip to content

Commit

Permalink
update /search-sin and DataTable component (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fbasham authored Mar 5, 2025
1 parent dab6d2d commit ac0efc3
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 21 deletions.
14 changes: 12 additions & 2 deletions frontend/app/.server/locales/protected-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,24 @@
"parents-legal-guardians": "Parents/legal guardians",
"other-last-names": "Other last names",
"search": "Search",
"matches": "Matches"
"matches": "Matches",
"table": {
"headers": {
"full-name": "Full name",
"date-of-birth": "Date of birth",
"parent-surname": "Parent's birth surname",
"sin": "SIN",
"match": "Match"
}
}
},
"pid-verification": {
"page-title": "Validation result",
"status-passed": "Passed",
"validation-passed": "Validation passed",
"all-input-successful": "All inputs have been successfully validated and match the primary identity document.",
"next": "Next",
"previous": "Previous"
"previous": "Previous",
"matches": "Matches"
}
}
14 changes: 12 additions & 2 deletions frontend/app/.server/locales/protected-fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,24 @@
"parents-legal-guardians": "Parents/legal guardians",
"other-last-names": "Other last names",
"search": "Search",
"matches": "Matches"
"matches": "Matches",
"table": {
"headers": {
"full-name": "Full name",
"date-of-birth": "Date of birth",
"parent-surname": "Parent's birth surname",
"sin": "SIN",
"match": "Match"
}
}
},
"pid-verification": {
"page-title": "Validation result",
"status-passed": "Passed",
"validation-passed": "Validation passed",
"all-input-successful": "All inputs have been successfully validated and match the primary identity document.",
"next": "Next",
"previous": "Previous"
"previous": "Previous",
"matches": "Matches"
}
}
7 changes: 3 additions & 4 deletions frontend/app/components/data-table.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { ReactNode } from 'react';

type Row = (string | number | ReactNode)[];
type Table = { data: Row[] };

interface DataTableProps {
/**
Expand All @@ -12,7 +11,7 @@ interface DataTableProps {
/**
* 2D array of table data where each inner array represents a row
*/
table: Table;
rows: Row[];

/**
* Whether to apply alternating background colors to rows
Expand All @@ -21,7 +20,7 @@ interface DataTableProps {
striped?: boolean;
}

export function DataTable({ headers, table, striped = true }: DataTableProps) {
export function DataTable({ headers, rows, striped = true }: DataTableProps) {
return (
<div className="overflow-x-auto rounded-lg shadow">
<table className="min-w-full divide-y divide-gray-200">
Expand All @@ -35,7 +34,7 @@ export function DataTable({ headers, table, striped = true }: DataTableProps) {
</tr>
</thead>
<tbody className="divide-y divide-gray-200 bg-white">
{table.data.map((row, rowIndex) => (
{rows.map((row, rowIndex) => (
<tr key={rowIndex} className={striped && rowIndex % 2 === 1 ? 'bg-gray-50' : 'bg-white'}>
{row.map((cell, cellIndex) => (
<td key={cellIndex} className="px-6 py-4 text-sm whitespace-nowrap text-gray-900">
Expand Down
33 changes: 20 additions & 13 deletions frontend/app/routes/protected/multi-channel/search-sin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,16 @@ export function meta({ data }: Route.MetaArgs) {
export function action({ context, request }: Route.ActionArgs) {
requireAuth(context.session, new URL(request.url), ['user']);

//TODO: fetch and return mock table result data
const headers = ['Header 1', 'Header 2', 'Header 3', 'Header 4', 'Header 5'];
const data = [
['Data 1-1', 'Data 1-2', 'Data 1-3', 'Data 1-4', 'Data 1-5'],
['Data 2-1', 'Data 2-2', 'Data 2-3', 'Data 2-4', 'Data 2-5'],
['Data 3-1', 'Data 3-2', 'Data 3-3', 'Data 3-4', 'Data 3-5'],
['Data 4-1', 'Data 4-2', 'Data 4-3', 'Data 4-4', 'Data 4-5'],
];
//TODO: fetch and return mock table data
return {
tableResults: {
headers,
table: { data },
tableData: {
rows: [
['John Doe', 'January 1, 1980', 'Doe', '*** *** 000', '98%'],
['Johnathan Doe', 'February 10, 1985', 'Doe', '*** *** 000', '95%'],
['John D', 'March 15, 1990', 'N/A', '*** *** 000', '88%'],
['Johnny Doe', 'April 20, 1978', 'Doe', '*** *** 000', '92%'],
['J. Doe', 'May 25, 1992', 'Doe', '*** *** 000', '90%'],
],
},
};
}
Expand Down Expand Up @@ -89,10 +87,19 @@ export default function SearchSin({ loaderData, actionData, params }: Route.Comp
</div>
</div>

{fetcher.data?.tableResults && (
{fetcher.data?.tableData && (
<>
<h3 className="font-lato mb-4 text-xl font-semibold">{t('protected:search-sin.matches')}</h3>
<DataTable {...fetcher.data.tableResults} />
<DataTable
headers={[
t('protected:search-sin.table.headers.full-name'),
t('protected:search-sin.table.headers.date-of-birth'),
t('protected:search-sin.table.headers.parent-surname'),
t('protected:search-sin.table.headers.sin'),
t('protected:search-sin.table.headers.match'),
]}
rows={fetcher.data.tableData.rows}
/>
</>
)}
</div>
Expand Down

0 comments on commit ac0efc3

Please sign in to comment.