Skip to content

Commit fd5957e

Browse files
authored
chore: merge pull request PapillonApp#344 from camarm-dev/fix/linter
🏷️ [Fix] Réparation de TOUS les types, et des erreur de lint (partie 2)
2 parents 6c24499 + 147ccff commit fd5957e

35 files changed

+216
-126
lines changed

package-lock.json

Lines changed: 29 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Home/AccountSwitcher.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ const AccountSwitcher: React.FC<{
3838
borderWidth: 1,
3939
borderRadius: 80,
4040
borderColor: interpolateColor(
41-
translationY.value,
41+
translationY?.value || 0, // Should think to pass a default value
4242
[200, 251],
4343
["#ffffff50", colors.border],
4444
),
4545
backgroundColor: interpolateColor(
46-
translationY.value,
46+
translationY?.value || 0, // Should think to pass a default value
4747
[200, 251],
4848
["#ffffff30", "transparent"],
4949
),
5050
}));
5151

5252
const textAnimatedStyle = useAnimatedStyle(() => ({
5353
color: interpolateColor(
54-
translationY.value,
54+
translationY?.value || 0, // Should think to pass a default value
5555
[200, 251],
5656
["#FFF", colors.text],
5757
),
@@ -64,7 +64,7 @@ const AccountSwitcher: React.FC<{
6464
const AnimatedChevronDown = Animated.createAnimatedComponent(ChevronDown);
6565
const iconAnimatedStyle = useAnimatedStyle(() => ({
6666
color: interpolateColor(
67-
translationY.value,
67+
translationY?.value || 0, // Should think to pass a default value
6868
[200, 251],
6969
["#FFF", colors.text],
7070
),
@@ -124,7 +124,7 @@ const AccountSwitcher: React.FC<{
124124
>
125125
{!shouldHidePicture ? (
126126
<Image
127-
source={(account.personalization.profilePictureB64 && account.personalization.profilePictureB64.trim() !== "") ? { uri: account.personalization.profilePictureB64 } : defaultProfilePicture(account.service)}
127+
source={(account.personalization.profilePictureB64 && account.personalization.profilePictureB64.trim() !== "") ? { uri: account.personalization.profilePictureB64 } : defaultProfilePicture(account.service, account.identityProvider?.name || "")}
128128
style={[
129129
styles.avatar,
130130
{

src/components/Restaurant/AccountButton.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,20 @@ import Reanimated, {
88
withTiming,
99
Easing,
1010
} from "react-native-reanimated";
11+
import {Balance} from "@/services/shared/Balance";
12+
import {Theme} from "@react-navigation/native";
1113

1214
const AnimatedTouchableOpacity = Reanimated.createAnimatedComponent(TouchableOpacity);
1315
const AnimatedView = Reanimated.createAnimatedComponent(View);
1416

15-
const AccountButton = ({ account, isSelected, onPress, colors }) => {
17+
interface AccountButtonProps {
18+
account: Balance
19+
isSelected: boolean
20+
onPress: () => any
21+
colors: Theme["colors"]
22+
}
23+
24+
const AccountButton: React.FC<AccountButtonProps> = ({ account, isSelected, onPress, colors }) => {
1625
const COLLAPSED_WIDTH = 47;
1726
const [textMeasurement, setTextMeasurement] = React.useState(0);
1827
const EXPANDED_WIDTH = React.useMemo(() => COLLAPSED_WIDTH + textMeasurement + 16, [textMeasurement]); // 16 pour le gap
@@ -135,4 +144,4 @@ const AccountButton = ({ account, isSelected, onPress, colors }) => {
135144
);
136145
};
137146

138-
export default AccountButton;
147+
export default AccountButton;

src/router/helpers/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export type RouteParameters = {
6060
UnivLimoges_Login: undefined;
6161
UnivSorbonneParisNord_login: undefined;
6262
UnivUphf_Login: undefined;
63-
BackgroundIUTLannion: { url: string; username: string; password: string };
63+
BackgroundIUTLannion: { url?: string; username: string; password: string, firstLogin?: boolean } | undefined;
6464

6565
// login.skolengo
6666
SkolengoAuthenticationSelector: undefined;

src/router/screens/login/identityProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import UnivRennes1_Login from "@/views/login/IdentityProvider/providers/UnivRenn
55
import UnivLimoges_Login from "@/views/login/IdentityProvider/providers/UnivLimoges";
66
import UnivRennes2_Login from "@/views/login/IdentityProvider/providers/UnivRennes2";
77
import UnivSorbonneParisNord_login from "@/views/login/IdentityProvider/providers/UnivSorbonneParisNord";
8-
import UnivUphf_Login from "@/views/login/IdentityProvider/providers/UnivUphf";
8+
//import UnivUphf_Login from "@/views/login/IdentityProvider/providers/UnivUphf";
99
import { UnivIUTLannion_Login } from "@/views/login/IdentityProvider/providers/UnivIUTLannion";
1010
import Muli_Login from "@/views/login/IdentityProvider/providers/Multi";
1111

@@ -44,4 +44,4 @@ export default [
4444
headerBackVisible: true,
4545
headerTitle: "ESUP Multi",
4646
}),
47-
] as const;
47+
] as const;

src/services/ard/history.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ import type { ARDAccount } from "@/stores/account/types";
22
import type { ReservationHistory } from "../shared/ReservationHistory";
33

44
export const history = async (account: ARDAccount): Promise<ReservationHistory[]> => {
5-
const uid = await account.instance?.getOnlinePayments().then((payments) => payments.user.uid)
6-
if (!uid) throw new Error("We can't get the account UID")
5+
const uid = await account.instance?.getOnlinePayments().then((payments) => payments.user.uid);
6+
if (!uid) throw new Error("We can't get the account UID");
77

88
let [financialHistory, ordersHistory, consumptionsHistory] = await Promise.all([
99
account.instance?.getFinancialHistory(uid),
1010
account.instance?.getOrdersHistory(uid),
1111
account.instance?.getConsumptionsHistory(uid)
12-
])
12+
]);
1313

1414
return [
15-
...(financialHistory ?? []).map((item) => ({
16-
amount: ((item.credit ?? 0) - (item.debit ?? 0)) / 100,
17-
timestamp: item.operationDate * 1000,
18-
currency: "€",
19-
label: item.operationName
20-
})),
15+
...(financialHistory ?? []).map((item) => ({
16+
amount: ((item.credit ?? 0) - (item.debit ?? 0)) / 100,
17+
timestamp: item.operationDate * 1000,
18+
currency: "€",
19+
label: item.operationName
20+
})),
2121
...(ordersHistory ?? []).map((item) => ({
2222
amount: item.amount / 100,
2323
timestamp: item.orderDate * 1000,

src/services/booking.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ export const getBookingsAvailableFromExternal = async (account: ExternalAccount,
2020
}
2121
};
2222

23-
export const bookDayFromExternal = async (account: ExternalAccount, id: string, date: Date, booked: boolean): Promise<BookingDay | null> => {
23+
export const bookDayFromExternal = async (account: ExternalAccount, id: string, date: Date, booked: boolean): Promise<BookingDay | undefined> => {
2424
switch (account.service) {
2525
case AccountService.Turboself: {
2626
const { bookDay } = await import("./turboself/booking");
2727
const bookedDay = await bookDay(account, id, date, booked);
2828
return bookedDay;
2929
}
3030
case AccountService.ARD: {
31-
return null;
31+
return undefined;
3232
}
3333
}
34-
};
34+
};

src/services/iutlan/grades.ts

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import { LocalAccount } from "@/stores/account/types";
2-
import { Grade } from "pawnote";
3-
import { AverageOverview } from "../shared/Grade";
2+
import {
3+
type AverageOverview,
4+
type Grade
5+
} from "@/services/shared/Grade";
46
import uuid from "@/utils/uuid-v4";
57

6-
export const saveIUTLanGrades = async (account: LocalAccount) => {
8+
export const saveIUTLanGrades = async (account: LocalAccount): Promise<{
9+
grades: Grade[];
10+
averages: AverageOverview;
11+
}> => {
712
try {
13+
// Il faudrait peut-être penser à typer cette partie, tous les types sont any :(
814
const scodocData = account.identityProvider.rawData;
9-
const matieres = scodocData["relevé"].ressources;
15+
const matieres = (scodocData["relevé"] as any).ressources;
1016

1117
const gradesList: Grade[] = [];
1218
const averages: AverageOverview = {
@@ -30,8 +36,8 @@ export const saveIUTLanGrades = async (account: LocalAccount) => {
3036
name: subjectName,
3137
};
3238

33-
const grades: Grade[] = matiere.evaluations.map((note) => {
34-
const grade = {
39+
const grades: Grade[] = matiere.evaluations.map((note: any) => {
40+
const grade: Grade = {
3541
student: {
3642
value: parseInt(note.note.value),
3743
disabled: isNaN(parseInt(note.note.value)),
@@ -54,16 +60,11 @@ export const saveIUTLanGrades = async (account: LocalAccount) => {
5460
value: 20,
5561
disabled: false,
5662
},
57-
defaultOutOf: 20,
5863
description: note.description,
5964
timestamp: new Date(note.date).getTime(),
60-
subject: subject,
6165
coefficient: parseInt(note.coef),
62-
isOutOf20: true,
63-
6466
isBonus: false,
6567
isOptional: false,
66-
6768
subjectName: subject.name,
6869
};
6970

@@ -72,10 +73,10 @@ export const saveIUTLanGrades = async (account: LocalAccount) => {
7273
return grade;
7374
});
7475

75-
const average = grades.reduce((acc, grade) => acc + grade.student.value, 0) / grades.length;
76-
const min = grades.reduce((acc, grade) => Math.min(acc, grade.min.value), 20);
77-
const max = grades.reduce((acc, grade) => Math.max(acc, grade.max.value), 0);
78-
const classAverage = grades.reduce((acc, grade) => acc + grade.average.value, 0) / grades.length;
76+
const average = grades.filter(grade => grade.student.value != null).reduce((acc, grade) => acc + (grade.student.value as number), 0) / grades.length;
77+
const min = grades.filter(grade => grade.min.value != null).reduce((acc, grade) => Math.min(acc, (grade.min.value as number)), 20);
78+
const max = grades.filter(grade => grade.max.value != null).reduce((acc, grade) => Math.max(acc, (grade.max.value as number)), 0);
79+
const classAverage = grades.filter(grade => grade.average.value != null).reduce((acc, grade) => acc + (grade.average.value as number), 0) / grades.length;
7980

8081

8182
if (grades.length === 0) {
@@ -112,5 +113,19 @@ export const saveIUTLanGrades = async (account: LocalAccount) => {
112113
}
113114
catch(e) {
114115
console.error(e);
116+
return {
117+
grades: [],
118+
averages: {
119+
classOverall: {
120+
value: null,
121+
disabled: true,
122+
},
123+
overall: {
124+
value: null,
125+
disabled: true,
126+
},
127+
subjects: []
128+
}
129+
};
115130
}
116-
};
131+
};

src/services/izly/reload.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { log } from "@/utils/logger/logger";
33
import {Identification, refresh} from "ezly";
44

55
export const reload = async (account: IzlyAccount): Promise<Identification> => {
6-
const instance = account.authentication.identification
7-
const secret = account.authentication.secret
6+
const instance = account.authentication.identification;
7+
const secret = account.authentication.secret;
88

99
await refresh(instance, secret);
1010
log("session refreshed", "izly");

src/services/menu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export async function getMenu <T extends Account> (account: Account, date: Date)
99
return menu;
1010
}
1111
default: {
12-
return null
12+
return null;
1313
}
1414
}
1515
}

0 commit comments

Comments
 (0)