generated from 8iq/nodejs-hackathon-boilerplate-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(condo): DOMA-9367 added ServiceProblemsAlert component (#4917)
* feat(condo): DOMA-9367 added NotWorkingAlert component * feat(condo): DOMA-9367 added pages config prop * feat(condo): DOMA-9367 rename to ServiceProblemsAlert * fix(condo): DOMA-9367 remove close alert logic * fix(condo): DOMA-9367 change prop to serviceProblemsAlert * feat(condo): DOMA-9367 added banner prop to alert component
- Loading branch information
1 parent
c188f04
commit 32fe13d
Showing
7 changed files
with
94 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
apps/condo/domains/common/components/ServiceProblemsAlert.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import get from 'lodash/get' | ||
import { useRouter } from 'next/router' | ||
import { useMemo } from 'react' | ||
|
||
import { useFeatureFlags } from '@open-condo/featureflags/FeatureFlagsContext' | ||
import { Alert } from '@open-condo/ui' | ||
|
||
import { SERVICE_PROBLEMS_ALERT } from '@condo/domains/common/constants/featureflags' | ||
|
||
|
||
export const ServiceProblemsAlert = () => { | ||
const router = useRouter() | ||
|
||
const { useFlagValue } = useFeatureFlags() | ||
const serviceProblemsAlertConfig = useFlagValue(SERVICE_PROBLEMS_ALERT) | ||
|
||
const title = useMemo(() => get(serviceProblemsAlertConfig, 'title'), [serviceProblemsAlertConfig]) | ||
const description = useMemo(() => get(serviceProblemsAlertConfig, 'description'), [serviceProblemsAlertConfig]) | ||
const pages = useMemo(() => get(serviceProblemsAlertConfig, 'pages', []), [serviceProblemsAlertConfig]) | ||
|
||
const showOnPage = useMemo(() => pages.length === 0 || pages.some(page => router.pathname.includes(page)), | ||
[pages, router.pathname]) | ||
const isEmptyAlert = !title && !description | ||
|
||
if (isEmptyAlert || !showOnPage) { | ||
return null | ||
} | ||
|
||
return ( | ||
<Alert | ||
type='warning' | ||
message={title} | ||
description={description} | ||
banner | ||
showIcon={false} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters