-
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.
feat: LBA-481 bouton de partage d'offres (#1534)
* feat: new icons * feat: embryon * feat: copy ui candidat ok * feat: ui candidat ok with tracking * feat: copie lien côté espace pro ok * feat: couleur correcte * feat: couleur corrigée * fix: correction séléction offre ft on startup * feat: utilisation constantes * feat: gestion cas lba recruteur sur france entière --------- Co-authored-by: Kevin Barnoin <[email protected]>
- Loading branch information
Showing
7 changed files
with
121 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { Button, Image, Text } from "@chakra-ui/react" | ||
import { useContext, useEffect, useState } from "react" | ||
import { ILbaItemFormation, ILbaItemFtJob, ILbaItemLbaCompany, ILbaItemLbaJob } from "shared" | ||
import { LBA_ITEM_TYPE_OLD, oldItemTypeToNewItemType } from "shared/constants/lbaitem" | ||
|
||
import { DisplayContext } from "@/context/DisplayContextProvider" | ||
|
||
const ShareLink = ({ item }: { item: ILbaItemFormation | ILbaItemFtJob | ILbaItemLbaCompany | ILbaItemLbaJob }) => { | ||
const [copied, setCopied] = useState(false) | ||
|
||
const { formValues } = useContext(DisplayContext) | ||
|
||
useEffect(() => { | ||
setCopied(false) | ||
}, [item.id]) | ||
|
||
const copyLink = (e) => { | ||
e.preventDefault() | ||
|
||
const link = | ||
item.ideaType === LBA_ITEM_TYPE_OLD.LBA && !formValues?.location?.value | ||
? `${window.location.origin}${window.location.pathname}?display=list&page=fiche&type=lba&itemId=${item.id}` | ||
: window.location.href | ||
navigator.clipboard.writeText(link).then(function () { | ||
setCopied(true) | ||
}) | ||
} | ||
|
||
return ( | ||
<Button | ||
sx={copied ? {} : { borderBottom: "1px solid #000091" }} | ||
mx={2} | ||
mb={4} | ||
px={0} | ||
pb={0} | ||
height={7} | ||
borderRadius={0} | ||
_hover={{ bg: "none" }} | ||
_focus={{ bg: "none" }} | ||
background="none" | ||
border="none" | ||
display="flex" | ||
alignItems="center" | ||
fontWeight={400} | ||
onClick={copyLink} | ||
data-tracking-id={`partager-${oldItemTypeToNewItemType(item.ideaType)}`} | ||
> | ||
{copied ? ( | ||
<> | ||
<Image mr={2} src="/images/icons/share_copied_icon.svg" aria-hidden={true} alt="" /> | ||
<Text fontSize={14} color="#18753C"> | ||
Lien copié ! | ||
</Text> | ||
</> | ||
) : ( | ||
<> | ||
<Image mr={2} src="/images/icons/share_icon.svg" aria-hidden={true} alt="" /> | ||
<Text fontSize={14} color="bluefrance.500"> | ||
Partager | ||
</Text> | ||
</> | ||
)} | ||
</Button> | ||
) | ||
} | ||
|
||
export default ShareLink |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.