Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/pages/Bugs/BugsTable/AllBugs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { useTranslation } from 'react-i18next';
import { useAppDispatch } from 'src/app/hooks';
import { theme } from 'src/app/theme';
import Table, { ColumnDefinitionType } from 'src/common/components/Table';
import { Bug } from 'src/features/api';
import {
getSelectedBugId,
selectBug,
} from 'src/features/bugsPage/bugsPageSlice';
import { TableBugType } from '../types';
import { EmptyState } from './components/EmptyState';
import { InfoRow } from './components/InfoRow';
import { mapBugsToTableData } from './mapBugsToTableData';
Expand All @@ -17,7 +17,7 @@ export const AllBugs = ({
columns,
isLoading,
}: {
bugs: Bug[];
bugs: TableBugType[];
columns: ColumnDefinitionType<TableDatum, keyof TableDatum>[];
isLoading?: boolean;
}) => {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Bugs/BugsTable/components/InfoRow.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { MD, SM } from '@appquality/unguess-design-system';
import { ReactNode } from 'react';
import { Trans } from 'react-i18next';
import { Bug } from 'src/features/api';
import { getSelectedFiltersIds } from 'src/features/bugsPage/bugsPageSlice';
import styled from 'styled-components';
import { TableBugType } from '../../types';

const StyledMD = styled(MD)`
color: ${({ theme }) => theme.palette.grey[800]};
Expand Down Expand Up @@ -31,7 +31,7 @@ export const InfoRow = ({
bugs,
title,
}: {
bugs: Bug[];
bugs: TableBugType[];
title?: ReactNode;
}) => {
// Count bugs with read = false
Expand Down
7 changes: 2 additions & 5 deletions src/pages/Bugs/BugsTable/mapBugsToTableData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ import { theme } from 'src/app/theme';
import { Pill } from 'src/common/components/pills/Pill';
import { SeverityPill } from 'src/common/components/pills/SeverityPill';
import { Pipe } from 'src/common/components/Pipe';
import { GetCampaignsByCidBugsApiResponse } from 'src/features/api';
import { getSelectedBugId } from 'src/features/bugsPage/bugsPageSlice';
import { TableBugType } from '../types';
import { BugTitle } from './components/BugTitle';

export const mapBugsToTableData = (
bugs: GetCampaignsByCidBugsApiResponse['items'],
t: TFunction
) => {
export const mapBugsToTableData = (bugs: TableBugType[], t: TFunction) => {
const currentBugId = getSelectedBugId();
if (!bugs) return [];
return bugs.map((bug) => {
Expand Down
11 changes: 4 additions & 7 deletions src/pages/Bugs/BugsTable/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { ReactNode } from 'react';
import {
Bug,
BugSeverity,
GetCampaignsByCidBugsApiResponse,
} from 'src/features/api';
import { Bug, BugSeverity } from 'src/features/api';
import { TableBugType } from '../types';

export interface TableDatum {
id: string;
Expand All @@ -17,10 +14,10 @@ export interface TableDatum {

export type BugByUsecaseType = {
useCase: Bug['application_section'];
bugs: Exclude<GetCampaignsByCidBugsApiResponse['items'], undefined>;
bugs: TableBugType[];
};

export type BugBySeverityType = {
severity: BugSeverity;
bugs: Exclude<GetCampaignsByCidBugsApiResponse['items'], undefined>;
bugs: TableBugType[];
};
8 changes: 4 additions & 4 deletions src/pages/Bugs/BugsTable/useTableData.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ColumnDefinitionType } from 'src/common/components/Table';
import { useTranslation } from 'react-i18next';
import { getSelectedFiltersIds } from 'src/features/bugsPage/bugsPageSlice';
import { Bug, useGetCampaignsByCidBugsQuery } from 'src/features/api';
import { useGetCampaignsByCidBugsQuery } from 'src/features/api';
import { TableBugType } from 'src/pages/Bugs/types';
import { BugBySeverityType, BugByUsecaseType, TableDatum } from './types';

export const useTableData = (campaignId: number) => {
Expand Down Expand Up @@ -72,8 +73,7 @@ export const useTableData = (campaignId: number) => {
isLoading: true,
};
}

const sortByUsecase = (bug: Bug) => {
const sortByUsecase = (bug: TableBugType) => {
if (typeof bug.application_section.title === 'undefined') return;
const useCase = bugsByUsecase.find(
(item) => item.useCase.title === bug.application_section.title
Expand All @@ -89,7 +89,7 @@ export const useTableData = (campaignId: number) => {
}
};

const sortBySeverity = (bug: Bug) => {
const sortBySeverity = (bug: TableBugType) => {
const severity = bugsBySeverity.find(
(item) =>
item.severity.id === bug.severity.id ||
Expand Down
5 changes: 5 additions & 0 deletions src/pages/Bugs/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { GetCampaignsByCidBugsApiResponse } from 'src/features/api';

type ApiBug = GetCampaignsByCidBugsApiResponse['items'];

export type TableBugType = ItemOfArray<ApiBug>;
1 change: 1 addition & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ declare global {
[P in K]?: T;
};
type Severities = 'critical' | 'high' | 'medium' | 'low';
type ItemOfArray<T> = NonNullable<T>[number];
}