Skip to content

Commit

Permalink
Merge branch 'main' into chore/expo52
Browse files Browse the repository at this point in the history
  • Loading branch information
Kgeek33 committed Dec 8, 2024
2 parents 6e99544 + 51d84eb commit 1a54306
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 64 deletions.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="papillon"/>
<data android:scheme="xyz.getpapillon.app"/>
<data android:scheme="izly"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/>
Expand Down
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"expo": {
"name": "Papillon",
"slug": "papillonvex",
"scheme": "papillon",
"version": "7.5.0",
"scheme": ["papillon", "izly"],
"version": "7.6.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "automatic",
Expand Down
3 changes: 2 additions & 1 deletion ios/Papillon/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@
<key>CFBundleURLSchemes</key>
<array>
<string>papillon</string>
<string>izly</string>
<string>xyz.getpapillon.ios</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<string>7501</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "papillonvex",
"version": "7.5.0",
"version": "7.6.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"update": "ncu -u && npm i",
Expand Down
6 changes: 5 additions & 1 deletion src/router/screens/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ const settingsScreens = [
}),

createScreen("IzlyActivation", IzlyActivation, {
headerTitle: "Configuration de la cantine",
headerTitle: "Configuration de Izly",
presentation: "modal",
headerBackVisible: false,
gestureEnabled: false,

}),

createScreen("SettingsDevLogs", SettingsDevLogs, {
Expand Down
4 changes: 2 additions & 2 deletions src/views/account/News/Document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const NewsItem: Screen<"NewsItem"> = ({ route, navigation }) => {
/>
<View style={{flex: 1, gap: 3}}>
<NativeText variant="title" numberOfLines={1}>{message.title === "" ? message.author : message.title}</NativeText>
<NativeText variant="subtitle" numberOfLines={1}>{message.title === "" ? formatDate(message.date.toDateString()) : message.author}</NativeText>
<NativeText variant="subtitle" numberOfLines={1}>{message.title === "" ? formatDate(message.date.toString()) : message.author}</NativeText>
</View>
{!isED && (
<PapillonPicker
Expand Down Expand Up @@ -231,7 +231,7 @@ const NewsItem: Screen<"NewsItem"> = ({ route, navigation }) => {
borderColor: theme.colors.border,
marginTop: 16,
}}>
<NativeText>{formatDate(message.date.toDateString())}</NativeText>
<NativeText>{formatDate(message.date.toString())}</NativeText>
</View>
</ScrollView>}

Expand Down
14 changes: 14 additions & 0 deletions src/views/account/Restaurant/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,20 @@ const Menu: Screen<"Menu"> = ({ route, navigation }) => {
})();
}, [linkedAccounts]);

const fetchQRCode = async () => {
if (linkedAccounts) {
const qrCodes = await Promise.all(linkedAccounts.map(qrcodeFromExternal));
console.log("fqq", qrCodes);
setAllQRCodes(qrCodes.filter((code) => code !== null) as string[]);
}
};

useEffect(() => {
// force la regénération du QR code à chaque fois que l'écran est affiché
const unsub = navigation.addListener("focus", fetchQRCode);
return unsub;
}, []);

return (
<ScrollView contentContainerStyle={styles.scrollViewContent}>
{!isInitialised ? (
Expand Down
89 changes: 32 additions & 57 deletions src/views/settings/ExternalAccount/IzlyActivation.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, {useState} from "react";
import React, {useState, useEffect} from "react";
import type {Screen} from "@/router/helpers/types";
import {useTheme} from "@react-navigation/native";
import {SafeAreaView, useSafeAreaInsets} from "react-native-safe-area-context";
import {Keyboard, KeyboardAvoidingView, StyleSheet, TextInput, TouchableWithoutFeedback, View} from "react-native";
import {Alert, Keyboard, KeyboardAvoidingView, StyleSheet, TextInput, TouchableWithoutFeedback, View} from "react-native";
import PapillonShineBubble from "@/components/FirstInstallation/PapillonShineBubble";
import {NativeItem, NativeList, NativeListHeader, NativeText,} from "@/components/Global/NativeComponents";
import ButtonCta from "@/components/FirstInstallation/ButtonCta";
Expand All @@ -12,26 +12,39 @@ import {AccountService, IzlyAccount} from "@/stores/account/types";
import {useAccounts, useCurrentAccount} from "@/stores/account";
import uuid from "@/utils/uuid-v4";

import * as Linking from "expo-linking";

const IzlyActivation: Screen<"IzlyActivation"> = ({ navigation, route }) => {
const theme = useTheme();
const { colors } = theme;
const insets = useSafeAreaInsets();

const linkExistingExternalAccount = useCurrentAccount(store => store.linkExistingExternalAccount);
const create = useAccounts(store => store.create);

const [activationURL, setActivationURL] = useState("");
const [error, setError] = useState("");
const [loading, setLoading] = useState(false);

const secret = route.params?.password;
const username = route.params?.username;

const handleActivation = async (): Promise<void> => {
useEffect(() => {
const handleDeepLink = (event: { url: string }) => {
const url = event.url;
const scheme = url.split(":")[0];
if (scheme === "izly") {
console.log("[IzlyActivation] Activation link received:", url);
handleActivation(url);
} else {
console.log("[IzlyActivation] Ignoring link:", url);
}
};
Linking.addEventListener("url", handleDeepLink);
}, []);

const handleActivation = async (activationLink: string): Promise<void> => {
Keyboard.dismiss();
try {
const URL = await extractActivationURL(activationURL);
const { identification, configuration } = await tokenize(URL);
setLoading(true);
const { identification, configuration } = await tokenize(activationLink);

const new_account: IzlyAccount = {
service: AccountService.Izly,
Expand All @@ -52,12 +65,14 @@ const IzlyActivation: Screen<"IzlyActivation"> = ({ navigation, route }) => {

navigation.pop();
navigation.pop();
navigation.pop();
navigation.pop();
} catch (error) {
if (error instanceof Error) {
setError(error.message);
Alert.alert("Erreur", error.message);
}
else {
setError("Une erreur est survenue lors de la connexion.");
Alert.alert("Erreur", "Une erreur est survenue lors de l'activation.");
} }
finally {
setLoading(false);
Expand All @@ -79,53 +94,12 @@ const IzlyActivation: Screen<"IzlyActivation"> = ({ navigation, route }) => {
style={styles.container}
>
<PapillonShineBubble
message={"Tu viens de recevoir un lien par SMS, peux tu me l'indiquer ?"}
message={loading ? "Activation en cours..." : "Tu viens de recevoir un lien par SMS, peux tu me cliquer sur le lien pour activer ton compte ?"}
width={270}
numberOfLines={2}
numberOfLines={loading ? 1 : 3}
offsetTop={insets.top}
/>



<View
style={styles.list}
>
<View
style={{ width: "100%" }}
>
{error && (
<NativeList
style={{
backgroundColor: "#eb403422",
}}
>
<NativeItem icon={<AlertTriangle />}>
<NativeText variant="subtitle">{error}</NativeText>
</NativeItem>
</NativeList>
)}
<NativeListHeader label="URL" />
<NativeList>
<NativeItem>
<TextInput
value={activationURL}
onChangeText={setActivationURL}
onPress={() => {setError("");}}
placeholder={"https://..."}
placeholderTextColor={theme.colors.text + "55"}
keyboardType={"url"}
autoCapitalize="none"
style={{
fontSize: 16,
fontFamily: "medium",
color: theme.colors.text,
}}
/>
</NativeItem>
</NativeList>
</View>
</View>

<NativeText
style={{
width: "100%",
Expand All @@ -138,13 +112,14 @@ const IzlyActivation: Screen<"IzlyActivation"> = ({ navigation, route }) => {
Papillon ne donnera jamais vos informations d'authentification à des tiers.
</NativeText>


<View style={styles.buttons}>
<ButtonCta
primary
value="Confirmer"
value="Annuler"
disabled={loading}
onPress={() => handleActivation()}
onPress={() => (Alert.alert("Annuler", "Êtes-vous sûr de vouloir annuler l'activation ?", [
{ text: "Continer l'activation", style: "cancel" },
{ text: "Confirmer", style: "destructive", onPress: () => navigation.pop() }
]))}
/>
</View>
</SafeAreaView>
Expand Down

0 comments on commit 1a54306

Please sign in to comment.