Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 10 additions & 67 deletions apps/frontend/components/TableDisplay/TableDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
Typography,
} from '@mui/material';
Expand All @@ -18,72 +17,9 @@ import { ValidationLinkButton } from 'components/FormValidation/ValidationIndica
import { useAuth } from 'context/auth';

import { formatDate } from '../../utils/date';
import { BatchEditDialog, BatchEditWarningTooltip } from './BatchEditControls';
import { TableHeader } from './TableHeader';
import { BasicFloodForm, formatForms } from './utils';

const TableHeader = ({
isFlood,
batchEditMode,
handleBatchEditClick,
selectedForms,
handleEditFloodNumber,
lastCheckboxPosition,
}: {
isFlood: boolean;
batchEditMode: boolean;
handleBatchEditClick: () => void;
selectedForms: BasicFloodForm[];
handleEditFloodNumber: (newFloodNumber: number) => void;
lastCheckboxPosition: { top: number; left: number } | null;
setSelectedForms: (forms: BasicFloodForm[]) => void;
}) => (
<TableHead>
<TableRow sx={{ backgroundColor: 'var(--color_table_1)', color: 'black' }}>
<TableCell sx={{ color: 'inherit' }}>
<FormattedMessage id="forms_table.headers.province" />
</TableCell>
<TableCell sx={{ color: 'inherit' }}>
<FormattedMessage id="forms_table.headers.district" />
</TableCell>
<TableCell sx={{ color: 'inherit' }}>
<FormattedMessage id="forms_table.headers.commune" />
</TableCell>
<TableCell sx={{ color: 'inherit' }}>
<FormattedMessage id="forms_table.headers.dis_date" />
</TableCell>
<TableCell sx={{ color: 'inherit', minWidth: '110px' }}>
<FormattedMessage id="forms_table.headers.entry_date" />
</TableCell>
<TableCell sx={{ color: 'inherit' }}>
<FormattedMessage id="forms_table.headers.dis_type" />
</TableCell>
{isFlood && (
<TableCell sx={{ color: 'inherit', minWidth: '90px' }}>
{batchEditMode && <BatchEditWarningTooltip />}
<FormattedMessage id="forms_table.headers.flood_number" />
<br />
<BatchEditDialog
batchEditMode={batchEditMode}
selectedForms={selectedForms}
handleBatchEditClick={handleBatchEditClick}
handleEditFloodNumber={handleEditFloodNumber}
lastCheckboxPosition={lastCheckboxPosition}
/>
</TableCell>
)}
<TableCell sx={{ color: 'inherit' }}>
<FormattedMessage id="forms_table.headers.entry_name" />
</TableCell>
<TableCell sx={{ color: 'inherit', minWidth: '120px' }}>
<FormattedMessage id="forms_table.headers.phone" />
</TableCell>
<TableCell sx={{ color: 'inherit', minWidth: '200px' }}>
<FormattedMessage id="forms_table.headers.review_link" />
</TableCell>
</TableRow>
</TableHead>
);

export const TableDisplay = ({
forms,
isLoading,
Expand Down Expand Up @@ -149,6 +85,12 @@ export const TableDisplay = ({

return (
<>
<Typography sx={{ mx: 2, mt: 2 }}>
<FormattedMessage
id="forms_table.results_count"
values={{ count: formattedForms.length }}
/>
</Typography>
Comment thread
Copilot marked this conversation as resolved.
Outdated
<TableContainer
component={Paper}
sx={{ m: 2, width: 'calc(100% - 32px)' }}
Expand All @@ -167,16 +109,17 @@ export const TableDisplay = ({
<TableBody>
{[1, 2, 3].map(id => (
<TableRow key={id}>
<TableCell colSpan={isFlood ? 10 : 9}>
<TableCell colSpan={isFlood ? 11 : 10}>
<Skeleton />
</TableCell>
</TableRow>
))}
</TableBody>
) : (
<TableBody>
{formattedForms.map(formattedForm => (
{formattedForms.map((formattedForm, index) => (
<TableRow key={formattedForm.id}>
<TableCell>{index + 1}</TableCell>
<TableCell>
<FormattedMessage
id={`province.${formattedForm.province}`}
Expand Down
71 changes: 71 additions & 0 deletions apps/frontend/components/TableDisplay/TableHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { TableCell, TableHead, TableRow } from '@mui/material';
import { FormattedMessage } from 'react-intl';

import { BatchEditDialog, BatchEditWarningTooltip } from './BatchEditControls';
import { BasicFloodForm } from './utils';

export const TableHeader = ({
isFlood,
batchEditMode,
handleBatchEditClick,
selectedForms,
handleEditFloodNumber,
lastCheckboxPosition,
}: {
isFlood: boolean;
batchEditMode: boolean;
handleBatchEditClick: () => void;
selectedForms: BasicFloodForm[];
handleEditFloodNumber: (newFloodNumber: number) => void;
lastCheckboxPosition: { top: number; left: number } | null;
setSelectedForms: (forms: BasicFloodForm[]) => void;
}): JSX.Element => (
Comment thread
Copilot marked this conversation as resolved.
<TableHead>
<TableRow sx={{ backgroundColor: 'var(--color_table_1)', color: 'black' }}>
<TableCell sx={{ color: 'inherit' }}>
<FormattedMessage id="forms_table.headers.row_number" />
</TableCell>
<TableCell sx={{ color: 'inherit' }}>
<FormattedMessage id="forms_table.headers.province" />
</TableCell>
<TableCell sx={{ color: 'inherit' }}>
<FormattedMessage id="forms_table.headers.district" />
</TableCell>
<TableCell sx={{ color: 'inherit' }}>
<FormattedMessage id="forms_table.headers.commune" />
</TableCell>
<TableCell sx={{ color: 'inherit' }}>
<FormattedMessage id="forms_table.headers.dis_date" />
</TableCell>
<TableCell sx={{ color: 'inherit', minWidth: '110px' }}>
<FormattedMessage id="forms_table.headers.entry_date" />
</TableCell>
<TableCell sx={{ color: 'inherit' }}>
<FormattedMessage id="forms_table.headers.dis_type" />
</TableCell>
{isFlood && (
<TableCell sx={{ color: 'inherit', minWidth: '90px' }}>
{batchEditMode && <BatchEditWarningTooltip />}
<FormattedMessage id="forms_table.headers.flood_number" />
<br />
<BatchEditDialog
batchEditMode={batchEditMode}
selectedForms={selectedForms}
handleBatchEditClick={handleBatchEditClick}
handleEditFloodNumber={handleEditFloodNumber}
lastCheckboxPosition={lastCheckboxPosition}
/>
</TableCell>
)}
<TableCell sx={{ color: 'inherit' }}>
<FormattedMessage id="forms_table.headers.entry_name" />
</TableCell>
<TableCell sx={{ color: 'inherit', minWidth: '120px' }}>
<FormattedMessage id="forms_table.headers.phone" />
</TableCell>
<TableCell sx={{ color: 'inherit', minWidth: '200px' }}>
<FormattedMessage id="forms_table.headers.review_link" />
</TableCell>
</TableRow>
</TableHead>
);
2 changes: 2 additions & 0 deletions apps/frontend/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@
},
"forms_table": {
"no_forms": "No forms match your search parameters.",
"results_count": "{count, plural, one {# record} other {# records}} found",
"headers": {
"row_number": "#",
"location": "Location",
"province": "Province",
"district": "District / Krong",
Expand Down
4 changes: 3 additions & 1 deletion apps/frontend/translations/km.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"onHold-normal": "របាយការណ៍ដែលមិនទាន់ឯកភាព",
"approved-long": "របាយការណ៌បានឯកភាពរួច",
"notApproved-long": "របាយការណ៌៍ត្រូវបានបដិសេធ",
"onHold-long": "របាយការណ៌បានឯកភាពរួច"
"onHold-long": "របាយការណ៍ដែលមិនទាន់ឯកភាព"
},
"navigation": {
"home": "ទំព័រដើម",
Expand Down Expand Up @@ -122,7 +122,9 @@
},
"forms_table": {
"no_forms": "គ្មានទម្រង់ដែលត្រូវគ្នានឹងប៉ារ៉ាម៉ែត្រស្វែងរករបស់អ្នកទេ។",
"results_count": "{count, plural, one {# កំណត់ត្រា} other {# កំណត់ត្រា}} បានរកឃើញ",
"headers": {
"row_number": "#",
"location": "ទីតាំង",
"province": "ខេត្ត",
"district": "ស្រុក",
Expand Down
Loading