-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
M2-6109: [FE] [Web App] Header - Update to Include Subject and Respon…
…dent (#442) This PR creates a `MultiInformantBadge` component that is shown during the completion of an activity in a multi-informant context. The component displays itself when the following are true: - The `enableMultiInformant` feature flag is turned on - The multi-informant state has been set. This state is set during the validation of multi-informant parameters in the `ValidateTakeNowParams` component.
- Loading branch information
1 parent
3b70529
commit d7653cb
Showing
10 changed files
with
134 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
export type MultiInformantSubject = { | ||
id: string; | ||
secretId: string | null; | ||
nickname: string | null; | ||
}; | ||
|
||
export type MultiInformantState = { | ||
sourceSubjectId?: string; | ||
targetSubjectId?: string; | ||
sourceSubject?: MultiInformantSubject; | ||
targetSubject?: MultiInformantSubject; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { useMultiInformantState } from '~/entities/applet/model/hooks'; | ||
import { MultiInformantBadgeTile } from '~/features/TakeNow/ui/MultiInformantBadgeTile'; | ||
import { Theme } from '~/shared/constants'; | ||
import { Box } from '~/shared/ui'; | ||
import { useLaunchDarkly } from '~/shared/utils/hooks/useLaunchDarkly'; | ||
|
||
const borderSize = 1; | ||
|
||
export const MultiInformantBadge = () => { | ||
const { getMultiInformantState, isInMultiInformantFlow } = useMultiInformantState(); | ||
const { flags: featureFlags } = useLaunchDarkly(); | ||
|
||
if (!isInMultiInformantFlow() || !featureFlags.enableMultiInformant) { | ||
return null; | ||
} | ||
|
||
const { sourceSubject, targetSubject } = getMultiInformantState(); | ||
|
||
if (!sourceSubject || !targetSubject) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Box | ||
display="flex" | ||
padding={`${4 - borderSize}px`} | ||
alignItems="center" | ||
gap="4px" | ||
width="192px" | ||
borderRadius="8px" | ||
border={`${borderSize}px solid ${Theme.colors.light.surfaceVariant}`} | ||
> | ||
<MultiInformantBadgeTile type="Respondent" subject={sourceSubject} /> | ||
<MultiInformantBadgeTile type="Subject" subject={targetSubject} /> | ||
</Box> | ||
); | ||
}; |
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,55 @@ | ||
import Tooltip from '@mui/material/Tooltip'; | ||
|
||
import { MultiInformantSubject } from '~/abstract/lib/types/multiInformant'; | ||
import { Theme } from '~/shared/constants'; | ||
import { Box } from '~/shared/ui'; | ||
|
||
type MultiInformantBadgeTileProps = { | ||
type: 'Subject' | 'Respondent'; | ||
subject: MultiInformantSubject; | ||
}; | ||
|
||
export const MultiInformantBadgeTile = ({ subject, type }: MultiInformantBadgeTileProps) => { | ||
const { id, secretId, nickname } = subject; | ||
let text = secretId ?? id; | ||
if (nickname) { | ||
text += `, ${nickname}`; | ||
} | ||
|
||
const tooltipText = `${type}: ${text}`; | ||
|
||
const backgroundColor = type === 'Subject' ? Theme.colors.light.inverseOnSurface : 'transparent'; | ||
|
||
return ( | ||
<Box | ||
display="flex" | ||
padding="8px" | ||
alignItems="center" | ||
gap="8px" | ||
flex="1 0 0" | ||
borderRadius="4px" | ||
width="78px" | ||
height="100%" | ||
sx={{ backgroundColor, cursor: 'default' }} | ||
> | ||
<Tooltip title={tooltipText}> | ||
<p | ||
style={{ | ||
overflow: 'hidden', | ||
color: Theme.colors.light.onSurface, | ||
textOverflow: 'ellipsis', | ||
|
||
fontSize: '16px', | ||
fontStyle: 'normal', | ||
fontWeight: 400, | ||
lineHeight: '24px', | ||
letterSpacing: '0.5px', | ||
whiteSpace: 'nowrap', | ||
}} | ||
> | ||
{text} | ||
</p> | ||
</Tooltip> | ||
</Box> | ||
); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from './ValidateTakeNowParams'; | ||
export * from './MultiInformantBadge'; | ||
export * from './MultiInformantBadgeTile'; |
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