Skip to content

Commit

Permalink
[EN-6274] feat(cv): integration page CV
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulEntourage committed Jul 26, 2023
1 parent 79ccffc commit 1c26a5f
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
'*.ts?(x)': 'yarn lint:fix',
'*.ts?(x)': ['yarn tsc-files', 'yarn lint:fix'],
'*.js?(x)': 'yarn lint:fix',
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"lint": "npx eslint src --ext js,jsx,ts,tsx",
"lint:fix": "npx eslint src --ext js,jsx,ts,tsx --fix",
"ts-check": "tsc -p tsconfig.json --noEmit",
"ts-check:hook": "tsc tsconfig.json --noEmit",
"format": "prettier --write './**/*.{js,jsx,md,json,ts,tsx}' --config .prettierrc.json",
"build": "next build",
"uikit-install": "cd ./node_modules/uikit && yarn",
Expand Down
2 changes: 1 addition & 1 deletion src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export class APIHandler {

// put

putUser(userId: string, params: UserDto): Promise<AxiosResponse> {
putUser(userId: string, params: Partial<UserDto>): Promise<AxiosResponse> {
return this.put(`/user/${userId}`, params);
}

Expand Down
5 changes: 5 additions & 0 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ export type User = {
};

export interface CV {
id?: string;
version: string;
profileImage: string;
profileImageObjectUrl: string;
user: {
candidat: {
firstName: string;
Expand Down Expand Up @@ -136,6 +140,7 @@ export interface CV {
}[];
experiences: {
description: string;
order: number;
skills: {
id: string;
name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { useCallback, useContext, useEffect, useState } from 'react';
import UIkit from 'uikit';
import { Api } from 'src/api';

import { CV, User } from 'src/api/types';
import { ButtonDownload } from 'src/components/backoffice/cv/ButtonDownload';
import { ButtonPost } from 'src/components/backoffice/cv/ButtonPost';
import { NoCV } from 'src/components/backoffice/cv/NoCV';
Expand All @@ -29,7 +30,12 @@ const pusher = new Pusher(process.env.PUSHER_API_KEY, {
forceTLS: true,
});

const ModalPreview = ({ imageUrl, cv }) => {
interface ModalPreviewProps {
imageUrl: string;
cv: CV;
}

const ModalPreview = ({ imageUrl, cv }: ModalPreviewProps) => {
const { onClose } = useModalContext();

return (
Expand All @@ -49,18 +55,23 @@ const ModalPreview = ({ imageUrl, cv }) => {
);
};

ModalPreview.propTypes = {
cv: CVShape.isRequired,
imageUrl: PropTypes.string.isRequired,
};

export const CVPageContent = ({ candidateId, cv, setCV }) => {
const [cvVersion, setCvVersion] = useState(undefined);
const [imageUrl, setImageUrl] = useState(undefined);
interface CVPageContentProps {
cv: CV;
candidateId: string;
setCV: (arg1: any) => void;
}

export const CVPageContent = ({
candidateId,
cv,
setCV,
}: CVPageContentProps) => {
const [cvVersion, setCvVersion] = useState<string>();
const [imageUrl, setImageUrl] = useState<string>();
const [previewGenerating, setPreviewGenerating] = useState(false);
const [pdfGenerating, setPdfGenerating] = useState(false);

const { user } = useContext(UserContext);
const { user } = useContext<{ user: User }>(UserContext);

const prevCV = usePrevious(cv);

Expand Down Expand Up @@ -155,25 +166,25 @@ export const CVPageContent = ({ candidateId, cv, setCV }) => {
};

Api.putUser(candidateId, userData)
.then(({ newUserData }) => {
res(newUserData);
.then((data) => {
res(data);
})
.catch((err) => {
rej(err);
});
} else {
res();
res(null);
}
});
};

const checkIfLastVersion = useCallback(
async (callback, isAutoSave) => {
async (callback, isAutoSave = false) => {
const {
data: { lastCvVersion },
} = await Api.getCVLastVersion(candidateId);

if (lastCvVersion > cvVersion) {
if (cvVersion && lastCvVersion > cvVersion) {
if (!isAutoSave) {
openModal(
<ModalConfirm
Expand Down Expand Up @@ -268,7 +279,7 @@ export const CVPageContent = ({ candidateId, cv, setCV }) => {
};
delete obj.id;
formData.append('cv', JSON.stringify(obj));
formData.append('autoSave', true);
formData.append('autoSave', '');
// post
return saveUserData(obj)
.then(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,31 @@ import { formEditCareerPath } from 'src/components/forms/schema/formEditCareerPa
import { openModal } from 'src/components/modals/Modal';
import { ModalEdit } from 'src/components/modals/Modal/ModalGeneric/ModalEdit';
import { ButtonIcon, Grid } from 'src/components/utils';
import { AMBITIONS_PREFIXES, BUSINESS_LINES } from 'src/constants';
import {
AMBITIONS_PREFIXES,
AmbitionsPrefixesType,
BUSINESS_LINES,
} from 'src/constants';
import { findConstantFromValue, sortByOrder } from 'src/utils';

export const CVEditCareerPath = ({ ambitions, businessLines, onChange }) => {
interface CVEditCareerPath {
ambitions: {
order: number;
name: string;
prefix: AmbitionsPrefixesType;
}[];
businessLines: {
order: number;
name: string;
}[];
onChange: (arg1: any) => void;
}

export const CVEditCareerPath = ({
ambitions,
businessLines,
onChange,
}: CVEditCareerPath) => {
const sortedAmbitions =
ambitions && ambitions.length > 0 ? sortByOrder(ambitions) : null;

Expand Down
17 changes: 12 additions & 5 deletions src/components/cv/CVFiche.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import PropTypes from 'prop-types';
import React from 'react';
import { v4 as uuid } from 'uuid';
import { CV } from 'src/api/types';
import { CVCareerPathSentence } from 'src/components/cv/CVCareerPathSentence';
import { CVCallToActions } from 'src/components/partials/CV/CVCallToActions';
import { Grid, Img, SimpleLink, Icon } from 'src/components/utils';
import { CONTRACTS } from 'src/constants';
import { DEPARTMENTS_FILTERS } from 'src/constants/departements';
Expand All @@ -14,12 +15,18 @@ import {
} from 'src/utils';
import { CVShape } from './CV.shape';

const uuidValue = uuid();

/**
* Le cv en public et en preview
*/
export const CVFiche = ({ cv, actionDisabled }) => {
const updateSharesCount = useUpdateSharesCount();

interface CVFicheProps {
cv: CV;
actionDisabled?: boolean;
}

export const CVFiche = ({ cv, actionDisabled }: CVFicheProps) => {
const experiences =
cv.experiences && cv.experiences.length > 0
? sortByOrder(cv.experiences)
Expand Down Expand Up @@ -285,7 +292,7 @@ export const CVFiche = ({ cv, actionDisabled }) => {
<ul className="uk-list">
{cv.skills.map(({ name }, i) => {
return (
<li id={i} key={i}>
<li id={`${i}-${uuidValue}`} key={`${i}-${uuidValue}`}>
{name}
</li>
);
Expand All @@ -300,7 +307,7 @@ export const CVFiche = ({ cv, actionDisabled }) => {
<ul className="uk-list">
{cv.passions.map(({ name }, i) => {
return (
<li id={i} key={i}>
<li id={`${i}-${uuidValue}`} key={`${i}-${uuidValue}`}>
{name}
</li>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PropTypes from 'prop-types';
import React, { useCallback, useEffect, useState } from 'react';
import { CV } from 'src/api/types';
import {
ExperiencesProfileCard,
InfoProfileCard,
Expand All @@ -15,7 +16,17 @@ import { Grid, Img } from 'src/components/utils';

import { CV_STATUS } from 'src/constants';
import { useMount, usePrevious } from 'src/hooks/utils';
import { CVShape } from './CV.shape';

interface VFicheEditionProps {
cv: CV;
onChange?: (arg1: any) => void;
disablePicture?: boolean;
email: string;
phone?: string;
previewGenerating: boolean;
address: string;
userZone: string;
}

export const CVFicheEdition = ({
cv,
Expand All @@ -26,7 +37,7 @@ export const CVFicheEdition = ({
phone,
address,
userZone,
}) => {
}: VFicheEditionProps) => {
const [previewUrl, setPreviewUrl] = useState(undefined);
const [imageUrl, setImageUrl] = useState(undefined);

Expand Down Expand Up @@ -151,22 +162,3 @@ export const CVFicheEdition = ({
</Grid>
);
};

CVFicheEdition.propTypes = {
cv: CVShape.isRequired,
onChange: PropTypes.func,
disablePicture: PropTypes.bool,
email: PropTypes.string.isRequired,
phone: PropTypes.string,
address: PropTypes.string,
previewGenerating: PropTypes.bool.isRequired,
userZone: PropTypes.string,
};

CVFicheEdition.defaultProps = {
onChange: () => {},
disablePicture: false,
phone: undefined,
address: undefined,
userZone: undefined,
};
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import React, { useContext, useEffect, useState } from 'react';
import { UserWithUserCandidate } from 'src/api/types';
import { Img } from 'src/components/utils';
import { CANDIDATE_USER_ROLES } from 'src/constants/users';
import { UserContext } from 'src/store/UserProvider';
import { isRoleIncluded } from 'src/utils/Finding';

interface ImgProfileProps {
user?: {
id: string;
firstName: string;
candidat?: {
cvs?: {
version: number;
urlImg: string;
}[];
};
};
user?: UserWithUserCandidate;
size?: number;
}

Expand Down
14 changes: 14 additions & 0 deletions src/components/utils/CarouselSwiper/swiper-augmentation.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint import/no-unresolved: "off" */
import { Pagination, Autoplay, Navigation } from 'swiper/modules';

declare module 'swiper/react' {
interface SwiperProps {
modules?: any[];
threshold?: number;
navigation: boolean;
autoplay: boolean;
pagination: {
clickable: boolean;
};
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"jsx": "preserve",
"baseUrl": "./"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "src/components/utils/CarouselSwiper/swiper-augmentation.d.ts"],
"exclude": ["node_modules"]
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14031,6 +14031,11 @@ ts-pnp@^1.1.6:
resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92"
integrity sha512-csd+vJOb/gkzvcCHgTGSChYpy5f1/XKNsmvBGO4JXS+z1v2HobugDz4s1IeFXM3wZB44uczs+eazB5Q/ccdhQw==

tsc-files@^1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/tsc-files/-/tsc-files-1.1.4.tgz#e0b2042a9494500f528769f52a0d0105a48457dd"
integrity sha512-RePsRsOLru3BPpnf237y1Xe1oCGta8rmSYzM76kYo5tLGsv5R2r3s64yapYorGTPuuLyfS9NVbh9ydzmvNie2w==

tsconfig-paths-webpack-plugin@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/tsconfig-paths-webpack-plugin/-/tsconfig-paths-webpack-plugin-4.0.1.tgz#a24651d0f69668a1abad38d3c2489855c257460d"
Expand Down

0 comments on commit 1c26a5f

Please sign in to comment.