-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/canteen-alise
- Loading branch information
Showing
15 changed files
with
407 additions
and
163 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
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,48 @@ | ||
import { LocalAccount } from "@/stores/account/types"; | ||
import uuid from "@/utils/uuid-v4"; | ||
import { Attendance } from "../shared/Attendance"; | ||
|
||
export const saveIUTLanAttendance = async (account: LocalAccount): Promise<Attendance> => { | ||
try { | ||
// Il faudrait peut-être penser à typer cette partie, tous les types sont any :( | ||
const scodocData = account.identityProvider.rawData; | ||
|
||
const allAbsences = []; | ||
|
||
// for all scodocData.absences | ||
if(scodocData.absences && Object.keys(scodocData.absences).length > 0) { | ||
for (const day of Object.keys(scodocData.absences)) { | ||
for (const absence of scodocData.absences[day]) { | ||
let from = new Date(day); | ||
from.setHours(absence.debut); | ||
|
||
let to = new Date(absence.dateFin); | ||
to.setHours(absence.fin); | ||
|
||
allAbsences.push({ | ||
id: absence.idAbs, | ||
fromTimestamp: from ? new Date(from).getTime() : undefined, | ||
toTimestamp: to ? new Date(to).getTime() : undefined, | ||
justified: absence.justifie ?? false, | ||
hours: (parseInt(absence.fin) - parseInt(absence.debut)) + "h 00", | ||
administrativelyFixed: absence.justifie ?? false, | ||
reasons: undefined, | ||
}); | ||
} | ||
} | ||
} | ||
|
||
// sort allAbsences by fromTimestamp | ||
allAbsences.sort((a, b) => a.fromTimestamp - b.fromTimestamp); | ||
|
||
return { | ||
delays: [], | ||
absences: allAbsences, | ||
punishments: [], | ||
observations: [], | ||
}; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
|
||
}; |
Oops, something went wrong.