Skip to content

Commit

Permalink
♻️ refactor to take and use NoData component for undefined campaignsData
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkjrs committed Jan 12, 2024
1 parent fde3f6e commit a542fde
Showing 1 changed file with 79 additions and 70 deletions.
149 changes: 79 additions & 70 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import { usePromoDashboardData } from './lib/hooks/usePromoDashboardData';
import { CampaignsSummaryStats } from './components/CampaignsSummaryStats';
import { Spinner } from './components/Spinner';
import { NoData } from './components/NoData';
import { CampaignList } from './components/CampaignList';
import { DashboardContainer } from './components/DashboardContainer';
import { options } from './lib/options';
Expand Down Expand Up @@ -273,78 +274,86 @@ export function PromoDashboard({
return (
<>
<DashboardContainer isLoading={isLoading}>
{!isCampaignClicked ? (
<>
<div className="inline-flex w-full pb-4 justify-between">
{!numberOfActiveCampaigns ? null : (
<h1 className="mt-auto mx-2 text-left align-text-middle text-2xl font-bold dark:text-slate-200">
{numberOfActiveCampaigns} active campaigns
</h1>
)}
{isLoading ? (
<span className="mt-auto text-center text-2xl ">
<Spinner />
{typeof campaignsData !== 'undefined' ? <>

Check failure on line 277 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.x and ubuntu-latest

Insert `(⏎··········`

Check failure on line 277 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20.x and ubuntu-latest

Insert `(⏎··········`
{!isCampaignClicked ? (

Check failure on line 278 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.x and ubuntu-latest

Insert `··`

Check failure on line 278 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20.x and ubuntu-latest

Insert `··`
<>

Check failure on line 279 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.x and ubuntu-latest

Insert `··`

Check failure on line 279 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20.x and ubuntu-latest

Insert `··`
<div className="inline-flex w-full pb-4 justify-between">

Check failure on line 280 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.x and ubuntu-latest

Replace `··············` with `················`

Check failure on line 280 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20.x and ubuntu-latest

Replace `··············` with `················`
{!numberOfActiveCampaigns ? null : (

Check failure on line 281 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.x and ubuntu-latest

Insert `··`

Check failure on line 281 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20.x and ubuntu-latest

Insert `··`
<h1 className="mt-auto mx-2 text-left align-text-middle text-2xl font-bold dark:text-slate-200">

Check failure on line 282 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.x and ubuntu-latest

Insert `··`

Check failure on line 282 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20.x and ubuntu-latest

Insert `··`
{numberOfActiveCampaigns} active campaigns

Check failure on line 283 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.x and ubuntu-latest

Insert `··`

Check failure on line 283 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20.x and ubuntu-latest

Insert `··`
</h1>

Check failure on line 284 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.x and ubuntu-latest

Insert `··`

Check failure on line 284 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20.x and ubuntu-latest

Insert `··`
)}

Check failure on line 285 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.x and ubuntu-latest

Insert `··`

Check failure on line 285 in src/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20.x and ubuntu-latest

Insert `··`
{isLoading ? (
<span className="mt-auto text-center text-2xl ">
<Spinner />
</span>
) : null}
<span className="mt-auto mx-2 text-center">
<DownloadAllCampaignsButton
campaignsData={sortedCampaignsData}
/>
</span>
) : null}
<span className="mt-auto mx-2 text-center">
<DownloadAllCampaignsButton
campaignsData={sortedCampaignsData}
/>
</span>
</div>
</div>

{!sortedCampaignsData ? null : (
<>
<CampaignsSummaryStats
data={statsCampaignsData}
statsHighlightTimeseries={statsHighlightCampaignsTimeseries}
statsHighlightMetricName={clickedStatsCampaignsClassName}
campaignData={sortedCampaignsData}
isTableCollapsed={dashboardOptions?.isTableCollapsed}
handleCampaignClick={handleCampaignOnClick}
handleCampaignDetailBackOnClick={
handleCampaignDetailBackOnClick
}
handleStatsHighlightClick={handleStatsHighlightCampaignsClick}
/>
<CampaignList
data={sortedCampaignsData}
handleRepeatButtonOnClick={
typeof handleRepeatButtonClick !== 'undefined'
? handleRepeatButtonClick
: handleRepeatButtonOnClick
}
handleCampaignClick={handleCampaignOnClick}
handleGeneratePaymentLinkButtonClick={
typeof handleGeneratePaymentLinkButtonClick !== 'undefined'
? handleGeneratePaymentLinkButtonClick
: handleGeneratePaymentLinkButtonOnClick
}
handleDeleteButtonOnClick={
typeof handleDeleteButtonClick !== 'undefined'
? handleDeleteButtonClick
: handleDeleteButtonOnClick
}
deletedCampaigns={deletedCampaigns}
dashboardOptions={dashboardOptions}
/>
{typeof campaignsData !== 'undefined' ? (
<div className=""></div>
) : null}
</>
)}
</>
) : typeof promoData !== 'undefined' ? (
<>
<CampaignDetail
data={promoData}
statsHighlightTimeseries={statsHighlightTimeseries}
statsHighlightMetricName={clickedStatsClassName}
handleCampaignDetailBackOnClick={handleCampaignDetailBackOnClick}
handleStatsHighlightClick={handleStatsHighlightClick}
/>
</>
) : null}
{!sortedCampaignsData ? null : (
<>
<CampaignsSummaryStats
data={statsCampaignsData}
statsHighlightTimeseries={statsHighlightCampaignsTimeseries}
statsHighlightMetricName={clickedStatsCampaignsClassName}
campaignData={sortedCampaignsData}
isTableCollapsed={dashboardOptions?.isTableCollapsed}
handleCampaignClick={handleCampaignOnClick}
handleCampaignDetailBackOnClick={
handleCampaignDetailBackOnClick
}
handleStatsHighlightClick={
handleStatsHighlightCampaignsClick
}
/>
<CampaignList
data={sortedCampaignsData}
handleRepeatButtonOnClick={
typeof handleRepeatButtonClick !== 'undefined'
? handleRepeatButtonClick
: handleRepeatButtonOnClick
}
handleCampaignClick={handleCampaignOnClick}
handleGeneratePaymentLinkButtonClick={
typeof handleGeneratePaymentLinkButtonClick !==
'undefined'
? handleGeneratePaymentLinkButtonClick
: handleGeneratePaymentLinkButtonOnClick
}
handleDeleteButtonOnClick={
typeof handleDeleteButtonClick !== 'undefined'
? handleDeleteButtonClick
: handleDeleteButtonOnClick
}
deletedCampaigns={deletedCampaigns}
dashboardOptions={dashboardOptions}
/>
{typeof campaignsData !== 'undefined' ? (
<div className=""></div>
) : null}
</>
)}
</>
) : typeof promoData !== 'undefined' ? (
<>
<CampaignDetail
data={promoData}
statsHighlightTimeseries={statsHighlightTimeseries}
statsHighlightMetricName={clickedStatsClassName}
handleCampaignDetailBackOnClick={
handleCampaignDetailBackOnClick
}
handleStatsHighlightClick={handleStatsHighlightClick}
/>
</>
) : null}
</>: <><NoData />
</>}
<Profile
setHasUpdatedSettings={setHasUpdatedSettings}
setIsUpdatingSettings={setIsUpdatingSettings}
Expand Down

0 comments on commit a542fde

Please sign in to comment.