Skip to content

Commit

Permalink
lot of fixes before merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Fefedu973 committed Nov 11, 2024
1 parent 3366296 commit 43c8c99
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 112 deletions.
6 changes: 6 additions & 0 deletions src/components/app/Account/Account.css
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ body:has(#account) {
align-items: center;
}

.file-box-loader {
display: grid;
grid-template-columns: 3.5fr .5fr;
gap: 10px;
}

.file-date {
margin-left: auto;
margin-right: 30px;
Expand Down
234 changes: 133 additions & 101 deletions src/components/app/Account/Account.jsx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/app/Grades/Charts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default function Charts({ selectedPeriod }) {
chartData.current = {
labels: Array.from({ length: subjectsComparativeInformation[selectedPeriod].length }, (_, i) => subjectsComparativeInformation[selectedPeriod][i].subjectFullname),
datasets: [
...(minMaxEnabled && false ? [
...(minMaxEnabled ? [
{
type: "bar",
label: "Moyennes min et max de classe",
Expand Down
17 changes: 14 additions & 3 deletions src/components/app/Grades/Grade.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export default function Grade({ grade, subject, className = "", ...props }) {
const [selectedPeriod, setSelectedPeriod] = useState(userData.get("activePeriod"));

const generalAverage = sortedGrades[selectedPeriod].generalAverage;
const subjectsSummedCoefs = getSummedCoef(sortedGrades[selectedPeriod].subjects);
const gradeCoef = grade.coef ?? 1;
let subjectCoef = grade?.subject?.coef ?? gradeCoef;
let subjectsSummedCoefs = getSummedCoef(sortedGrades[selectedPeriod].subjects);


function getSummedCoef(subjects) {
let sum = 0;
Expand All @@ -23,12 +26,20 @@ export default function Grade({ grade, subject, className = "", ...props }) {
sum += subjects[key].coef;
}
}
// if all subjects have 0 as coef, we replace all coef by 1
if (sum === 0) {
sum = Object.keys(subjects).length;
subjectCoef = 1;
}

return sum;
}

// Use subject coef if subject is provided, otherwise use grade's coef
const gradeCoef = grade.coef ?? 1;
const subjectCoef = grade?.subject?.coef ?? gradeCoef;

// if all subjects have 0 as coef, we replace all coef by 1 to avoid division by 0


const gradeScore = (subjectCoef * (grade.value - generalAverage)) / ((subjectsSummedCoefs - subjectCoef) || 1);

const coefficientEnabled = useUserData().get("gradesEnabledFeatures")?.coefficient;
Expand Down
4 changes: 2 additions & 2 deletions src/components/app/Messaging/Inbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function Inbox({ selectedMessage, setSelectedMessage, selectedFol
try {
// regexp = new RegExp(removeAccents(search.toLowerCase()));
} catch { return -1 }
const filterBy = [message.subject, message.from.name, message.content?.content, message.files?.map((file) => file.name)].flat();
const filterBy = [message.subject, message.from.nom, message.content?.content, message.files?.map((file) => file.name)].flat();
for (let filter of filterBy) {
if (filter) {
filter = removeAccents(filter.toLowerCase());
Expand Down Expand Up @@ -92,7 +92,7 @@ export default function Inbox({ selectedMessage, setSelectedMessage, selectedFol
? <ScrollShadedDiv className="messages-container">
<ul>
{messages.filter((message) => message.folderId === selectedFolder).filter(filterResearch).map((message, index) => <li style={{ "--order": index }} className={"message-container" + (selectedMessage === message.id ? " selected" : "")} data-read={message.read} onClick={() => handleClick(message)} onKeyDown={(event) => handleKeyDown(event, message)} key={message.id} role="button" tabIndex={0}>
<h4 className="message-subject"><span className="author-name">{settings.get("isStreamerModeEnabled") ? message.from.name.split(" ")[0] + " " + "-".repeat(message.from.name.length) : message.from.name}</span> <span className="actions"><button disabled={!message.read} onClick={(event) => handleMarkAsUnread(event, message)} className="mark-as-unread" title="Marquer comme non lu"><MarkAsUnread className="mark-as-unread-icon" /></button> {message.files?.length > 0 && <AttachmentIcon className="attachment-icon" />}</span></h4>
<h4 className="message-subject"><span className="author-name">{settings.get("isStreamerModeEnabled") ? (message.from.civilite + " " + message.from.prenom + " " + message.from.nom).split(" ")[0] + " " + "-".repeat((message.from.civilite + " " + message.from.prenom + " " + message.from.nom).length) : (message.from.civilite + " " + message.from.prenom + " " + message.from.nom)}</span> <span className="actions"><button disabled={!message.read} onClick={(event) => handleMarkAsUnread(event, message)} className="mark-as-unread" title="Marquer comme non lu"><MarkAsUnread className="mark-as-unread-icon" /></button> {message.files?.length > 0 && <AttachmentIcon className="attachment-icon" />}</span></h4>
<p className="message-author">{message.subject}</p>
<p className="message-date">{(new Date(message.date)).toLocaleDateString("fr-FR", {
month: "long",
Expand Down
2 changes: 0 additions & 2 deletions src/components/app/Messaging/MessageReader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ export default function MessageReader({ selectedMessage, fetchMessageMarkAsUnrea
const printWindow = window.open("", "_blank");
printWindow.document.write("<html><head><title>Impression</title></head><body>");
printWindow.document.write(document.querySelector("#message-reader .message-content").innerHTML);
//remove the email footer
printWindow.document.querySelector("#message-reader .email-footer").remove();
printWindow.document.write("</body></html>");
printWindow.document.close();
printWindow.print();
Expand Down
15 changes: 12 additions & 3 deletions src/components/app/Messaging/Messaging.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function Messaging({ isLoggedIn, activeAccount, fetchMessages, fe
const navigate = useNavigate();
const location = useLocation();

const { useUserData } = useContext(AppContext);
const { accountsListState, useUserData } = useContext(AppContext);
const [selectedMessage, setSelectedMessage] = useState(null);
const [selectedFolder, setSelectedFolder] = useState(0);
const oldSelectedMessage = useRef(selectedMessage);
Expand All @@ -45,8 +45,15 @@ export default function Messaging({ isLoggedIn, activeAccount, fetchMessages, fe
}, [useUserData("messageFolders").get()]);




const module = accountsListState[activeAccount].modules?.find(module => module.code === "MESSAGERIE");
let canSendMessages = (module?.params?.destAdmin ?? "1") === "1" ||
(module?.params?.destEleve ?? "1") === "1" ||
(module?.params?.destFamille ?? "1") === "1" ||
(module?.params?.destProf ?? "1") === "1" ||
(module?.params?.destEspTravail ?? "1") === "1";
if (accountsListState[activeAccount].accountType !== "E") {
canSendMessages = true;
}

const [isEditingFolder, setIsEditingFolder] = useState(false);
const [newFolderName, setNewFolderName] = useState('');
Expand Down Expand Up @@ -242,6 +249,8 @@ export default function Messaging({ isLoggedIn, activeAccount, fetchMessages, fe
<ul className="folders-container">
{folders
.filter((folder) => folder.id !== -3)
// if canSendMessages is false, we don't show the drafts folder and the sent folder
.filter((folder) => canSendMessages || folder.id !== -4)
.sort((a, b) => {
const order = [0, -1, -2, -4];
const indexA = order.indexOf(a.id);
Expand Down

0 comments on commit 43c8c99

Please sign in to comment.