Skip to content

Commit

Permalink
fix: ensure consistency with delete and archive option for various te…
Browse files Browse the repository at this point in the history
…mplates
  • Loading branch information
yogai53 committed Sep 5, 2024
1 parent 06ded59 commit 3405e78
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ function DefaultTemplatesTable(props: DefaultTemplatesTableProps) {
const { isArchived, templateGroup } = props;
const { api } = useDataApiWithFeedback();

const defaultIsRowRemovable = () => true;
const defaultIsRowRemovable = (rowData: TemplateRowDataType) =>
rowData.questionaryCount === 0;

// NOTE: Here we keep the columns inside the component just because of the itemCountLabel shown in the title
const defaultColumns: Column<TemplateRowDataType>[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ import { TemplateGroupId } from 'generated/sdk';
import { StyledContainer, StyledPaper } from 'styles/StyledComponents';

import DefaultTemplatesTable from './DefaultTemplatesTable';
import { TemplateRowDataType } from './TemplatesTable';

export default function GenericTemplatesPage() {
const templateGroup = TemplateGroupId.GENERIC_TEMPLATE;
const itemCountLabel = '# templates';
const isRowRemovable = (rowData: TemplateRowDataType) =>
rowData.questionaryCount === 0;

return (
<StyledContainer maxWidth={false}>
Expand All @@ -21,13 +18,11 @@ export default function GenericTemplatesPage() {
templateGroup={templateGroup}
itemCountLabel={itemCountLabel}
isArchived={false}
isRowRemovable={isRowRemovable}
/>
<DefaultTemplatesTable
templateGroup={templateGroup}
itemCountLabel={itemCountLabel}
isArchived={true}
isRowRemovable={isRowRemovable}
/>
</SimpleTabs>
</StyledPaper>
Expand Down
5 changes: 0 additions & 5 deletions apps/frontend/src/components/template/SampleTemplatesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ import { TemplateGroupId } from 'generated/sdk';
import { StyledContainer, StyledPaper } from 'styles/StyledComponents';

import DefaultTemplatesTable from './DefaultTemplatesTable';
import { TemplateRowDataType } from './TemplatesTable';

export default function SampleEsiPage() {
const templateGroup = TemplateGroupId.SAMPLE;
const itemCountLabel = '# samples';
const isRowRemovable = (rowData: TemplateRowDataType) =>
rowData.questionaryCount === 0;

return (
<StyledContainer maxWidth={false}>
Expand All @@ -21,13 +18,11 @@ export default function SampleEsiPage() {
templateGroup={templateGroup}
itemCountLabel={itemCountLabel}
isArchived={false}
isRowRemovable={isRowRemovable}
/>
<DefaultTemplatesTable
templateGroup={templateGroup}
itemCountLabel={itemCountLabel}
isArchived={true}
isRowRemovable={isRowRemovable}
/>
</SimpleTabs>
</StyledPaper>
Expand Down

0 comments on commit 3405e78

Please sign in to comment.