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 363df77 commit 3612a1c
Show file tree
Hide file tree
Showing 27 changed files with 775 additions and 1,477 deletions.
6 changes: 0 additions & 6 deletions cypress/fixtures/opportunity-admin-res.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"endOfContract": null,
"isPartTime": false,
"numberOfPositions": 1,
"beContacted": false,
"message": "Bonjour Candidat",
"driversLicense": true,
"workingHours": "3j",
Expand Down Expand Up @@ -156,7 +155,6 @@
"endOfContract": null,
"isPartTime": false,
"numberOfPositions": 1,
"beContacted": false,
"message": null,
"driversLicense": false,
"workingHours": null,
Expand Down Expand Up @@ -266,7 +264,6 @@
"endOfContract": "2022-02-17",
"isPartTime": true,
"numberOfPositions": 29,
"beContacted": true,
"message": null,
"driversLicense": false,
"workingHours": null,
Expand Down Expand Up @@ -414,7 +411,6 @@
"endOfContract": null,
"isPartTime": false,
"numberOfPositions": 1,
"beContacted": false,
"message": null,
"driversLicense": false,
"workingHours": null,
Expand Down Expand Up @@ -524,7 +520,6 @@
"endOfContract": "2021-10-30",
"isPartTime": true,
"numberOfPositions": 6,
"beContacted": true,
"message": null,
"driversLicense": false,
"workingHours": null,
Expand Down Expand Up @@ -729,7 +724,6 @@
"endOfContract": null,
"isPartTime": true,
"numberOfPositions": 6,
"beContacted": true,
"message": null,
"driversLicense": false,
"workingHours": null,
Expand Down
1 change: 0 additions & 1 deletion cypress/fixtures/opportunity-res.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"isExternal": false,
"isPartTime": false,
"numberOfPositions": 1,
"beContacted": false,
"driversLicense": false,
"id": "e80ece3a-7f14-4eea-9fe6-7244c5c42b5c",
"isPublic": false,
Expand Down
13 changes: 8 additions & 5 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ContactContactUs,
ContactCandidate,
ContactNewsletter,
ExternalOpportunity,
ExternalOpportunityDto,
Opportunity,
OpportunityJoin,
OpportunityUserEvent,
Expand All @@ -23,6 +23,7 @@ import {
UserDto,
OrganizationDto,
ExternalMessage,
OpportunityDto,
} from './types';

export class APIHandler {
Expand Down Expand Up @@ -302,11 +303,13 @@ export class APIHandler {

// post

postOpportunity(params: Opportunity): Promise<AxiosResponse> {
postOpportunity(params: OpportunityDto): Promise<AxiosResponse> {
return this.post('/opportunity', params);
}

postExternalOpportunity(params: ExternalOpportunity): Promise<AxiosResponse> {
postExternalOpportunity(
params: ExternalOpportunityDto
): Promise<AxiosResponse> {
return this.post('/opportunity/external', params);
}

Expand Down Expand Up @@ -334,15 +337,15 @@ export class APIHandler {

putOpportunity(
opportunityId: string,
params: Opportunity
params: Partial<OpportunityDto>
): Promise<AxiosResponse> {
return this.put(`/opportunity/${opportunityId}`, params);
}

putExternalOpportunity(
opportunityId: string,
candidateId: string,
params: ExternalOpportunity
params: Partial<ExternalOpportunityDto>
): Promise<AxiosResponse> {
return this.put(
`/opportunity/external/${opportunityId}/${candidateId}`,
Expand Down
105 changes: 53 additions & 52 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,75 +210,76 @@ export type Opportunity = {
companyDescription: string;
skills: string;
prerequisites: string;
department: string;
department: Department;
contract: ContractValue;
startOfContract: string;
endOfContract: string;
isPartTime: boolean;
numberOfPositions: number;
beContacted: boolean;
message: string;
driversLicense: boolean;
workingHours: string;
salary: string;
otherInfo: string;
businessLines: { name: string; order: string }[];
businessLines: { name: BusinessLineValue; order: number }[];
candidatesIds: string[];
isAdmin: boolean;
shouldSendNotifications: boolean;
isCopy: boolean;
locations: object;
visit: string;
visitor: string;
urlParams: object;
createdAt: string;
};

/*
type OpportunityDto = {
'title': string,
'isPublic': boolean,
'isValidated',
'isArchived',
'isExternal',
'link',
'externalOrigin',
'company',
'recruiterName',
'recruiterFirstName',
'recruiterMail',
'contactMail',
'recruiterPosition',
'recruiterPhone',
'date',
'address',
'description',
'companyDescription',
'skills',
'prerequisites',
'department',
'contract',
'startOfContract',
'endOfContract',
'isPartTime',
'numberOfPositions',
'beContacted',
'message',
'driversLicense',
'workingHours',
'salary',
'otherInfo',
'businessLines',
candidatesIds
isAdmin
shouldSendNotifications
isCopy
locations
visit
visitor
urlParams
export interface PleziTrackingData {
visit?: string;
visitor?: string;
urlParams?: {
utm?: string;
utm_medium?: string;
utm_source?: string;
gclid?: string;
referer?: string;
};
}
*/

export type OpportunityDto = {
title: string;
isPublic: boolean;
isValidated?: boolean;
isArchived?: boolean;
company: string;
recruiterName: string;
recruiterFirstName: string;
recruiterMail: string;
contactMail?: string;
recruiterPosition: string;
recruiterPhone: string;
date: string;
description: string;
companyDescription: string;
department?: Department;
address?: string;
contract: ContractValue;
startOfContract?: string;
endOfContract?: string;
isPartTime: boolean;
message: string;
driversLicense: boolean;
workingHours: string;
salary: string;
otherInfo: string;
businessLines?: { name: BusinessLineValue; order: number }[];
candidatesIds: string[];
isAdmin?: boolean;
shouldSendNotifications?: boolean;
isCopy?: boolean;
locations?: { department: Department; address: string }[];
visit?: PleziTrackingData['visit'];
visitor?: PleziTrackingData['visitor'];
urlParams?: PleziTrackingData['urlParams'];
};

export type Skill = {
id: string;
Expand Down Expand Up @@ -333,21 +334,21 @@ export interface OpportunityWithOpportunityUsers extends Opportunity {
opportunityUsers: OpportunityUser;
}

export type ExternalOpportunity = {
export type ExternalOpportunityDto = {
title: string;
company: string;
contract: ContractValue;
startOfContract?: string;
endOfContract?: string;
isPartTime?: string;
businessLines?: { name: string; order: string }[];
isPartTime?: boolean;
businessLines?: { name: BusinessLineValue; order: number }[];
department: Department;
link: string;
description: string;
externalOrigin?: ExternalOfferOrigin;
date: string;
candidateId: string;
status?: string;
status?: number;
};

export type OpportunityUserEvent = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import moment from 'moment';
import PropTypes from 'prop-types';
import React, { useRef } from 'react';
import UIkit from 'uikit';
import { Api } from 'src/api';
Expand All @@ -13,7 +12,17 @@ import { OpportunityList } from 'src/components/opportunities/OpportunityList';
import { ButtonMultiple } from 'src/components/utils';
import { Icon } from 'src/components/utils/Icon';
import { useIsDesktop } from 'src/hooks/utils';
import { AnyToFix } from 'src/utils/Types';

interface AdminOpportunityListProps {
filters: AnyToFix; // to be typed
setFilters: (updatedFilters: AnyToFix) => void;
setTabFilters: (updatedFilters: AnyToFix) => void;
tabFilters: AnyToFix[];
search?: string;
setSearch: (search?: string) => void;
resetFilters: () => void;
}
export const AdminOpportunityList = ({
search,
filters,
Expand All @@ -22,10 +31,10 @@ export const AdminOpportunityList = ({
setTabFilters,
setSearch,
resetFilters,
}) => {
}: AdminOpportunityListProps) => {
const isDesktop = useIsDesktop();

const opportunityListRef = useRef();
const opportunityListRef = useRef<{ fetchData: () => Promise<void> }>();

const opportunityModalProps = {
defaultValues: {
Expand All @@ -34,7 +43,7 @@ export const AdminOpportunityList = ({
isAdmin: true,
callback: opportunityListRef?.current?.fetchData,
modalTitle: 'Ajouter une nouvelle offre',
schema: formAddOpportunityAsAdmin,
formSchema: formAddOpportunityAsAdmin,
};

return (
Expand Down Expand Up @@ -66,15 +75,14 @@ export const AdminOpportunityList = ({
try {
await Api.postExternalOpportunity({
...fields,
status: parseInt(fields.status, 10),
startOfContract: fields.startOfContract || null,
endOfContract: fields.endOfContract || null,
department: fields.department.value,
candidateId: fields.candidateId.value,
date: moment().toISOString(),
businessLines: fields.businessLines
? fields.businessLines.map(
(businessLine, index) => {
return {
name: businessLine,
name: businessLine.value,
order: index,
};
}
Expand Down Expand Up @@ -107,7 +115,7 @@ export const AdminOpportunityList = ({
</ButtonMultiple>
</HeaderBackoffice>
<OpportunityList
ref={opportunityListRef}
listRef={opportunityListRef}
tabFilters={tabFilters}
setTabFilters={setTabFilters}
search={search}
Expand All @@ -120,23 +128,3 @@ export const AdminOpportunityList = ({
</>
);
};

AdminOpportunityList.propTypes = {
search: PropTypes.string,
filters: PropTypes.shape({}),
setFilters: PropTypes.func,
tabFilters: PropTypes.arrayOf(PropTypes.shape({})),
setTabFilters: PropTypes.func,
setSearch: PropTypes.func,
resetFilters: PropTypes.func,
};

AdminOpportunityList.defaultProps = {
search: undefined,
filters: {},
setFilters: () => {},
tabFilters: {},
setTabFilters: () => {},
setSearch: () => {},
resetFilters: () => {},
};
2 changes: 1 addition & 1 deletion src/components/backoffice/admin/useOnMemberFormSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function useOnMemberFormSubmit(
let userFields: UserDto;
let name: string;
const shouldTryToCreateOrganization =
fields.organizationId.value === CREATE_NEW_ORGANIZATION_VALUE;
fields.organizationId?.value === CREATE_NEW_ORGANIZATION_VALUE;

try {
let {
Expand Down
9 changes: 0 additions & 9 deletions src/components/forms/FormWithValidation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,6 @@ export function FormWithValidation<S extends FormSchema<AnyCantFix>>({
const onValidForm: SubmitHandler<ExtractFormSchemaValidation<S>> =
useCallback(
(formValues) => {
/* const mutatedFormValues = Object.keys(formValues).reduce(
(acc, curr) => {
return {
...acc,
[curr]: getValueFromFormField(formValues[curr]),
};
},
{}
); */
onSubmit(formValues, (msg) => {
setError(msg);
});
Expand Down
Loading

0 comments on commit 3612a1c

Please sign in to comment.