File tree Expand file tree Collapse file tree 5 files changed +36
-26
lines changed Expand file tree Collapse file tree 5 files changed +36
-26
lines changed Original file line number Diff line number Diff line change 1+ import { useTranslation } from 'react-i18next' ;
12import { CampaignStatus } from 'src/types' ;
23import { Meta } from '../Meta' ;
34import { getStatusInfo } from '../utils/getStatusInfo' ;
@@ -10,7 +11,8 @@ interface StatusMetaArgs extends React.HTMLAttributes<HTMLDivElement> {
1011}
1112
1213export const StatusMeta = ( { status, counter, ...props } : StatusMetaArgs ) => {
13- const statusInfo = getStatusInfo ( status ) ;
14+ const { t } = useTranslation ( ) ;
15+ const statusInfo = getStatusInfo ( status , t ) ;
1416
1517 return (
1618 < Meta
Original file line number Diff line number Diff line change 11import { Tag } from '@appquality/unguess-design-system' ;
2+ import { useTranslation } from 'react-i18next' ;
23import { theme } from 'src/app/theme' ;
34import { CampaignStatus } from 'src/types' ;
45import { getStatusInfo } from '../utils/getStatusInfo' ;
@@ -17,7 +18,8 @@ export const StatusTag = ({
1718 isRound,
1819 ...props
1920} : StatusTagArgs ) => {
20- const statusInfo = getStatusInfo ( status ) ;
21+ const { t } = useTranslation ( ) ;
22+ const statusInfo = getStatusInfo ( status , t ) ;
2123
2224 return (
2325 < Tag
Original file line number Diff line number Diff line change @@ -7,17 +7,18 @@ import {
77 CampaignFunctionalIcon ,
88} from '@appquality/unguess-design-system' ;
99import { theme } from 'src/app/theme' ;
10- import { useTranslation } from 'react- i18next' ;
10+ import { TFunction } from 'i18next' ;
1111
1212type StatusInfo = {
1313 icon ?: React . ReactNode ;
1414 text ?: string ;
1515 color ?: string ;
1616} ;
1717
18- export const getStatusInfo = ( status : CampaignStatus ) : StatusInfo => {
19- const { t } = useTranslation ( ) ;
20-
18+ export const getStatusInfo = (
19+ status : CampaignStatus ,
20+ t : TFunction
21+ ) : StatusInfo => {
2122 switch ( status . toLowerCase ( ) ) {
2223 case 'running' :
2324 return {
Original file line number Diff line number Diff line change @@ -39,25 +39,29 @@ export const TableList = ({
3939
4040 const items = curr . map ( ( campaign ) => {
4141 const statusInfo = getStatusInfo (
42- campaign . status . name as CampaignStatus
42+ campaign . status . name as CampaignStatus ,
43+ t
4344 ) ;
45+
46+ const cpUrl = getLocalizeDashboardRoute ( {
47+ campaignId : campaign . id ,
48+ cpFamily : campaign . family . name ,
49+ outputs : campaign . outputs || [ ] ,
50+ } ) ;
51+
52+ const cpStartDate = new Date ( campaign . start_date ) . toLocaleDateString ( ) ;
53+
4454 return {
4555 name : (
46- < Anchor
47- href = { getLocalizeDashboardRoute ( {
48- campaignId : campaign . id ,
49- cpFamily : campaign . family . name ,
50- outputs : campaign . outputs || [ ] ,
51- } ) }
52- >
56+ < Anchor href = { cpUrl } >
5357 < Span isBold style = { { color : theme . palette . grey [ 800 ] } } >
5458 { campaign . customer_title ?? campaign . title }
5559 </ Span >
5660 </ Anchor >
5761 ) ,
5862 type : campaign . family . name ,
5963 testType : campaign . type . name ,
60- startDate : new Date ( campaign . start_date ) . toLocaleDateString ( ) ,
64+ startDate : cpStartDate ,
6165 status : (
6266 < Tooltip
6367 type = "light"
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ export const TableList = ({
3232 { name : t ( '__CAMPAIGNS_TABLE_COLUMN_STATUS' ) , field : 'status' } ,
3333 ] ;
3434
35+ if ( ! campaigns . length ) return null ;
36+
3537 return (
3638 < Table isReadOnly style = { { backgroundColor : 'white' } } >
3739 < TableHead >
@@ -43,27 +45,26 @@ export const TableList = ({
4345 </ TableHead >
4446 < TableBody >
4547 { campaigns . map ( ( cp ) => {
46- const statusInfo = getStatusInfo ( cp . status . name as CampaignStatus ) ;
48+ const statusInfo = getStatusInfo ( cp . status . name as CampaignStatus , t ) ;
49+ const cpUrl = getLocalizeDashboardRoute ( {
50+ campaignId : cp . id ,
51+ cpFamily : cp . family . name ,
52+ outputs : cp . outputs || [ ] ,
53+ } ) ;
54+ const cpStartDate = new Date ( cp . start_date ) . toLocaleDateString ( ) ;
55+
4756 return (
4857 < TableRow key = { cp . id } >
4958 < TableCell >
50- < Anchor
51- href = { getLocalizeDashboardRoute ( {
52- campaignId : cp . id ,
53- cpFamily : cp . family . name ,
54- outputs : cp . outputs || [ ] ,
55- } ) }
56- >
59+ < Anchor href = { cpUrl } >
5760 < Span isBold style = { { color : theme . palette . grey [ 800 ] } } >
5861 { cp . customer_title ?? cp . title }
5962 </ Span >
6063 </ Anchor >
6164 </ TableCell >
6265 < TableCell > { cp . family . name } </ TableCell >
6366 < TableCell > { cp . type . name } </ TableCell >
64- < TableCell >
65- { new Date ( cp . start_date ) . toLocaleDateString ( ) }
66- </ TableCell >
67+ < TableCell > { cpStartDate } </ TableCell >
6768 < TableCell >
6869 < Tooltip
6970 type = "light"
You can’t perform that action at this time.
0 commit comments