Skip to content

Commit

Permalink
[EN-7378] feat(CV): remove preview image and use cv profile image
Browse files Browse the repository at this point in the history
  • Loading branch information
guillobits committed Sep 18, 2024
1 parent 6bacf41 commit 83c17f8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 65 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useCallback, useEffect, useState } from 'react';
import { CV } from 'src/api/types';
import { Grid, Img } from 'src/components/utils';
import { Grid } from 'src/components/utils';

import { CV_STATUS } from 'src/constants';
import { AdminZone } from 'src/constants/departements';
import { useMount, usePrevious } from 'src/hooks/utils';
import {
Expand Down Expand Up @@ -48,8 +47,6 @@ export const CVFicheEdition = ({
address,
userZone,
}: CVFicheEditionProps) => {
const [previewUrl, setPreviewUrl] = useState<string>();

const [imageUrl, setImageUrl] = useState<string>();

const prevPreviewGenerating = usePrevious(previewGenerating);
Expand All @@ -58,7 +55,6 @@ export const CVFicheEdition = ({
// Use hash to reload image if an update is done
const previewHash = Date.now();
const baseUrl = `${process.env.AWSS3_URL}${process.env.AWSS3_IMAGE_DIRECTORY}${cv.UserId}.${cv.status}`;
setPreviewUrl(`${baseUrl}.preview.jpg?${previewHash}`);
setImageUrl(`${baseUrl}.jpg?${previewHash}`);
}, [cv.UserId, cv.status]);

Expand All @@ -81,49 +77,6 @@ export const CVFicheEdition = ({
onChange={onChange}
disablePicture={disablePicture}
/>
{cv.urlImg && (
<div className="uk-card uk-card-default">
<div className="uk-card-body">
<h3 className="uk-card-title">
Photo de <span className="uk-text-primary">partage</span>
</h3>
</div>
<div className="uk-card-media-bottom">
<div className="uk-inline uk-width-expand uk-height-medium uk-width-expand uk-cover-container">
{previewUrl ? (
<Img cover src={previewUrl} alt="Preview" />
) : (
<div className="uk-height-medium uk-width-expand" />
)}

{(cv.status === CV_STATUS.Draft.value ||
previewGenerating) && (
<>
<div
className="uk-position-cover"
style={{
background: 'rgba(0, 0, 0, 0.8)',
}}
/>
<div className="uk-overlay uk-position-center uk-light">
{previewGenerating ? (
<div>
Génération de la prévisualisation en cours&nbsp;
<div
className="uk-margin-small-left"
data-uk-spinner="ratio: 0.6"
/>
</div>
) : (
<p>Veuillez sauvegarder ou publier le CV</p>
)}
</div>
</>
)}
</div>
</div>
</div>
)}
</Grid>

<Grid childWidths={['1-2@s']} row match>
Expand Down
12 changes: 3 additions & 9 deletions src/pages/cv/[url].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { PageCVContent } from 'src/components/partials/CV/PageCVContent';
import { StyledCVPage } from 'src/components/partials/CV/PageCVContent/PageCVContent.styles';
import { NewsletterPartial } from 'src/components/partials/common/NewsletterPartial';
import { Grid, Section, SimpleLink, Button } from 'src/components/utils';
import { CV_FILTERS_DATA } from 'src/constants';
import { CV_FILTERS_DATA, CV_STATUS } from 'src/constants';
import { GA_TAGS } from 'src/constants/tags';

interface CVPageProps {
Expand All @@ -29,6 +29,7 @@ const CVPage = ({ cv, exists = false, router }: CVPageProps) => {
const title = candidateExists
? `Entourage Pro\xa0: Aidez ${cv.user.candidat.firstName} à retrouver un emploi`
: '';
const urlImg = `${process.env.AWSS3_URL}${process.env.AWSS3_IMAGE_DIRECTORY}${cv.user.candidat.id}.${CV_STATUS.Published.value}.jpg`;

useEffect(() => {
if (cv) {
Expand Down Expand Up @@ -113,14 +114,7 @@ const CVPage = ({ cv, exists = false, router }: CVPageProps) => {
metaTitle={title}
metaUrl={link}
metaDescription={sharedDescription}
metaImage={
cv.urlImg
? `${process.env.AWSS3_CDN_URL}/${cv.urlImg.replace(
'.jpg',
'.preview.jpg'
)}`
: `${process.env.SERVER_URL}/static/img/entourage-pro-preview.jpg`
}
metaImage={urlImg}
metaType="profile"
>
<StyledCVPage>
Expand Down
12 changes: 4 additions & 8 deletions src/pages/cv/pdf/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CV } from 'src/api/types';
import { Layout } from 'src/components/Layout';
import { CVPDF } from 'src/components/cv';
import { Section } from 'src/components/utils';
import { CV_STATUS } from 'src/constants';

interface CVPDFPageProps {
cv: CV;
Expand All @@ -13,6 +14,8 @@ interface CVPDFPageProps {
}

const CVPDFPage = ({ cv, page, router }: CVPDFPageProps) => {
const urlImg = `${process.env.AWSS3_URL}${process.env.AWSS3_IMAGE_DIRECTORY}${cv.user.candidat.id}.${CV_STATUS.Published.value}.jpg`;

if (!cv) {
return (
<Layout title="Page introuvable - Entourage Pro">
Expand All @@ -33,14 +36,7 @@ const CVPDFPage = ({ cv, page, router }: CVPDFPageProps) => {
metaTitle={`Aidez ${cv.user.candidat.firstName} en partageant son CV.`}
metaUrl={`${process.env.SERVER_URL}${router.asPath}`}
metaDescription={cv.story}
metaImage={
cv.urlImg
? `${process.env.AWSS3_URL}/${cv.urlImg.replace(
'.jpg',
'.preview.jpg'
)}`
: `${process.env.SERVER_URL}/static/img/entourage-pro-preview.jpg`
}
metaImage={urlImg}
metaType="profile"
>
<div>
Expand Down

0 comments on commit 83c17f8

Please sign in to comment.