Skip to content

Commit

Permalink
[EN-4026] chore(inputs): continue testing
Browse files Browse the repository at this point in the history
  • Loading branch information
emile-bex committed Aug 18, 2023
1 parent 3612a1c commit ee6a061
Show file tree
Hide file tree
Showing 42 changed files with 294 additions and 240 deletions.
11 changes: 6 additions & 5 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import {
AmbitionsPrefixesType,
BusinessLineValue,
ExternalOfferOrigin,
HeardAboutValue,
} from 'src/constants';
import { AdminZone, Department } from 'src/constants/departements';
import { AdminRole, Gender, UserRole } from 'src/constants/users';

export type SocialMedia = 'facebook' | 'linkedin' | 'twitter';
export type SocialMedia = 'facebook' | 'linkedin' | 'twitter' |'whatsapp' | 'other';

export const APIRoutes = {
USERS: 'user',
Expand Down Expand Up @@ -125,7 +126,7 @@ export interface CV {
}[];
transport: string;
skills: {
id: string;
id?: string;
name: string;
order: number;
}[];
Expand All @@ -134,7 +135,7 @@ export interface CV {
order: number;
}[];
reviews: {
id: string;
id?: string;
name: string;
text: string;
status: string;
Expand All @@ -143,7 +144,7 @@ export interface CV {
description: string;
order: number;
skills: {
id: string;
id?: string;
name: string;
order: number;
}[];
Expand Down Expand Up @@ -376,7 +377,7 @@ export type ContactContactUs = {
email: string;
structure: string;
message: string;
heardAbout: object;
heardAbout: HeardAboutValue;
cgu: boolean;
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/backoffice/admin/AdminOpportunityList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const AdminOpportunityList = ({
</ButtonMultiple>
</HeaderBackoffice>
<OpportunityList
listRef={opportunityListRef}
innerRef={opportunityListRef}
tabFilters={tabFilters}
setTabFilters={setTabFilters}
search={search}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ from 'lodash';
import React, { useCallback, useEffect, useMemo } from 'react';
import UIkit from 'uikit';
import { ExtractFormSchemaValidation } from '../../../../forms/FormSchema';
import { Api } from 'src/api';
import { User, UserDto } from 'src/api/types';
import { useOnMemberFormSubmit } from 'src/components/backoffice/admin/useOnMemberFormSubmit';
Expand Down Expand Up @@ -52,12 +53,18 @@ export function EditMemberModal({ user, setUser }: EditMemberModal) {
}, Actions.UPDATE);

const handleMemberUpdateSubmit = useCallback(
async (fields, closeModal) => {
async (
fields: ExtractFormSchemaValidation<typeof formAddUser>,
closeModal
) => {
const updatedUser = await onSubmit(fields, closeModal);
try {
const userToLinkId = Array.isArray(fields.userToLinkId)
? fields.userToLinkId.map(({ value }) => value)
: fields.userToLinkId?.value;
const { data: updatedUserWithLinkedMember } = await Api.putLinkUser(
user.id,
fields.userToLinkId || null
userToLinkId || null
);

setUser(updatedUserWithLinkedMember);
Expand All @@ -81,7 +88,10 @@ export function EditMemberModal({ user, setUser }: EditMemberModal) {
description:
'Merci de modifier les informations que vous souhaitez concernant le membre.',
submitText: 'Modifier le membre',
onSubmit: async (fields, closeModal) => {
onSubmit: async (
fields: ExtractFormSchemaValidation<typeof formAddUser>,
closeModal
) => {
if (fields.role !== user.role) {
openModal(
<ModalConfirm
Expand Down
4 changes: 1 addition & 3 deletions src/components/backoffice/admin/useOnMemberFormSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ export function useOnMemberFormSubmit(
fields.organizationId?.value === CREATE_NEW_ORGANIZATION_VALUE;

try {
let {
organizationId: { value: organizationId },
} = fields;
let organizationId = fields.organizationId?.value;

if (shouldTryToCreateOrganization) {
const organizationFields = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ export const SendMailModalContent = ({
fetchOpportunities
);
const { onClose } = useModalContext();
const [textAreaContent, setTextAreaContent] = useState();
const handleDescription = (e) => {
setTextAreaContent(e.target.value);
};
const [textAreaContent, setTextAreaContent] = useState<string>();

const object = relance
? 'Relance - demande de contact'
: 'Demande de contact';

const description = relance ? (
<>
Vous pouvez ci-dessous envoyer un mail de relance pour le poste de
Expand Down Expand Up @@ -149,7 +147,7 @@ export const SendMailModalContent = ({
<div className="textarea-container">
<TextArea
title="Ajouter un message personnel"
onChange={handleDescription}
onChange={setTextAreaContent}
value={textAreaContent}
name="contact-description"
id="contact-description"
Expand Down
32 changes: 9 additions & 23 deletions src/components/cards/CandidatCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ import _ from 'lodash';
import moment from 'moment';
import { useRouter } from 'next/router';
import PropTypes from 'prop-types';
import React, { useContext } from 'react';
import React from 'react';

import {
FacebookShareButton,
LinkedinShareButton,
TwitterShareButton,
} from 'react-share';

import { Api } from 'src/api';
import { openModal } from 'src/components/modals/Modal';
import { ModalShareCV } from 'src/components/modals/Modal/ModalGeneric/StepperModal/ModalShareCV';
import { Grid, Img, SimpleLink, Icon } from 'src/components/utils';
import { AMBITIONS_PREFIXES, BUSINESS_LINES } from 'src/constants';
import { FB_TAGS, GA_TAGS } from 'src/constants/tags';
import { useUpdateSharesCount } from 'src/hooks';
import { fbEvent } from 'src/lib/fb';
import { gaEvent } from 'src/lib/gtag';
import { SharesCountContext } from 'src/store/SharesCountProvider';
import {
buildBusinessLineForSentence,
findConstantFromValue,
Expand Down Expand Up @@ -55,25 +54,12 @@ export const CandidatCard = ({
const sharedDescription = `La précarité n'exclut pas les compétences\xa0! Avec LinkedOut, aidons ${firstName} à retrouver un emploi en lui proposant un job ou en diffusant son CV\xa0!`;
const title = `LinkedOut\xa0: Aidez ${firstName} à retrouver un emploi`;

const { incrementSharesCount } = useContext(SharesCountContext);
const updateSharesCount = useUpdateSharesCount();

const openNewsletterModal = () => {
openModal(<ModalShareCV firstName={firstName} />);
};

const updateShareCount = (candidateId, type) => {
Api.postCVCount({
candidateId,
type,
})
.then(() => {
incrementSharesCount();
})
.catch((err) => {
console.error(err);
});
};

const linkToCV = `/cv/${url}?hideShareOptions=${!showShareOptions}`;

const sortedAmbitions =
Expand Down Expand Up @@ -292,14 +278,14 @@ export const CandidatCard = ({
<ul className="uk-iconnav">
<li>
<LinkedinShareButton
onShareWindowClose={() => {
onShareWindowClose={async () => {
gaEvent(
isCandidatsPage
? GA_TAGS.PAGE_GALERIE_PARTAGE_CV_LINKEDIN_CLIC
: GA_TAGS.HOME_PARTAGE_CV_LINKEDIN_CLIC
);
fbEvent(FB_TAGS.SHARE_CV_SEND);
updateShareCount(id, 'linkedin');
await updateSharesCount(id, 'linkedin');
openNewsletterModal();
}}
onClick={() => {
Expand All @@ -320,14 +306,14 @@ export const CandidatCard = ({
</li>
<li>
<FacebookShareButton
onShareWindowClose={() => {
onShareWindowClose={async () => {
gaEvent(
isCandidatsPage
? GA_TAGS.PAGE_GALERIE_PARTAGE_CV_FACEBOOK_CLIC
: GA_TAGS.HOME_PARTAGE_CV_FACEBOOK_CLIC
);
fbEvent(FB_TAGS.SHARE_CV_SEND);
updateShareCount(id, 'facebook');
await updateSharesCount(id, 'facebook');
openNewsletterModal();
}}
onClick={() => {
Expand All @@ -348,14 +334,14 @@ export const CandidatCard = ({
</li>
<li>
<TwitterShareButton
onShareWindowClose={() => {
onShareWindowClose={async () => {
gaEvent(
isCandidatsPage
? GA_TAGS.PAGE_GALERIE_PARTAGE_CV_TWITTER_CLIC
: GA_TAGS.HOME_PARTAGE_CV_TWITTER_CLIC
);
fbEvent(FB_TAGS.SHARE_CV_SEND);
updateShareCount(id, 'twitter');
await updateSharesCount(id, 'twitter');
openNewsletterModal();
}}
onClick={() => {
Expand Down
6 changes: 3 additions & 3 deletions src/components/cards/StoryProfileCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const StoryProfileCard = ({
onChange,
}: {
description?: string;
onChange?: (arg1: { story: string }) => void; // to be typed
onChange: (updatedStory: { story: string }) => void;
}) => {
return (
<div className="uk-card uk-card-default uk-card-body">
Expand All @@ -27,9 +27,9 @@ export const StoryProfileCard = ({
title="Édition - Mon histoire"
formSchema={formEditStory}
defaultValues={{ story: description }}
onSubmit={async (fields, closeModal) => {
onSubmit={(fields, closeModal) => {
closeModal();
await onChange({ ...fields });
onChange(fields);
}}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const CVCareerPathSentence = ({
fontSize: 'inherit',
}}
>
{sortedAmbitions[0].name || sortedAmbitions[0]}
{sortedAmbitions[0].name}
</span>
{sortedAmbitions.length > 1 && (
<>
Expand All @@ -63,7 +63,7 @@ export const CVCareerPathSentence = ({
fontSize: 'inherit',
}}
>
{sortedAmbitions[1].name || sortedAmbitions[1]}
{sortedAmbitions[1].name}
</span>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,11 @@ export const CVCareerPathSentenceNew = ({
J&apos;aimerais travailler{' '}
{sortedAmbitions[0].prefix ||
AMBITIONS_PREFIXES[0].label.toLowerCase()}{' '}
<span className="orange">
{sortedAmbitions[0].name || sortedAmbitions[0]}
</span>
<span className="orange">{sortedAmbitions[0].name}</span>
{sortedAmbitions.length > 1 && (
<>
{getAmbitionsLinkingSentence(sortedAmbitions)}
<span className="orange">
{sortedAmbitions[1].name || sortedAmbitions[1]}
</span>
<span className="orange">{sortedAmbitions[1].name}</span>
</>
)}
</>
Expand Down
2 changes: 1 addition & 1 deletion src/components/cv/CVEditCareerPath.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const CVEditCareerPath = ({
openModal(
<ModalEdit
title="Édition - Projet professionnel"
description="J'aimerais travailler dans ..."
description="J'aimerais travailler ..."
formSchema={formEditCareerPath}
defaultValues={defaultValues}
onSubmit={async (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import PropTypes from 'prop-types';
import React from 'react';
import { formEditTestimonial } from 'src/components/forms/schemas/formEditTestimonial';
import { openModal } from 'src/components/modals/Modal';
Expand All @@ -7,7 +6,17 @@ import { ModalEdit } from 'src/components/modals/Modal/ModalGeneric/ModalEdit';
import { Grid, ButtonIcon, Icon } from 'src/components/utils';
import { formatParagraph, sortByName } from 'src/utils';

export const CVEditReviews = ({ reviews, onChange }) => {
interface Review {
name: string;
text: string;
status: string;
}

interface CVEditReviewsProps {
reviews: Review[];
onChange: (updatedCV: { reviews: Review[] }) => void;
}
export const CVEditReviews = ({ reviews, onChange }: CVEditReviewsProps) => {
const MAX_REVIEWS = 3;

const sortedReviews = sortByName(reviews);
Expand All @@ -25,9 +34,9 @@ export const CVEditReviews = ({ reviews, onChange }) => {
<ModalEdit
title="Ajout - Ils me recommandent"
formSchema={formEditTestimonial}
onSubmit={async (fields, closeModal) => {
onSubmit={(fields, closeModal) => {
closeModal();
await onChange({
onChange({
reviews: [...reviews, fields],
});
}}
Expand All @@ -42,7 +51,7 @@ export const CVEditReviews = ({ reviews, onChange }) => {
{sortedReviews.length > 0 ? (
sortedReviews.map((review, i) => {
return (
<li id={i} key={i} className="">
<li id={i.toString()} key={i} className="">
<Grid
eachWidths={['auto', 'expand']}
className="uk-padding-small uk-padding-remove-horizontal"
Expand All @@ -67,10 +76,10 @@ export const CVEditReviews = ({ reviews, onChange }) => {
title="Édition - Ils me recommandent"
formSchema={formEditTestimonial}
defaultValues={{ ...review }}
onSubmit={async (fields, closeModal) => {
onSubmit={(fields, closeModal) => {
closeModal();
sortedReviews[i] = fields;
await onChange({ reviews: sortedReviews });
onChange({ reviews: sortedReviews });
}}
/>
);
Expand Down Expand Up @@ -106,17 +115,3 @@ export const CVEditReviews = ({ reviews, onChange }) => {
</div>
);
};
CVEditReviews.propTypes = {
reviews: PropTypes.arrayOf(
PropTypes.shape({
name: PropTypes.string.isRequired,
text: PropTypes.string.isRequired,
status: PropTypes.string.isRequired,
})
),
onChange: PropTypes.func,
};
CVEditReviews.defaultProps = {
reviews: [],
onChange: null,
};
Loading

0 comments on commit ee6a061

Please sign in to comment.