Skip to content

Commit

Permalink
fix: crisp env variable usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementNumericite committed Feb 28, 2024
1 parent ef5e731 commit 12803b0
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions webapp/src/components/support/Crisp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,37 @@ type CrispProps = {
onClose: () => void;
}

const crispToken = process.env.NEXT_PUBLIC_CRISP_TOKEN as string

const CrispChat = (props: CrispProps) => {
const { user, onClose } = props;
useEffect(() => {
Crisp.configure(process.env.NEXT_PUBLIC_CRISP_TOKEN as string, {
autoload: false,
});
Crisp.setTokenId(`cje-token-crisp-${user.id.toString()}`)
if (user.firstName && user.lastName) Crisp.user.setNickname(`${user.firstName} ${user.lastName}`)
if (user.userEmail) Crisp.user.setEmail(`${user.userEmail}`)
if (user.status_image) {
Crisp.session.setData({
hasCjePass: user.status_image === 'approved'
if (crispToken) {
Crisp.configure(crispToken, {
autoload: false,
});
Crisp.setTokenId(`cje-token-crisp-${user.id.toString()}`)
if (user.firstName && user.lastName) Crisp.user.setNickname(`${user.firstName} ${user.lastName}`)
if (user.userEmail) Crisp.user.setEmail(`${user.userEmail}`)
if (user.status_image) {
Crisp.session.setData({
hasCjePass: user.status_image === 'approved'
})
}

// NEED DOMAIN NAME TO SET AVATAR => TODO LATER
// if (user.status_image === 'approved' && user.image && user.image.url) {
// Crisp.user.setAvatar(user.image.url)
// }

Crisp.chat.open()
Crisp.chat.show()
Crisp.chat.onChatClosed(() => {
Crisp.chat.hide()
onClose()
})
}

// NEED DOMAIN NAME TO SET AVATAR => TODO LATER
// if (user.status_image === 'approved' && user.image && user.image.url) {
// Crisp.user.setAvatar(user.image.url)
// }

Crisp.chat.open()
Crisp.chat.show()
Crisp.chat.onChatClosed(() => {
Crisp.chat.hide()
onClose()
})
}, [])
})

return null
}
Expand Down

0 comments on commit 12803b0

Please sign in to comment.