Skip to content

Commit

Permalink
Cleaning azure files from strapi folder (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImenOuidou authored Nov 25, 2024
1 parent 8b704d6 commit f1de221
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 293 deletions.
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 f1de221

Please sign in to comment.