Skip to content
Draft
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
7 changes: 7 additions & 0 deletions packages/curve-ui-kit/src/hooks/useFeatureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ export const useManageSoftLiquidation = useAlphaChannel

/** Entire new app containing in-depth analyses for knowledgeable users */
export const useAnalyticsApp = useAlphaChannel

/**
* Phishing warning banner shown on localhost and production, hidden on preview,
* but forced on in CI so automated tests keep working
*/
export const usePhishingBanner = () =>
process.env.NODE_ENV === 'development' || defaultReleaseChannel === ReleaseChannel.Stable || Boolean(process.env.CI)
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { usePhishingBanner } from '@ui-kit/hooks/useFeatureFlags'
import { useDismissBanner } from '@ui-kit/hooks/useLocalStorage'
import { t } from '@ui-kit/lib/i18n'
import { Banner } from '@ui-kit/shared/ui/Banner'
Expand All @@ -10,10 +11,15 @@ const ONE_MONTH_MS = 30 * 24 * 60 * 60 * 1000 // 30 days in milliseconds
* The banner will reappear after one month if dismissed.
*/
export const PhishingWarningBanner = () => {
const { shouldShowBanner, dismissBanner } = useDismissBanner('phishing-warning-dismissed', ONE_MONTH_MS)
const shouldShowBanner = usePhishingBanner()
const { shouldShowBanner: isNotDismissed, dismissBanner } = useDismissBanner(
'phishing-warning-dismissed',
ONE_MONTH_MS,
)

return (
shouldShowBanner && (
shouldShowBanner &&
isNotDismissed && (
<Banner
subtitle={t`Always carefully check that your URL is ${URL}.`}
severity="warning"
Expand Down
Loading