From dd503ddea48b05ba178c95ca947c03337bc3d162 Mon Sep 17 00:00:00 2001 From: "Jason R. Stevens, CFA" Date: Wed, 29 Nov 2023 00:16:16 -0500 Subject: [PATCH 1/4] :recycle: replace type imports with promo-types --- src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 4308a6d..4a4dd86 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -21,7 +21,7 @@ import { CampaignDummyData, CampaignMetrics, CampaignSortedData, -} from './lib/types'; +} from '@tincre/promo-types'; import { CampaignsSummaryStats } from './components/CampaignsSummaryStats'; import { Spinner } from './components/Spinner'; import { CampaignList } from './components/CampaignList'; From 36556b81d1c384f40a59dd6a1d4ef18e18e7f792 Mon Sep 17 00:00:00 2001 From: "Jason R. Stevens, CFA" Date: Wed, 29 Nov 2023 00:22:51 -0500 Subject: [PATCH 2/4] :recycle: replace local type import with @tincre/promo-types --- src/components/Campaign.tsx | 2 +- src/components/CampaignDeleteButton.tsx | 2 +- src/components/CampaignDetail.tsx | 2 +- src/components/CampaignImageChart.tsx | 2 +- src/components/CampaignList.tsx | 2 +- src/components/CampaignPaymentButton.tsx | 2 +- src/components/CampaignRepeatButton.tsx | 2 +- src/components/CampaignsChart.tsx | 2 +- src/components/CampaignsLineChart.tsx | 1 - src/components/CampaignsStatsHighlights.tsx | 2 +- src/components/CampaignsSummaryStats.tsx | 2 +- src/components/CampaignsTable.tsx | 4 ++-- src/components/DownloadButton.tsx | 2 +- src/components/Profile.tsx | 2 +- src/components/StatsHighlights.tsx | 2 +- src/lib/metricsDisplay.ts | 2 +- 16 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/components/Campaign.tsx b/src/components/Campaign.tsx index 8f399cc..882236f 100644 --- a/src/components/Campaign.tsx +++ b/src/components/Campaign.tsx @@ -7,7 +7,7 @@ import { useState, useEffect, MouseEvent, ReactNode } from 'react'; import { IsActivePill } from './IsActivePill'; import { IsPaidPill } from './IsPaidPill'; -import { CampaignData, CampaignDummyData } from '../lib/types'; +import { CampaignData, CampaignDummyData } from '@tincre/promo-types'; import { CampaignRepeatButton } from './CampaignRepeatButton'; import { CampaignSupportButton } from './CampaignSupportButton'; import { CampaignDeleteButton } from './CampaignDeleteButton'; diff --git a/src/components/CampaignDeleteButton.tsx b/src/components/CampaignDeleteButton.tsx index 5cb6273..86e9451 100644 --- a/src/components/CampaignDeleteButton.tsx +++ b/src/components/CampaignDeleteButton.tsx @@ -5,7 +5,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import { MouseEvent } from 'react'; -import { CampaignData, CampaignDummyData } from '../lib/types'; +import { CampaignData, CampaignDummyData } from '@tincre/promo-types'; import { XCircleIcon } from '@heroicons/react/20/solid'; export function CampaignDeleteButton({ diff --git a/src/components/CampaignDetail.tsx b/src/components/CampaignDetail.tsx index 421f324..2325d1d 100644 --- a/src/components/CampaignDetail.tsx +++ b/src/components/CampaignDetail.tsx @@ -12,7 +12,7 @@ import { CampaignDummyData, CampaignStatsData, CampaignMetrics, -} from '../lib/types'; +} from '@tincre/promo-types'; import { StatsHighlights } from './StatsHighlights'; import { CampaignImageChart } from './CampaignImageChart'; import { DownloadCampaignButton } from './DownloadButton'; diff --git a/src/components/CampaignImageChart.tsx b/src/components/CampaignImageChart.tsx index ff38289..279c626 100644 --- a/src/components/CampaignImageChart.tsx +++ b/src/components/CampaignImageChart.tsx @@ -10,7 +10,7 @@ import { CampaignData, CampaignDummyData, CampaignStatsData, -} from '../lib/types'; +} from '@tincre/promo-types'; export function CampaignImageChart({ data, diff --git a/src/components/CampaignList.tsx b/src/components/CampaignList.tsx index 6ca45e4..ba36361 100644 --- a/src/components/CampaignList.tsx +++ b/src/components/CampaignList.tsx @@ -10,7 +10,7 @@ import { CampaignData, CampaignDummyData, DashboardOptions, -} from '../lib/types'; +} from '@tincre/promo-types'; export function CampaignList({ data, diff --git a/src/components/CampaignPaymentButton.tsx b/src/components/CampaignPaymentButton.tsx index 56f2b13..15caec2 100644 --- a/src/components/CampaignPaymentButton.tsx +++ b/src/components/CampaignPaymentButton.tsx @@ -5,7 +5,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import { MouseEvent, ReactNode } from 'react'; -import { CampaignData, CampaignDummyData } from '../lib/types'; +import { CampaignData, CampaignDummyData } from '@tincre/promo-types'; import { CreditCardIcon } from '@heroicons/react/20/solid'; export function CampaignPaymentButton({ diff --git a/src/components/CampaignRepeatButton.tsx b/src/components/CampaignRepeatButton.tsx index 1ddfa27..df9a0e5 100644 --- a/src/components/CampaignRepeatButton.tsx +++ b/src/components/CampaignRepeatButton.tsx @@ -5,7 +5,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import { MouseEvent, ReactNode } from 'react'; -import { CampaignData, CampaignDummyData } from '../lib/types'; +import { CampaignData, CampaignDummyData } from '@tincre/promo-types'; import { ArrowPathIcon } from '@heroicons/react/20/solid'; export function CampaignRepeatButton({ diff --git a/src/components/CampaignsChart.tsx b/src/components/CampaignsChart.tsx index 5608a77..5722ec0 100644 --- a/src/components/CampaignsChart.tsx +++ b/src/components/CampaignsChart.tsx @@ -7,7 +7,7 @@ import { MouseEvent } from 'react'; import { CampaignsLineChart } from './CampaignsLineChart'; import { ChartButton } from './ChartButton'; -import { CampaignStatsData } from '../lib/types'; +import { CampaignStatsData } from '@tincre/promo-types'; export function CampaignsChart({ timePeriods, diff --git a/src/components/CampaignsLineChart.tsx b/src/components/CampaignsLineChart.tsx index b9d689b..126b558 100644 --- a/src/components/CampaignsLineChart.tsx +++ b/src/components/CampaignsLineChart.tsx @@ -6,7 +6,6 @@ */ import { useState, useEffect } from 'react'; import { Line } from 'react-chartjs-2'; -//import { CampaignData } from '../lib/types'; import { Chart as ChartJS, LineElement, diff --git a/src/components/CampaignsStatsHighlights.tsx b/src/components/CampaignsStatsHighlights.tsx index 644c521..55adb99 100644 --- a/src/components/CampaignsStatsHighlights.tsx +++ b/src/components/CampaignsStatsHighlights.tsx @@ -5,7 +5,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import { ArrowDownIcon, ArrowUpIcon } from '@heroicons/react/20/solid'; -import { CampaignStatsData } from '../lib/types'; +import { CampaignStatsData } from '@tincre/promo-types'; /* @ts-ignore */ function classNames(...classes) { return classes.filter(Boolean).join(' '); diff --git a/src/components/CampaignsSummaryStats.tsx b/src/components/CampaignsSummaryStats.tsx index d97fdb8..5b93c45 100644 --- a/src/components/CampaignsSummaryStats.tsx +++ b/src/components/CampaignsSummaryStats.tsx @@ -9,7 +9,7 @@ import { CampaignStatsData, CampaignData, CampaignDummyData, -} from '../lib/types'; +} from '@tincre/promo-types'; import { CampaignsStatsHighlights } from './CampaignsStatsHighlights'; import { CampaignsChart } from './CampaignsChart'; import { merge } from '../lib/merge'; diff --git a/src/components/CampaignsTable.tsx b/src/components/CampaignsTable.tsx index dc8dbce..bf0ed48 100644 --- a/src/components/CampaignsTable.tsx +++ b/src/components/CampaignsTable.tsx @@ -1,5 +1,5 @@ -import { useState, MouseEvent, Fragment } from 'react'; -import { CampaignDummyData, CampaignData } from '../lib/types'; +import { useState, MouseEvent } from 'react'; +import { CampaignDummyData, CampaignData } from '@tincre/promo-types'; import { Transition } from '@headlessui/react'; export function CampaignsTable({ diff --git a/src/components/DownloadButton.tsx b/src/components/DownloadButton.tsx index d195279..c7b32cc 100644 --- a/src/components/DownloadButton.tsx +++ b/src/components/DownloadButton.tsx @@ -9,7 +9,7 @@ import { CampaignDummyData, DownloadableCampaignStatsSample, DownloadableCampaignMetadataSample, -} from '../lib/types'; +} from '@tincre/promo-types'; import { useState, useEffect } from 'react'; import CsvDownload from 'react-json-to-csv'; import { now } from '../lib/date'; diff --git a/src/components/Profile.tsx b/src/components/Profile.tsx index 3dcb36a..d4f86a0 100644 --- a/src/components/Profile.tsx +++ b/src/components/Profile.tsx @@ -6,7 +6,7 @@ */ import { useEffect, useState, Dispatch, MouseEvent, ChangeEvent } from 'react'; import { settingsDetailSchema } from '../lib/yup'; -import { Settings } from '../lib/types'; +import { Settings } from '@tincre/promo-types'; import { Button } from '../components/Button'; export function Profile({ diff --git a/src/components/StatsHighlights.tsx b/src/components/StatsHighlights.tsx index 8d33ca5..5c7f429 100644 --- a/src/components/StatsHighlights.tsx +++ b/src/components/StatsHighlights.tsx @@ -4,7 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { CampaignStatsData } from '../lib/types'; +import { CampaignStatsData } from '@tincre/promo-types'; import { ArrowDownIcon, ArrowUpIcon } from '@heroicons/react/20/solid'; /* @ts-ignore */ diff --git a/src/lib/metricsDisplay.ts b/src/lib/metricsDisplay.ts index d19ee48..654c269 100644 --- a/src/lib/metricsDisplay.ts +++ b/src/lib/metricsDisplay.ts @@ -1,4 +1,4 @@ -import { CampaignMetrics, HeroiconIcon } from '../lib/types'; +import { CampaignMetrics, HeroiconIcon } from '@tincre/promo-types'; import { CursorArrowRaysIcon, EnvelopeOpenIcon, From 3d2a7056656c235d19958f5403330f3a429914b4 Mon Sep 17 00:00:00 2001 From: "Jason R. Stevens, CFA" Date: Wed, 29 Nov 2023 00:28:41 -0500 Subject: [PATCH 3/4] :recycle: replace type imports with @tincre/promo-types --- test/components/CampaignDeleteButton.test.tsx | 2 +- test/components/CampaignPaymentButton.test.tsx | 2 +- test/components/CampaignRepeatButton.test.tsx | 2 +- test/index.test.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/components/CampaignDeleteButton.test.tsx b/test/components/CampaignDeleteButton.test.tsx index 159667d..735531a 100644 --- a/test/components/CampaignDeleteButton.test.tsx +++ b/test/components/CampaignDeleteButton.test.tsx @@ -2,7 +2,7 @@ import React, { MouseEvent } from 'react'; import { render, screen, fireEvent } from '@testing-library/react'; import { CampaignDeleteButton } from '../../src/components/CampaignDeleteButton'; import { campaignStubData } from '../cms.data'; -import { CampaignData, CampaignDummyData } from '../../src/lib/types'; +import { CampaignData, CampaignDummyData } from '@tincre/promo-types'; describe('CampaignDeleteButton', () => { let testData = campaignStubData[0]; diff --git a/test/components/CampaignPaymentButton.test.tsx b/test/components/CampaignPaymentButton.test.tsx index f7411e0..280892a 100644 --- a/test/components/CampaignPaymentButton.test.tsx +++ b/test/components/CampaignPaymentButton.test.tsx @@ -2,7 +2,7 @@ import React, { MouseEvent } from 'react'; import { render, screen, fireEvent } from '@testing-library/react'; import { CampaignPaymentButton } from '../../src/components/CampaignPaymentButton'; import { campaignStubData } from '../cms.data'; -import { CampaignData, CampaignDummyData } from '../../src/lib/types'; +import { CampaignData, CampaignDummyData } from '@tincre/promo-types'; describe('CampaignPaymentButton', () => { let testData = campaignStubData[0]; diff --git a/test/components/CampaignRepeatButton.test.tsx b/test/components/CampaignRepeatButton.test.tsx index 3617e1d..38455df 100644 --- a/test/components/CampaignRepeatButton.test.tsx +++ b/test/components/CampaignRepeatButton.test.tsx @@ -2,7 +2,7 @@ import React, { MouseEvent } from 'react'; import { render, screen, fireEvent } from '@testing-library/react'; import { CampaignRepeatButton } from '../../src/components/CampaignRepeatButton'; import { testPromoApiCampaignData, campaignStubData } from '../cms.data'; -import { CampaignData, CampaignDummyData } from '../../src/lib/types'; +import { CampaignData, CampaignDummyData } from '@tincre/promo-types'; describe('CampaignRepeatButton', () => { it('renders without crashing', () => { diff --git a/test/index.test.tsx b/test/index.test.tsx index a084d99..e303b93 100644 --- a/test/index.test.tsx +++ b/test/index.test.tsx @@ -3,7 +3,7 @@ import { screen, render, fireEvent } from '@testing-library/react'; import { PromoDashboard } from '../src/index'; import { PromoChat } from '@tincre/promo-chat'; import { campaignStubData } from './cms.data'; -import { CampaignData, CampaignDummyData, Settings } from '../src/lib/types'; +import { CampaignData, CampaignDummyData, Settings } from '@tincre/promo-types'; import { mockAllIsIntersecting, setupIntersectionMocking, From dc92b90d47e2fdcf2e0c7d012029a57b7dc95fec Mon Sep 17 00:00:00 2001 From: "Jason R. Stevens, CFA" Date: Wed, 29 Nov 2023 00:32:02 -0500 Subject: [PATCH 4/4] :recycle: remove local type import for @tincre/promo-types --- src/lib/coerce.ts | 2 +- src/lib/compareDates.ts | 2 +- src/lib/sort.ts | 2 +- src/lib/support.ts | 2 +- src/lib/types.ts | 143 ---------------------------------------- 5 files changed, 4 insertions(+), 147 deletions(-) delete mode 100644 src/lib/types.ts diff --git a/src/lib/coerce.ts b/src/lib/coerce.ts index 3a4fcbd..415cca7 100644 --- a/src/lib/coerce.ts +++ b/src/lib/coerce.ts @@ -17,7 +17,7 @@ import { CampaignDummyData, CampaignSortedData, CampaignMetrics, -} from './types'; +} from '@tincre/promo-types'; function generateEmptyPromoApiDataForChartJs(): { updatedTime: (string | null)[]; diff --git a/src/lib/compareDates.ts b/src/lib/compareDates.ts index d9b6dea..1169c73 100644 --- a/src/lib/compareDates.ts +++ b/src/lib/compareDates.ts @@ -4,7 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { CampaignData, CampaignDummyData } from './types'; +import { CampaignData, CampaignDummyData } from '@tincre/promo-types'; /* * Given data packages compare their dates. diff --git a/src/lib/sort.ts b/src/lib/sort.ts index 20e0a44..2e47a33 100644 --- a/src/lib/sort.ts +++ b/src/lib/sort.ts @@ -4,7 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { CampaignData, CampaignDummyData } from './types'; +import { CampaignData, CampaignDummyData } from '@tincre/promo-types'; import { compareDates } from './compareDates'; export function sortCampaignDataOnIsActive( data: CampaignData[] | CampaignDummyData[] diff --git a/src/lib/support.ts b/src/lib/support.ts index 4d9bf42..70a1acd 100644 --- a/src/lib/support.ts +++ b/src/lib/support.ts @@ -1,4 +1,4 @@ -import { CampaignData, CampaignDummyData } from './types'; +import { CampaignData, CampaignDummyData } from '@tincre/promo-types'; const EMAILDOMAIN = 'tincre.dev'; const EMAILLOCALPART = 'team'; diff --git a/src/lib/types.ts b/src/lib/types.ts deleted file mode 100644 index 8186b88..0000000 --- a/src/lib/types.ts +++ /dev/null @@ -1,143 +0,0 @@ -/* Copyright Tincre (Musicfox, Inc) - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -export type HeroiconIcon = React.ForwardRefExoticComponent< - Omit, 'ref'> & { - title?: string | undefined; - titleId?: string | undefined; - } & React.RefAttributes ->; - -export interface DownloadableCampaignStatsSample - extends PromoApiCampaignStatsSample { - pid: string; -} - -export interface DownloadableCampaignMetadataSample - extends DownloadableCampaignStatsSample { - adTitle?: string; - budget?: number | string; - target?: string; - isActive?: boolean; - adCallToAction?: string; - buttonText?: string; - creativeUrl: string; -} - -export interface PromoApiCampaignStatsSample { - updatedTime?: string; - updated_time?: string; - spend?: number | string | null; - reach?: number | string | null; - views?: number | string | null; - clicks?: number | string | null; - cpc?: number | string | null; - ctr?: number | string | null; - cpm?: number | string | null; - cpv?: number | string | null; -} - -export interface CampaignStatsSample { - name: string; -} - -export interface PromoApiCampaignStatsData { - totals?: PromoApiCampaignStatsSample[]; - google?: PromoApiCampaignStatsSample[]; - meta?: PromoApiCampaignStatsSample[]; -} - -export interface DownloadableCampaignStats { - updatedTime: (string | null)[]; - spend?: (number | string | null)[]; - reach?: (number | string | null)[]; - views?: (number | string | null)[]; - clicks?: (number | string | null)[]; - cpc?: (number | string | null)[]; - cpm?: (number | string | null)[]; - ctr?: (number | string | null)[]; - cpv?: (number | string | null)[]; - pid: (string | null)[]; -} - -export type CampaignMetrics = - | 'Spend' - | 'Clicks' - | 'Views' - | 'Reach' - | 'CPM' - | 'CTR' - | 'CPC' - | 'CPV' - | string; - -export interface CampaignStatsData { - id: number | undefined; - name: CampaignMetrics; - stat: string; - isActive?: boolean; - icon: React.ForwardRefExoticComponent< - Omit, 'ref'> & { - title?: string | undefined; - titleId?: string | undefined; - } & React.RefAttributes - >; - change: string | number; - changeType: string; - chartData: { - labels: (string | null)[]; - data: (string | number | null)[]; - }; -} - -export interface CampaignMetadata { - pid?: string; - email?: string; - adTitle?: string; - budget?: string | number; - description?: string; - target?: string; - adCopy?: string; - creativeUrls?: string[]; - adCallToAction?: string; - buttonText?: string; - isActive?: boolean; - receiptId?: string; - currency?: string; - isFlat?: boolean; - usageFee?: string | number; - startDate?: string; -} - -export interface CampaignData extends CampaignMetadata { - stats?: CampaignStatsData[]; - data?: PromoApiCampaignStatsData; -} - -export interface CampaignDummyData extends CampaignMetadata { - stats?: CampaignStatsData[]; - data?: CampaignStatsData[]; -} - -export interface CampaignSortedData extends CampaignDummyData {} - -export interface Settings { - fullName?: string; - image?: string; - userName?: string; - email?: string; -} - -export type DashboardOptions = { - emailDomain?: string; - emailLocalPart?: string; - isTableCollapsed?: boolean; - promoChatApiRoute?: string; - promoChatStartingAgentMessage?: string; - promoChatAgentName?: string; - promoChatInputMessagePlaceholder?: string; - promoChatExecuteRecaptcha?: (action: string) => Promise; -};