Skip to content

Commit

Permalink
chore: merge pull request #286 from tom-theret/service/uphf
Browse files Browse the repository at this point in the history
Feat+Fix(uphf): Ajout de la photo de profil
  • Loading branch information
Vexcited authored Oct 21, 2024
2 parents 643ea18 + a2c559d commit af8cf8a
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 8 deletions.
73 changes: 69 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"scolengo-api": "^3.0.5",
"text-encoding": "^0.7.0",
"turbawself": "^1.1.1",
"uphf-api": "^2.1.3",
"uphf-api": "^2.2.0",
"zustand": "^4.5.2"
},
"devDependencies": {
Expand Down
8 changes: 6 additions & 2 deletions src/services/uphf/default-personalization.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Personalization } from "@/stores/account/types";
import type { Personalization, UphfAccount } from "@/stores/account/types";
import { defaultTabs } from "@/consts/DefaultTabs";
import type pronote from "pawnote";

Expand All @@ -10,10 +10,14 @@ const defaultUphfTabs = [
"News",
] as typeof defaultTabs[number]["tab"][];

const defaultPersonalization = async (): Promise<Partial<Personalization>> => {
const defaultPersonalization = async (instance: UphfAccount["instance"]): Promise<Partial<Personalization>> => {
const profilePictureAsBase64 = await instance?.getProfilePictureAsBase64();
return {
color: colors[0],
magicEnabled: true,
profilePictureB64: (profilePictureAsBase64 !== null && profilePictureAsBase64 != "")
? await profilePictureAsBase64
: void 0,
tabs: defaultTabs.filter(current => defaultUphfTabs.includes(current.tab)).map((tab, index) => ({
name: tab.tab,
enabled: index <= 4
Expand Down
27 changes: 27 additions & 0 deletions src/views/login/IdentityProvider/IdentityProviderSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ import { NativeItem, NativeList, NativeListHeader, NativeText } from "@/componen
import { Info } from "lucide-react-native";

const IdentityProviderSelector: Screen<"IdentityProviderSelector"> = ({ navigation }) => {
const universityProviders = [
{
name: "univ_uphf",
title: "Université Polytechnique Hauts-de-France",
description: "Utilisez votre compte UPHF pour vous connecter",
image: require("@/../assets/images/service_uphf.png"),
navigate: () => navigation.navigate("UnivUphf_Login"),
},
];

const identityProviders = [
{
name: "univ_rennes1",
Expand Down Expand Up @@ -43,6 +53,23 @@ const IdentityProviderSelector: Screen<"IdentityProviderSelector"> = ({ navigati
style={{ flex: 1 }}
contentContainerStyle={{ padding: 16, paddingTop: 0 }}
>
<NativeListHeader label="Service universitaire disponible" />

<NativeList>
{universityProviders.map((identityProvider) => (
<NativeItem
key={identityProvider.name}
onPress={() => identityProvider.navigate()}
leading={<Image source={identityProvider.image} style={{ width: 40, height: 40, borderRadius: 300 }} />}
>
<NativeText variant="title">{identityProvider.title}</NativeText>
<NativeText variant="subtitle">
{identityProvider.description}
</NativeText>
</NativeItem>
))}
</NativeList>

<NativeListHeader label="Fournisseurs disponibles" />

<NativeList>
Expand Down
2 changes: 1 addition & 1 deletion src/views/login/IdentityProvider/providers/UnivUphf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const UnivUphf_Login: Screen<"UnivUphf_Login"> = ({ navigation }) => {
authentication: {
refreshAuthToken: account.userData.refreshAuthToken,
},
personalization: await defaultPersonalization()
personalization: await defaultPersonalization(account),
};

createStoredAccount(local_account);
Expand Down

0 comments on commit af8cf8a

Please sign in to comment.