-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from PapillonApp/dev
Passage de la version 0.2.6 à 0.2.7
- Loading branch information
Showing
13 changed files
with
152 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { login, ED } from "./login"; | ||
|
||
// Exemple de schoolLife | ||
|
||
login().then(() => { | ||
ED.schoolLife.fetch().then(response => { | ||
for (const sanctionsEncouragement of response.sanctionsEncouragements) { | ||
console.log(`[${sanctionsEncouragement.typeElement}] ${sanctionsEncouragement.libelle} le ${sanctionsEncouragement.date} par ${sanctionsEncouragement.par}; ${sanctionsEncouragement.motif} ${sanctionsEncouragement.commentaire}`) | ||
} | ||
for (const absencesRetard of response.absencesRetards) { | ||
console.log(`[${absencesRetard.typeElement}] ${absencesRetard.libelle} le ${absencesRetard.date} par ${absencesRetard.par}; ${absencesRetard.motif} ${absencesRetard.commentaire}`) | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"preset": "ts-jest", | ||
"testEnvironment": "node" | ||
"testEnvironment": "node", | ||
"moduleNameMapper": { | ||
"^~/(.*)$": "<rootDir>/src/$1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
export type Timeinterval = { | ||
start: string | ||
end: string | ||
}; | ||
|
||
export function dateAsISO860(str: string): string { | ||
const parts = str.split(" "); | ||
let month = "01"; | ||
switch (parts[2]) { | ||
case "janvier": | ||
month = "01"; | ||
break; | ||
case "février": | ||
month = "02"; | ||
break; | ||
case "mars": | ||
month = "03"; | ||
break; | ||
case "avril": | ||
month = "04"; | ||
break; | ||
case "mai": | ||
month = "05"; | ||
break; | ||
case "juin": | ||
month = "06"; | ||
break; | ||
case "juillet": | ||
month = "07"; | ||
break; | ||
case "août": | ||
month = "08"; | ||
break; | ||
case "septembre": | ||
month = "09"; | ||
break; | ||
case "octobre": | ||
month = "10"; | ||
break; | ||
case "novembre": | ||
month = "11"; | ||
break; | ||
case "décembre": | ||
month = "12"; | ||
break; | ||
} | ||
return parts[3] + "-" + month + "-" + parts[1] + "T" + parts[5] + ":00.000+02:00"; | ||
} | ||
|
||
export function dateStringAsTimeInterval(str: string): Timeinterval | undefined { | ||
if (str.includes("du")) { | ||
/** | ||
* @example | ||
* str is equal to "du mercredi 21 février 2024 au jeudi 22 février 2024" | ||
*/ | ||
const parts = str.split("au"); | ||
const start = dateAsISO860(parts[0].replace("du", "").trim()); | ||
const end = dateAsISO860(parts[1].trim()); | ||
return {start: start, end: end} as Timeinterval; | ||
} | ||
if (str.includes("le")) { | ||
/** | ||
* @example | ||
* str is equal to "le mercredi 21 février 2024 de 08:55 à 09:45" | ||
* or "le mercredi 21 février 2024" | ||
*/ | ||
const parts = str.split("à"); | ||
|
||
let startDate, endDate; | ||
|
||
// C'est une journée complète ("le mercredi 21 février 2024") | ||
if (!str.includes(":")) { | ||
startDate = parts[0].replace("le", "").trim() + " de 00:00"; | ||
endDate = parts[0].split("de")[0].replace("le", "").trim() + " de 23:59"; | ||
} else { | ||
startDate = parts[0].replace("le", "").trim(); | ||
endDate = parts[0].split("de")[0].replace("le", "").trim() + " de " + parts[1].trim(); | ||
} | ||
const start = dateAsISO860(startDate); | ||
const end = dateAsISO860(endDate); | ||
return { start: start, end: end } as Timeinterval; | ||
} | ||
return undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {failureRes, schoolLifeItem, schoolLifeResData, schoolLifeResSuccess} from "~/types/v3"; | ||
import {Timeinterval} from "~/utils/dates"; | ||
|
||
export type schoolLifeRes = schoolLifeSuccess | failureRes; | ||
|
||
export type schoolLifeSuccess = schoolLifeResSuccess & { data: EDCoreSchoolLifeResData }; | ||
|
||
export type EDCoreSchoolLifeItem = schoolLifeItem & { interval?: Timeinterval }; | ||
|
||
export type EDCoreSchoolLifeResData = schoolLifeResData & { | ||
sanctionsEncouragements: Array<EDCoreSchoolLifeItem>; | ||
absencesRetards: Array<EDCoreSchoolLifeItem>; | ||
}; |