Skip to content

Commit

Permalink
Merge pull request #413 from MTES-MCT/master
Browse files Browse the repository at this point in the history
release 21/09/2023
  • Loading branch information
gaspard-lonchampt authored Sep 21, 2023
2 parents 2101bb2 + 711b250 commit 0b8ea7f
Show file tree
Hide file tree
Showing 54 changed files with 1,570 additions and 617 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Le projet est divisé en 2 grandes briques distinctes :
- Application Flask servie par Gunicorn avec une API GraphQL
- [lien vers le dépôt](https://github.com/MTES-MCT/mobilic-api)

![Architecture](./archi.png)
![Architecture](./archi.jpg)

## Infrastructure

Expand Down
Binary file added archi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed archi.png
Binary file not shown.
175 changes: 175 additions & 0 deletions archi.xml

Large diffs are not rendered by default.

Binary file added common/assets/images/partner-logos/dht.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion common/assets/styles/root.scss
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
opacity: 0;
}

[href]:not(.fr-breadcrumb__link, .fr-link, .certificateBannerLink) {
[href]:not(.fr-breadcrumb__link, .fr-link) {
--underline-img: none;
}

Expand Down Expand Up @@ -317,3 +317,9 @@ video:not([href])[controls] {
linear-gradient(#000 0 0);
mask-composite: exclude;
}

.fr-checkbox-group {
input[type=checkbox]:disabled{
opacity: 0;
}
}
8 changes: 6 additions & 2 deletions common/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,12 @@ export class StoreSyncedWithLocalStorageProvider extends React.Component {
lastName,
timezoneName,
email,
creationTime,
birthDate,
hasConfirmedEmail,
hasActivatedEmail,
disabledWarnings
disabledWarnings,
surveyActions
},
commitImmediately = true
) =>
Expand All @@ -427,11 +429,13 @@ export class StoreSyncedWithLocalStorageProvider extends React.Component {
firstName,
lastName,
email,
creationTime,
birthDate,
timezoneName,
hasConfirmedEmail,
hasActivatedEmail,
disabledWarnings
disabledWarnings,
surveyActions
}
},
resolve,
Expand Down
23 changes: 23 additions & 0 deletions common/utils/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import {
formatDay,
formatTimeOfDay,
isDateBeforeNbDays,
now,
nowMilliseconds,
sameMinute,
Expand Down Expand Up @@ -47,6 +48,11 @@ import {
} from "./apiQueries";
import { hasPendingUpdates } from "../store/offline";
import { ACTIONS } from "../store/reducers/root";
import {
firstActionDateForSurvey,
hasNotSubmittedSurvey,
nbTimesSurveyWasDisplayed
} from "./surveys";

const ActionsContext = React.createContext(() => {});

Expand Down Expand Up @@ -309,6 +315,7 @@ class Actions {
api.registerResponseHandler("validateMission", {
onSuccess: async apiResponse => {
const userId = this.store.userId();
const userInfo = this.store.userInfo();
const missionResponse = apiResponse.data.activities.validateMission;
const parsedMission = parseMissionPayloadFromBackend(
missionResponse,
Expand All @@ -328,6 +335,22 @@ class Actions {
missionResponse.id,
6000
);
const surveyId = process.env.REACT_APP_SURVEY_EMPLOYEE_SOCIAL_IMPACT;
if (
surveyId &&
userInfo.surveyActions &&
hasNotSubmittedSurvey(userInfo.surveyActions, surveyId) &&
nbTimesSurveyWasDisplayed(userInfo.surveyActions, surveyId) === 1 &&
isDateBeforeNbDays(
firstActionDateForSurvey(userInfo.surveyActions, surveyId),
7
)
) {
modals.open("typeformModal", {
typeformId: surveyId,
userId: userId
});
}
}
});

Expand Down
15 changes: 15 additions & 0 deletions common/utils/apiFragments.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ export const REGULATION_COMPUTATIONS_FRAGMENT = gql`
}
`;

export const OBSERVED_INFRACTIONS_FRAGMENT = gql`
fragment ObservedInfractions on ObservedInfraction {
sanction
date
isReportable
isReported
label
description
type
unit
extra
}
`;

export const FULL_TEAM_FRAGMENT = gql`
fragment FullTeamData on Team {
id
Expand Down Expand Up @@ -199,6 +213,7 @@ export const CONTROL_DATA_FRAGMENT = gql`
controlBulletinCreationTime
vehicleRegistrationNumber
note
nbReportedInfractions
controlBulletin {
locationLieu
}
Expand Down
61 changes: 56 additions & 5 deletions common/utils/apiQueries.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
FULL_MISSION_FRAGMENT,
FULL_TEAM_FRAGMENT,
REGULATION_COMPUTATIONS_FRAGMENT,
OBSERVED_INFRACTIONS_FRAGMENT,
WORK_DAYS_DATA_FRAGMENT
} from "./apiFragments";
import { nowMilliseconds } from "./time";
Expand Down Expand Up @@ -341,12 +342,17 @@ export const CONTROLLER_READ_MISSION_DETAILS = gql`
export const CONTROLLER_READ_CONTROL_DATA_NO_LIC = gql`
${CONTROL_BULLETIN_FRAGMENT}
${CONTROL_DATA_FRAGMENT}
${OBSERVED_INFRACTIONS_FRAGMENT}
query readControlDataNoLic($controlId: Int!) {
controlData(controlId: $controlId) {
...ControlData
controlBulletin {
...ControlBulletin
}
observedInfractions {
...ObservedInfractions
}
reportedInfractionsLastUpdateTime
}
}
`;
Expand All @@ -355,6 +361,7 @@ export const CONTROLLER_READ_CONTROL_DATA = gql`
${COMPANY_SETTINGS_FRAGMENT}
${FRAGMENT_LOCATION_FULL}
${REGULATION_COMPUTATIONS_FRAGMENT}
${OBSERVED_INFRACTIONS_FRAGMENT}
${CONTROL_BULLETIN_FRAGMENT}
${CONTROL_DATA_FRAGMENT}
query readControlData($controlId: Int!) {
Expand Down Expand Up @@ -459,6 +466,10 @@ export const CONTROLLER_READ_CONTROL_DATA = gql`
regulationComputationsByDay {
...RegulationComputations
}
observedInfractions {
...ObservedInfractions
}
reportedInfractionsLastUpdateTime
}
}
`;
Expand Down Expand Up @@ -1989,6 +2000,24 @@ export const CONTROLLER_SAVE_CONTROL_BULLETIN = gql`
}
`;

export const CONTROLLER_SAVE_REPORTED_INFRACTIONS = gql`
${OBSERVED_INFRACTIONS_FRAGMENT}
mutation controllerSaveReportedInfractions(
$controlId: Int
$reportedInfractions: [ReportedInfractionInput]
) {
controllerSaveReportedInfractions(
controlId: $controlId
reportedInfractions: $reportedInfractions
) {
observedInfractions {
...ObservedInfractions
}
reportedInfractionsLastUpdateTime
}
}
`;

export const CONTROLLER_USER_CONTROLS_QUERY = gql`
${CONTROL_DATA_FRAGMENT}
query controllerUser(
Expand Down Expand Up @@ -2206,14 +2235,22 @@ export const EDIT_COMPANIES_COMMUNICATION_SETTING = gql`
}
`;

export const ADD_CERTIFICATION_INFO_RESULT = gql`
mutation addCertificateInfoResult(
$employmentId: Int!
export const SNOOZE_CERTIFICATION_INFO = gql`
mutation snoozeCertificateInfo($employmentId: Int!) {
snoozeCertificateInfo(employmentId: $employmentId) {
success
}
}
`;

export const ADD_SCENARIO_TESTING_RESULT = gql`
mutation addScenarioTestingResult(
$userId: Int!
$scenario: ScenarioEnum!
$action: ActionEnum!
) {
addCertificateInfoResult(
employmentId: $employmentId
addScenarioTestingResult(
userId: $userId
scenario: $scenario
action: $action
) {
Expand Down Expand Up @@ -2253,3 +2290,17 @@ export const CONTROL_LOCATION_QUERY = gql`
}
}
`;

export const CREATE_SURVEY_ACTION = gql`
mutation createSurveyAction(
$userId: Int!
$surveyId: String!
$action: SurveyActionEnum!
) {
createSurveyAction(userId: $userId, surveyId: $surveyId, action: $action) {
surveyId
creationTime
action
}
}
`;
14 changes: 12 additions & 2 deletions common/utils/loadUserData.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ const USER_QUERY = gql`
query user($id: Int!, $activityAfter: TimeStamp) {
user(id: $id) {
id
creationTime
surveyActions {
surveyId
creationTime
action
}
firstName
lastName
birthDate
Expand Down Expand Up @@ -238,14 +244,16 @@ export async function syncUser(userPayload, api, store) {
firstName,
lastName,
email,
creationTime,
birthDate,
timezoneName,
shouldUpdatePassword,
hasConfirmedEmail,
hasActivatedEmail,
disabledWarnings,
missions: missionsPayload,
employments
employments,
surveyActions
} = userPayload;

onLogIn(shouldUpdatePassword);
Expand Down Expand Up @@ -275,11 +283,13 @@ export async function syncUser(userPayload, api, store) {
firstName,
lastName,
email,
creationTime,
timezoneName,
birthDate,
hasConfirmedEmail,
hasActivatedEmail,
disabledWarnings
disabledWarnings,
surveyActions
},
false
)
Expand Down
3 changes: 2 additions & 1 deletion common/utils/regulation/alertTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const ALERT_TYPES = {
maximumWorkDayTime: "maximumWorkDayTime",
minimumWorkDayBreak: "minimumWorkDayBreak",
maximumUninterruptedWorkTime: "maximumUninterruptedWorkTime",
maximumWorkedDaysInWeek: "maximumWorkedDaysInWeek"
maximumWorkedDaysInWeek: "maximumWorkedDaysInWeek",
noPaperLic: "noLic"
};

export const ALERT_TYPE_PROPS_SIMPLER = {
Expand Down
Loading

0 comments on commit 0b8ea7f

Please sign in to comment.