-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
79 additions
and
120 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
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
27 changes: 13 additions & 14 deletions
27
...ponents/backoffice/profile/ProfileHelpInformationCard/ProfileHelpList/ProfileHelpList.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 |
---|---|---|
@@ -1,32 +1,31 @@ | ||
import React from 'react'; | ||
import { HelpNames } from 'src/api/types'; | ||
import { ParametresHelpCardContents } from 'src/constants/helps'; | ||
import { USER_ROLES } from 'src/constants/users'; | ||
import { | ||
StyledHelpList, | ||
StyledHelpListImgContainer, | ||
} from './ProfileHelpList.styles'; | ||
import { PARAMETRES_HELP_CARD_CONTENTS } from './ProfileHelpList.utils'; | ||
|
||
interface ProfileHelpListProps { | ||
helpList: { name: HelpNames }[]; | ||
role: string; | ||
role: typeof USER_ROLES.CANDIDATE | typeof USER_ROLES.COACH; | ||
} | ||
|
||
export const ProfileHelpList = ({ helpList, role }: ProfileHelpListProps) => { | ||
return ( | ||
<StyledHelpList data-testid="parametres-help-list"> | ||
{PARAMETRES_HELP_CARD_CONTENTS[role.toLowerCase()].map( | ||
({ icon, title, value }, index) => { | ||
if (!helpList.some((help) => help.name === value)) { | ||
return null; | ||
} | ||
return ( | ||
<li key={index}> | ||
<StyledHelpListImgContainer>{icon}</StyledHelpListImgContainer> | ||
{title} | ||
</li> | ||
); | ||
{ParametresHelpCardContents[role].map(({ icon, title, value }, index) => { | ||
if (!helpList.some((help) => help.name === value)) { | ||
return null; | ||
} | ||
)} | ||
return ( | ||
<li key={index}> | ||
<StyledHelpListImgContainer>{icon}</StyledHelpListImgContainer> | ||
{title} | ||
</li> | ||
); | ||
})} | ||
</StyledHelpList> | ||
); | ||
}; |
84 changes: 0 additions & 84 deletions
84
...s/backoffice/profile/ProfileHelpInformationCard/ProfileHelpList/ProfileHelpList.utils.tsx
This file was deleted.
Oops, something went wrong.
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,25 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { | ||
CANDIDATE_USER_ROLES, | ||
USER_ROLES, | ||
UserRole, | ||
} from 'src/constants/users'; | ||
import { isRoleIncluded } from 'src/utils'; | ||
|
||
export function useContextualRole(role: UserRole) { | ||
const [contextualRole, setContextualRole] = useState< | ||
typeof USER_ROLES.CANDIDATE | typeof USER_ROLES.COACH | ||
>(USER_ROLES.CANDIDATE); | ||
|
||
useEffect(() => { | ||
setContextualRole( | ||
isRoleIncluded(CANDIDATE_USER_ROLES, role) | ||
? USER_ROLES.CANDIDATE | ||
: USER_ROLES.COACH | ||
); | ||
}, [role]); | ||
|
||
return { | ||
contextualRole, | ||
}; | ||
} |
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