Skip to content

Commit

Permalink
Merge branch 'master' of github.com:SocialGouv/fce
Browse files Browse the repository at this point in the history
  • Loading branch information
ImenOuidou committed Nov 25, 2024
2 parents 2f02eac + f1de221 commit 6aa4d44
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 302 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [27.106.2](https://github.com/SocialGouv/fce/compare/v27.106.1...v27.106.2) (2024-11-07)


### Bug Fixes

* fix marche publiques sort ([#356](https://github.com/SocialGouv/fce/issues/356)) ([36f4ed5](https://github.com/SocialGouv/fce/commit/36f4ed5bc609d0264bbd23a73af08be2c643e8d2))

## [27.106.1](https://github.com/SocialGouv/fce/compare/v27.106.0...v27.106.1) (2024-10-14)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fce",
"version": "27.106.1",
"version": "27.106.2",
"description": "",
"author": "commit42",
"private": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { formatSiret } from "../../../../../helpers/utils";
import { formatUpperCase } from "../../../../../utils/entreprise/entreprise";
import { getCodePostal } from "../../../../../utils/establishment/establishment";

// Suppose this function is imported or defined
export const getCity = (marche) =>
marche?.etablissement?.libellecommuneetablissement ||
marche?.etablissement?.libellecommune2etablissement;
Expand All @@ -25,22 +24,39 @@ export const useSortableData = (items, config = null) => {
if (sortConfig.key === "city") {
aValue = getCodePostal(a?.etablissement); // Retrieve city using getCity
bValue = getCodePostal(b?.etablissement);
console.log(bValue);
} else if (sortConfig.key === "acheteur") {
aValue = getAcheteur(a);
bValue = getAcheteur(b);
} else if (
sortConfig.key === "montant" ||
sortConfig.key === "dureeMois"
) {
// Convertir 'montant' en nombre
aValue = parseFloat(a[sortConfig.key]);
bValue = parseFloat(b[sortConfig.key]);
} else {
aValue = a[sortConfig.key];
bValue = b[sortConfig.key];
}

if (aValue < bValue) {
return sortConfig.direction === "ascending" ? -1 : 1;
}
if (aValue > bValue) {
return sortConfig.direction === "ascending" ? 1 : -1;
// Gérer les valeurs nulles ou indéfinies
if (aValue == null) return 1;
if (bValue == null) return -1;

// Comparaison appropriée en fonction du type
if (typeof aValue === "number" && typeof bValue === "number") {
return sortConfig.direction === "ascending"
? aValue - bValue
: bValue - aValue;
} else {
if (aValue < bValue) {
return sortConfig.direction === "ascending" ? -1 : 1;
}
if (aValue > bValue) {
return sortConfig.direction === "ascending" ? 1 : -1;
}
return 0;
}
return 0;
});
}
return sortableItems;
Expand Down
7 changes: 6 additions & 1 deletion src/client/src/components/PublicPage/Help/Help.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import React from "react";
import { Link } from "react-router-dom";

import UsersFeedback from "../../../containers/UsersFeedback";
import Config from "../../../services/Config";
import LoadSpinner from "../../shared/LoadSpinner";

const Help = ({ pageData = null, isLoading, hasError }) => {
const strapiPath = Config.get("strapi.domain");
if (hasError) {
return (
<div className="page content">
Expand Down Expand Up @@ -41,7 +43,10 @@ const Help = ({ pageData = null, isLoading, hasError }) => {
<div className="help-video__title">{item.titre}</div>
{/* eslint-disable-next-line jsx-a11y/media-has-caption */}
<video className="help-video__video" controls>
<source src={item.video.url} type="video/mp4" />
<source
src={`${strapiPath}${item.video.url}`}
type="video/mp4"
/>
<p>
Votre navigateur ne prend pas en charge les vidéos
HTML5. Voici{" "}
Expand Down
13 changes: 10 additions & 3 deletions src/client/src/components/RequestAccessForm/RequestAccessForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@ import FormSubmit from "../Login/steps/Form/FormSubmit";
import StepForm from "../Login/steps/Form/StepForm";

const submitForm = async (data) => {
const response = await Http.post("/createAccount", data);

return response.data;
try {
const response = await Http.post("/createAccount", data);
return response.data;
} catch (error) {
console.error("Error submitting form:", error);
return {
error: error.response?.data || "An unknown error occurred",
success: false,
};
}
};

const alreadyAcceptedEmailDomains = [
Expand Down
2 changes: 1 addition & 1 deletion src/client/src/components/UsersFeedback/UsersFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const UsersFeedback = ({
const handleChange = (action) => (e) => {
dispatch({ payload: e.target.value, type: action });
};
const [thumbup, setThumbup] = useState(false);
const [thumbup, setThumbup] = useState(true);
const [thumbdown, setThumbdown] = useState(false);
const [isOpenModal, setIsOpenModal] = useState(false);
const handleOpenModal = () => {
Expand Down
52 changes: 30 additions & 22 deletions src/server/src/models/FceUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ export default class FceUser {
try {
const response = await axios.post(LOGIN_ENDPOINT, {
identifier: strapiUser,
password: strapiPassword
password: strapiPassword,
});
this.token = response.data.jwt;
} catch(err) {
} catch (err) {
console.log(err);
throw err;
}
}

isTokenExpired() {
const { payload: {
exp
}} = decodeJWT(this.token);
const {
payload: { exp },
} = decodeJWT(this.token);

return exp > getUnixTime(new Date());
}
Expand All @@ -47,8 +47,8 @@ export default class FceUser {

return axios.create({
headers: {
Authorization: `Bearer ${token}`
}
Authorization: `Bearer ${token}`,
},
});
}

Expand All @@ -57,8 +57,8 @@ export default class FceUser {

const response = await request.get(USERS_ENDPOINT, {
params: {
email_eq: email
}
email_eq: email,
},
});

return response?.data[0] || null;
Expand All @@ -71,24 +71,32 @@ export default class FceUser {
await request.post(USERS_ENDPOINT, {
email,
structure,
published_at: null
published_at: null,
});
return {
success: true
success: true,
data: response.data,
};
} catch(err) {
if (err.response.data.statusCode === 500) {
return {
success: true,
}
} else {
} catch (err) {
// Vérifier si err.response existe
const errorDetails =
err.response?.data || err.message || "Erreur inconnue";

console.error("Erreur API :", errorDetails);

if (err.response?.data?.statusCode === 500) {
return {
success: false,
error: {
structure: "Structure inconnue"
}
}
success: true, // Supposé comme un succès en cas d'erreur 500
};
}

return {
success: false,
error: {
message: "Erreur de création de l'utilisateur",
details: errorDetails,
},
};
}
}
}
22 changes: 14 additions & 8 deletions src/server/src/utils/mail.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ export default class Mail {
}

async send(to, subject, message, options = {}) {
return await this.transport.sendMail({
from: this.from,
to,
subject,
text: stripHtml(message),
html: message,
...options
});
try {
return await this.transport.sendMail({
from: this.from,
to,
subject,
text: stripHtml(message).result,
html: message,
...options,
});
} catch (error) {
console.error("Error sending email:", error);
throw error;
}
}



}
7 changes: 0 additions & 7 deletions src/strapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ A quick description of your strapi application
# Development initialization :


## Initialize azure storage
We initialize our azure storage server (which is emulated by azurite).

```bash
node ./scripts/init-azurite.js
```

## Initialize database

Connect to the development database et create a strapi database
Expand Down
2 changes: 0 additions & 2 deletions src/strapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
},
"devDependencies": {},
"dependencies": {
"@azure/storage-blob": "^12.6.0",
"knex": "<0.20.0",
"pg": "latest",
"strapi": "^3.2.1",
Expand All @@ -22,7 +21,6 @@
"strapi-plugin-email": "^3.2.1",
"strapi-plugin-upload": "^3.2.1",
"strapi-plugin-users-permissions": "^3.2.1",
"strapi-provider-upload-azure-storage": "^1.1.3",
"strapi-utils": "^3.2.1"
},
"author": {
Expand Down
23 changes: 0 additions & 23 deletions src/strapi/scripts/init-azurite.js

This file was deleted.

Loading

0 comments on commit 6aa4d44

Please sign in to comment.