Skip to content

Commit dcce72b

Browse files
authored
chore: ads components refactor
2 parents 3224227 + f7d27bd commit dcce72b

File tree

14 files changed

+249
-238
lines changed

14 files changed

+249
-238
lines changed

src/app/[locale]/borrower/components/MarketsSection/сomponents/MarketsTables/BorrowerActiveMarketsTables/index.tsx

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ import {
1313
} from "@/app/[locale]/borrower/components/MarketsSection/сomponents/MarketsTables/interface"
1414
import { DataGridSx } from "@/app/[locale]/borrower/components/MarketsSection/сomponents/MarketsTables/style"
1515
import { LinkCell } from "@/app/[locale]/borrower/components/MarketsTables/style"
16-
import Ethena from "@/assets/companies-icons/ethena_icon.svg"
17-
import Ethereal from "@/assets/companies-icons/ethereal_icon.svg"
1816
import { MarketStatusChip } from "@/components/@extended/MarketStatusChip"
1917
import { MarketTypeChip } from "@/components/@extended/MarketTypeChip"
20-
import { AurosEthenaBanner } from "@/components/AdsBanners/AurosEthena/AurosEthenaBanner"
21-
import { AurosEthenaProposalChip } from "@/components/AdsBanners/AurosEthena/AurosEthenaProposalChip"
22-
import { AprTooltip } from "@/components/AdsBanners/Common/AprTooltip"
18+
import {
19+
getAdsCellProps,
20+
getAdsTooltipComponent,
21+
} from "@/components/AdsBanners/adsHelpers"
2322
import { AprChip } from "@/components/AprChip"
2423
import { MarketsTableAccordion } from "@/components/MarketsTableAccordion"
2524
import { ROUTES } from "@/routes"
@@ -30,11 +29,7 @@ import {
3029
tokenAmountComparator,
3130
typeComparator,
3231
} from "@/utils/comparators"
33-
import {
34-
AUROS_ETHENA_ADDRESS,
35-
KAPPALAB_ETHENA_ADDRESS,
36-
pageCalcHeights,
37-
} from "@/utils/constants"
32+
import { pageCalcHeights } from "@/utils/constants"
3833
import {
3934
buildMarketHref,
4035
formatBps,
@@ -231,24 +226,11 @@ export const BorrowerActiveMarketsTables = ({
231226
headerAlign: "right",
232227
align: "right",
233228
renderCell: (params) => {
234-
const isAuros =
235-
params.row.id.toLowerCase() === AUROS_ETHENA_ADDRESS.toLowerCase()
236-
237-
const isKappaLab =
238-
params.row.id.toLowerCase() === KAPPALAB_ETHENA_ADDRESS.toLowerCase()
239-
240-
const showAdsComponent = isAuros || isKappaLab
241-
242-
const adsComponent = showAdsComponent ? (
243-
<AprTooltip
244-
baseAPR={formatBps(params.value)}
245-
aprProposal={<AurosEthenaProposalChip isTooltip />}
246-
banner={
247-
<AurosEthenaBanner tokenAmount={isAuros ? "1 million" : "200k"} />
248-
}
249-
withdrawalAnyTime
250-
/>
251-
) : undefined
229+
const adsComponent = getAdsTooltipComponent(
230+
params.row.id,
231+
formatBps(params.value),
232+
)
233+
const adsCellProps = getAdsCellProps(params.row.id)
252234

253235
return (
254236
<Link
@@ -260,11 +242,9 @@ export const BorrowerActiveMarketsTables = ({
260242
style={{ ...LinkCell, justifyContent: "flex-end" }}
261243
>
262244
<AprChip
263-
isBonus={isAuros || isKappaLab}
245+
isBonus={!!adsCellProps}
264246
baseApr={formatBps(params.value)}
265-
icons={
266-
isAuros || isKappaLab ? [<Ethena />, <Ethereal />] : undefined
267-
}
247+
icons={adsCellProps?.icons}
268248
adsComponent={adsComponent}
269249
/>
270250
</Link>

src/app/[locale]/borrower/components/MarketsSection/сomponents/MarketsTables/BorrowerTerminatedMarketsTables/index.tsx

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,19 @@ import {
1313
} from "@/app/[locale]/borrower/components/MarketsSection/сomponents/MarketsTables/interface"
1414
import { DataGridSx } from "@/app/[locale]/borrower/components/MarketsSection/сomponents/MarketsTables/style"
1515
import { LinkCell } from "@/app/[locale]/borrower/components/MarketsTables/style"
16-
import Ethena from "@/assets/companies-icons/ethena_icon.svg"
17-
import Ethereal from "@/assets/companies-icons/ethereal_icon.svg"
1816
import { MarketStatusChip } from "@/components/@extended/MarketStatusChip"
19-
import { AurosEthenaBanner } from "@/components/AdsBanners/AurosEthena/AurosEthenaBanner"
20-
import { AurosEthenaProposalChip } from "@/components/AdsBanners/AurosEthena/AurosEthenaProposalChip"
21-
import { AprTooltip } from "@/components/AdsBanners/Common/AprTooltip"
17+
import {
18+
getAdsCellProps,
19+
getAdsTooltipComponent,
20+
} from "@/components/AdsBanners/adsHelpers"
2221
import { AprChip } from "@/components/AprChip"
2322
import { BorrowerProfileChip } from "@/components/BorrowerProfileChip"
2423
import { ROUTES } from "@/routes"
2524
import { useAppDispatch, useAppSelector } from "@/store/hooks"
2625
import { setScrollTarget } from "@/store/slices/marketsOverviewSidebarSlice/marketsOverviewSidebarSlice"
2726
import { COLORS } from "@/theme/colors"
2827
import { statusComparator, tokenAmountComparator } from "@/utils/comparators"
29-
import {
30-
AUROS_ETHENA_ADDRESS,
31-
KAPPALAB_ETHENA_ADDRESS,
32-
pageCalcHeights,
33-
} from "@/utils/constants"
28+
import { pageCalcHeights } from "@/utils/constants"
3429
import {
3530
buildMarketHref,
3631
formatBps,
@@ -217,24 +212,11 @@ export const BorrowerTerminatedMarketsTables = ({
217212
headerAlign: "right",
218213
align: "right",
219214
renderCell: (params) => {
220-
const isAuros =
221-
params.row.id.toLowerCase() === AUROS_ETHENA_ADDRESS.toLowerCase()
222-
223-
const isKappaLab =
224-
params.row.id.toLowerCase() === KAPPALAB_ETHENA_ADDRESS.toLowerCase()
225-
226-
const showAdsComponent = isAuros || isKappaLab
227-
228-
const adsComponent = showAdsComponent ? (
229-
<AprTooltip
230-
baseAPR={formatBps(params.value)}
231-
aprProposal={<AurosEthenaProposalChip isTooltip />}
232-
banner={
233-
<AurosEthenaBanner tokenAmount={isAuros ? "1 million" : "200k"} />
234-
}
235-
withdrawalAnyTime
236-
/>
237-
) : undefined
215+
const adsComponent = getAdsTooltipComponent(
216+
params.row.id,
217+
formatBps(params.value),
218+
)
219+
const adsCellProps = getAdsCellProps(params.row.id)
238220

239221
return (
240222
<Link
@@ -246,11 +228,9 @@ export const BorrowerTerminatedMarketsTables = ({
246228
style={{ ...LinkCell, justifyContent: "flex-end" }}
247229
>
248230
<AprChip
249-
isBonus={isAuros || isKappaLab}
231+
isBonus={!!adsCellProps}
250232
baseApr={formatBps(params.value)}
251-
icons={
252-
isAuros || isKappaLab ? [<Ethena />, <Ethereal />] : undefined
253-
}
233+
icons={adsCellProps?.icons}
254234
adsComponent={adsComponent}
255235
/>
256236
</Link>

src/app/[locale]/borrower/components/MarketsSection/сomponents/MarketsTables/OtherMarketsTables/index.tsx

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ import {
1919
import { DataGridSx } from "@/app/[locale]/borrower/components/MarketsSection/сomponents/MarketsTables/style"
2020
import { LinkCell } from "@/app/[locale]/borrower/components/MarketsTables/style"
2121
import { useBorrowerNames } from "@/app/[locale]/borrower/hooks/useBorrowerNames"
22-
import Ethena from "@/assets/companies-icons/ethena_icon.svg"
23-
import Ethereal from "@/assets/companies-icons/ethereal_icon.svg"
2422
import { MarketStatusChip } from "@/components/@extended/MarketStatusChip"
2523
import { MarketTypeChip } from "@/components/@extended/MarketTypeChip"
26-
import { AurosEthenaBanner } from "@/components/AdsBanners/AurosEthena/AurosEthenaBanner"
27-
import { AurosEthenaProposalChip } from "@/components/AdsBanners/AurosEthena/AurosEthenaProposalChip"
28-
import { AprTooltip } from "@/components/AdsBanners/Common/AprTooltip"
24+
import {
25+
getAdsCellProps,
26+
getAdsTooltipComponent,
27+
} from "@/components/AdsBanners/adsHelpers"
2928
import { AprChip } from "@/components/AprChip"
3029
import { BorrowerProfileChip } from "@/components/BorrowerProfileChip"
3130
import { MarketsTableAccordion } from "@/components/MarketsTableAccordion"
@@ -38,11 +37,7 @@ import {
3837
tokenAmountComparator,
3938
typeComparator,
4039
} from "@/utils/comparators"
41-
import {
42-
AUROS_ETHENA_ADDRESS,
43-
KAPPALAB_ETHENA_ADDRESS,
44-
pageCalcHeights,
45-
} from "@/utils/constants"
40+
import { pageCalcHeights } from "@/utils/constants"
4641
import {
4742
buildMarketHref,
4843
formatBps,
@@ -257,24 +252,11 @@ export const OtherMarketsTables = ({
257252
headerAlign: "right",
258253
align: "right",
259254
renderCell: (params) => {
260-
const isAuros =
261-
params.row.id.toLowerCase() === AUROS_ETHENA_ADDRESS.toLowerCase()
262-
263-
const isKappaLab =
264-
params.row.id.toLowerCase() === KAPPALAB_ETHENA_ADDRESS.toLowerCase()
265-
266-
const showAdsComponent = isAuros || isKappaLab
267-
268-
const adsComponent = showAdsComponent ? (
269-
<AprTooltip
270-
baseAPR={formatBps(params.value)}
271-
aprProposal={<AurosEthenaProposalChip isTooltip />}
272-
banner={
273-
<AurosEthenaBanner tokenAmount={isAuros ? "1 million" : "200k"} />
274-
}
275-
withdrawalAnyTime
276-
/>
277-
) : undefined
255+
const adsComponent = getAdsTooltipComponent(
256+
params.row.id,
257+
formatBps(params.value),
258+
)
259+
const adsCellProps = getAdsCellProps(params.row.id)
278260

279261
return (
280262
<Link
@@ -286,11 +268,9 @@ export const OtherMarketsTables = ({
286268
style={{ ...LinkCell, justifyContent: "flex-end" }}
287269
>
288270
<AprChip
289-
isBonus={isAuros || isKappaLab}
271+
isBonus={!!adsCellProps}
290272
baseApr={formatBps(params.value)}
291-
icons={
292-
isAuros || isKappaLab ? [<Ethena />, <Ethereal />] : undefined
293-
}
273+
icons={adsCellProps?.icons}
294274
adsComponent={adsComponent}
295275
/>
296276
</Link>

src/app/[locale]/lender/components/MarketsSection/components/MarketsTables/LenderActiveMarketsTables/index.tsx

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ import { useTranslation } from "react-i18next"
99

1010
import { TypeSafeColDef } from "@/app/[locale]/borrower/components/MarketsSection/сomponents/MarketsTables/interface"
1111
import { LinkCell } from "@/app/[locale]/borrower/components/MarketsTables/style"
12-
import Ethena from "@/assets/companies-icons/ethena_icon.svg"
13-
import Ethereal from "@/assets/companies-icons/ethereal_icon.svg"
1412
import { MarketStatusChip } from "@/components/@extended/MarketStatusChip"
1513
import { MarketTypeChip } from "@/components/@extended/MarketTypeChip"
16-
import { AurosEthenaBanner } from "@/components/AdsBanners/AurosEthena/AurosEthenaBanner"
17-
import { AurosEthenaProposalChip } from "@/components/AdsBanners/AurosEthena/AurosEthenaProposalChip"
18-
import { AprTooltip } from "@/components/AdsBanners/Common/AprTooltip"
14+
import {
15+
getAdsCellProps,
16+
getAdsTooltipComponent,
17+
} from "@/components/AdsBanners/adsHelpers"
1918
import { AprChip } from "@/components/AprChip"
2019
import { BorrowerProfileChip } from "@/components/BorrowerProfileChip"
2120
import { MarketsTableAccordion } from "@/components/MarketsTableAccordion"
@@ -30,11 +29,7 @@ import {
3029
tokenAmountComparator,
3130
typeComparator,
3231
} from "@/utils/comparators"
33-
import {
34-
AUROS_ETHENA_ADDRESS,
35-
KAPPALAB_ETHENA_ADDRESS,
36-
pageCalcHeights,
37-
} from "@/utils/constants"
32+
import { pageCalcHeights } from "@/utils/constants"
3833
import {
3934
buildMarketHref,
4035
formatBps,
@@ -224,36 +219,21 @@ export const LenderActiveMarketsTables = ({
224219
headerAlign: "right",
225220
align: "right",
226221
renderCell: (params) => {
227-
const isAuros =
228-
params.row.id.toLowerCase() === AUROS_ETHENA_ADDRESS.toLowerCase()
229-
230-
const isKappaLab =
231-
params.row.id.toLowerCase() === KAPPALAB_ETHENA_ADDRESS.toLowerCase()
232-
233-
const showAdsComponent = isAuros || isKappaLab
234-
235-
const adsComponent = showAdsComponent ? (
236-
<AprTooltip
237-
baseAPR={formatBps(params.value)}
238-
aprProposal={<AurosEthenaProposalChip isTooltip />}
239-
banner={
240-
<AurosEthenaBanner tokenAmount={isAuros ? "1 million" : "200k"} />
241-
}
242-
withdrawalAnyTime
243-
/>
244-
) : undefined
222+
const adsComponent = getAdsTooltipComponent(
223+
params.row.id,
224+
formatBps(params.value),
225+
)
226+
const adsCellProps = getAdsCellProps(params.row.id)
245227

246228
return (
247229
<Link
248230
href={buildMarketHref(params.row.id, params.row.chainId)}
249231
style={{ ...LinkCell, justifyContent: "flex-end" }}
250232
>
251233
<AprChip
252-
isBonus={isAuros || isKappaLab}
234+
isBonus={!!adsCellProps}
253235
baseApr={formatBps(params.value)}
254-
icons={
255-
isAuros || isKappaLab ? [<Ethena />, <Ethereal />] : undefined
256-
}
236+
icons={adsCellProps?.icons}
257237
adsComponent={adsComponent}
258238
/>
259239
</Link>

src/app/[locale]/lender/components/MarketsSection/components/MarketsTables/OtherMarketsTables/index.tsx

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ import { TypeSafeColDef } from "@/app/[locale]/borrower/components/MarketsSectio
1515
import { LinkCell } from "@/app/[locale]/borrower/components/MarketsTables/style"
1616
import { useBorrowerNames } from "@/app/[locale]/borrower/hooks/useBorrowerNames"
1717
import { DataGridSx } from "@/app/[locale]/lender/components/MarketsSection/components/MarketsTables/style"
18-
import Ethena from "@/assets/companies-icons/ethena_icon.svg"
19-
import Ethereal from "@/assets/companies-icons/ethereal_icon.svg"
2018
import { MarketStatusChip } from "@/components/@extended/MarketStatusChip"
2119
import { MarketTypeChip } from "@/components/@extended/MarketTypeChip"
22-
import { AurosEthenaBanner } from "@/components/AdsBanners/AurosEthena/AurosEthenaBanner"
23-
import { AurosEthenaProposalChip } from "@/components/AdsBanners/AurosEthena/AurosEthenaProposalChip"
24-
import { AprTooltip } from "@/components/AdsBanners/Common/AprTooltip"
20+
import {
21+
getAdsCellProps,
22+
getAdsTooltipComponent,
23+
} from "@/components/AdsBanners/adsHelpers"
2524
import { AprChip } from "@/components/AprChip"
2625
import { BorrowerProfileChip } from "@/components/BorrowerProfileChip"
2726
import { MarketsTableAccordion } from "@/components/MarketsTableAccordion"
@@ -37,11 +36,7 @@ import {
3736
tokenAmountComparator,
3837
typeComparator,
3938
} from "@/utils/comparators"
40-
import {
41-
AUROS_ETHENA_ADDRESS,
42-
KAPPALAB_ETHENA_ADDRESS,
43-
pageCalcHeights,
44-
} from "@/utils/constants"
39+
import { pageCalcHeights } from "@/utils/constants"
4540
import {
4641
buildMarketHref,
4742
formatBps,
@@ -235,36 +230,21 @@ export const OtherMarketsTables = ({
235230
headerAlign: "right",
236231
align: "right",
237232
renderCell: (params) => {
238-
const isAuros =
239-
params.row.id.toLowerCase() === AUROS_ETHENA_ADDRESS.toLowerCase()
240-
241-
const isKappaLab =
242-
params.row.id.toLowerCase() === KAPPALAB_ETHENA_ADDRESS.toLowerCase()
243-
244-
const showAdsComponent = isAuros || isKappaLab
245-
246-
const adsComponent = showAdsComponent ? (
247-
<AprTooltip
248-
baseAPR={formatBps(params.value)}
249-
aprProposal={<AurosEthenaProposalChip isTooltip />}
250-
banner={
251-
<AurosEthenaBanner tokenAmount={isAuros ? "1 million" : "200k"} />
252-
}
253-
withdrawalAnyTime
254-
/>
255-
) : undefined
233+
const adsComponent = getAdsTooltipComponent(
234+
params.row.id,
235+
formatBps(params.value),
236+
)
237+
const adsCellProps = getAdsCellProps(params.row.id)
256238

257239
return (
258240
<Link
259241
href={buildMarketHref(params.row.id, params.row.chainId)}
260242
style={{ ...LinkCell, justifyContent: "flex-end" }}
261243
>
262244
<AprChip
263-
isBonus={isAuros || isKappaLab}
245+
isBonus={!!adsCellProps}
264246
baseApr={formatBps(params.value)}
265-
icons={
266-
isAuros || isKappaLab ? [<Ethena />, <Ethereal />] : undefined
267-
}
247+
icons={adsCellProps?.icons}
268248
adsComponent={adsComponent}
269249
/>
270250
</Link>

src/components/AdsBanners/AurosEthena/AurosEthenaMobileContent/index.tsx

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)