-
-
Notifications
You must be signed in to change notification settings - Fork 87
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 #466 from raphckrman/feature/canteen-alise
Implémentation de Alise
- Loading branch information
Showing
28 changed files
with
701 additions
and
158 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
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,14 @@ | ||
import type { AliseAccount } from "@/stores/account/types"; | ||
import type { Balance } from "../shared/Balance"; | ||
|
||
export const getBalance = async (account: AliseAccount, force = false): Promise<Array<Balance>> => { | ||
const balance = force ? (await account.authentication.session.getInformations()).balance : account.authentication.session.account?.balance ?? 0; | ||
const mealPrice = account.authentication.mealPrice; | ||
|
||
return [{ | ||
amount: balance, | ||
currency: "€", | ||
remaining: Math.floor(balance / (mealPrice ?? 0)), | ||
label: "Self" | ||
}]; | ||
}; |
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,26 @@ | ||
import type { AliseAccount } from "@/stores/account/types"; | ||
import type { BookingDay, BookingTerminal } from "../shared/Booking"; | ||
|
||
export const getBookings = async (account: AliseAccount, force = false): Promise<BookingTerminal[]> => { | ||
const bookings = force ? await account.authentication.session.getBookings() : await account.authentication.bookings; | ||
return [{ | ||
id: "", | ||
terminalLabel: "Self", | ||
days: bookings.map((day) => ({ | ||
id: (day.identifier ?? ""), | ||
canBook: day.canBook, | ||
date: day.date, | ||
booked: day.booked | ||
})), | ||
account: account | ||
}]; | ||
}; | ||
|
||
export const bookDay = async (account: AliseAccount, id: string, date: Date, booked: boolean): Promise<BookingDay> => { | ||
const bookedDay = await account.authentication.session.bookDay(id, 1, !booked); | ||
return { | ||
id: bookedDay.identifier ?? "", | ||
canBook: bookedDay.canBook, | ||
booked: bookedDay.booked, | ||
}; | ||
}; |
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,12 @@ | ||
import type { AliseAccount } from "@/stores/account/types"; | ||
import type { ReservationHistory } from "../shared/ReservationHistory"; | ||
|
||
export const getHistory = async (account: AliseAccount): Promise<ReservationHistory[]> => { | ||
const history = await account.authentication.session.getFinancialHistory(); | ||
return (history ?? []).map((item) => ({ | ||
timestamp: item.date.getTime(), | ||
amount: item.amount, | ||
currency: "€", | ||
label: item.label, | ||
})); | ||
}; |
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,16 @@ | ||
import type { AliseAccount } from "@/stores/account/types"; | ||
import { authenticateWithCredentials } from "alise-api"; | ||
|
||
export const reload = async (account: AliseAccount): Promise<AliseAccount["authentication"]> => { | ||
const auth = { ...account.authentication }; | ||
const session = await authenticateWithCredentials(auth.username, auth.password, auth.schoolID); | ||
const bookings = await session.getBookings(); | ||
return { | ||
session, | ||
schoolID: auth.schoolID, | ||
username: auth.username, | ||
password: auth.password, | ||
mealPrice: auth.mealPrice, | ||
bookings: bookings | ||
}; | ||
}; |
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
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 |
---|---|---|
@@ -1,19 +1,15 @@ | ||
import { ARDAccount, TurboselfAccount } from "@/stores/account/types"; | ||
import { AliseAccount, ARDAccount, TurboselfAccount } from "@/stores/account/types"; | ||
|
||
export interface BookingTerminal { | ||
id: string; | ||
week: number; | ||
from: Date; | ||
to: Date; | ||
terminalLabel: string; | ||
days: BookingDay[]; | ||
account: TurboselfAccount | ARDAccount; | ||
account: TurboselfAccount | ARDAccount | AliseAccount; | ||
} | ||
|
||
export interface BookingDay { | ||
id: string; | ||
canBook: boolean; | ||
date: Date; | ||
message: string; | ||
date?: Date; | ||
booked: boolean; | ||
} |
Oops, something went wrong.