@@ -3,11 +3,14 @@ import { Screen } from "@/router/helpers/types";
3
3
import { useCurrentAccount } from "@/stores/account" ;
4
4
import { useTheme } from "@react-navigation/native" ;
5
5
import * as ImagePicker from "expo-image-picker" ;
6
- import { Camera , Plus , TextCursorInput , User2 , UserCircle2 , WholeWord } from "lucide-react-native" ;
6
+ import { Camera , ChevronDown , ChevronUp , Plus , TextCursorInput , User2 , UserCircle2 , WholeWord } from "lucide-react-native" ;
7
7
import React , { useEffect , useRef , useState } from "react" ;
8
- import { ActivityIndicator , Image , KeyboardAvoidingView , ScrollView , Switch , TextInput } from "react-native" ;
8
+ import { ActivityIndicator , Alert , Image , KeyboardAvoidingView , ScrollView , Switch , TextInput } from "react-native" ;
9
9
import { useSafeAreaInsets } from "react-native-safe-area-context" ;
10
10
11
+ import * as Clipboard from "expo-clipboard" ;
12
+ import { TouchableOpacity } from "react-native-gesture-handler" ;
13
+
11
14
const SettingsProfile : Screen < "SettingsProfile" > = ( { navigation } ) => {
12
15
const theme = useTheme ( ) ;
13
16
const insets = useSafeAreaInsets ( ) ;
@@ -80,6 +83,48 @@ const SettingsProfile: Screen<"SettingsProfile"> = ({ navigation }) => {
80
83
} ) ;
81
84
} , [ hideNameOnHomeScreen , hideProfilePicOnHomeScreen ] ) ;
82
85
86
+ const identityData = account . identity ? [
87
+ account . identity . civility && {
88
+ label : "Civilité" ,
89
+ value : account . identity . civility === "M" ? "Monsieur" : "Madame" ,
90
+ } ,
91
+ account . identity . birthDate && {
92
+ label : "Date de naissance" ,
93
+ value : new Date ( account . identity . birthDate ) . toLocaleDateString ( "fr-FR" , {
94
+ year : "numeric" ,
95
+ month : "long" ,
96
+ day : "numeric" ,
97
+ } ) ,
98
+ } ,
99
+ account . identity . birthPlace && {
100
+ label : "Lieu de naissance" ,
101
+ value : account . identity . birthPlace ,
102
+ } ,
103
+ account . identity . ine && {
104
+ label : "INE" ,
105
+ value : account . identity . ine ,
106
+ } ,
107
+ account . identity . boursier && {
108
+ label : "Boursier" ,
109
+ value : "Oui" ,
110
+ } ,
111
+ account . identity . email && {
112
+ label : "Email" ,
113
+ value : account . identity . email [ 0 ] ,
114
+ } ,
115
+ account . identity . phone && {
116
+ label : "Téléphone" ,
117
+ value : account . identity . phone [ 0 ] ,
118
+ } ,
119
+ account . identity . address && {
120
+ label : "Adresse" ,
121
+ value : `${ account . identity . address . street } , ${ account . identity . address . zipCode } ${ account . identity . address . city } ` ,
122
+ } ,
123
+ ] . filter ( Boolean ) as { label : string , value : string } [
124
+ ] : [ ] ;
125
+
126
+ const [ showIdentity , setShowIdentity ] = useState ( false ) ;
127
+
83
128
return (
84
129
< KeyboardAvoidingView
85
130
behavior = "padding"
@@ -228,6 +273,50 @@ const SettingsProfile: Screen<"SettingsProfile"> = ({ navigation }) => {
228
273
</ NativeText >
229
274
</ NativeItem >
230
275
</ NativeList >
276
+
277
+ { account . identity && Object . keys ( account . identity ) !== undefined && Object . keys ( account . identity ) . length > 0 && (
278
+ < NativeListHeader
279
+ label = "Informations d'identité"
280
+ trailing = {
281
+ < TouchableOpacity
282
+ onPress = { ( ) => setShowIdentity ( ! showIdentity ) }
283
+ >
284
+ { showIdentity ?
285
+ < ChevronUp
286
+ size = { 24 }
287
+ color = { theme . colors . primary }
288
+ /> :
289
+ < ChevronDown
290
+ size = { 24 }
291
+ color = { theme . colors . primary }
292
+ />
293
+ }
294
+ </ TouchableOpacity >
295
+ }
296
+ />
297
+ ) }
298
+
299
+ { showIdentity && (
300
+ < NativeList >
301
+ { identityData . map ( ( item , index ) => (
302
+ < NativeItem
303
+ key = { "identityData_" + index }
304
+ onPress = { async ( ) => {
305
+ await Clipboard . setStringAsync ( item . value ) ;
306
+ Alert . alert ( "Copié" , "L'information a été copiée dans le presse-papier." ) ;
307
+ } }
308
+ chevron = { false }
309
+ >
310
+ < NativeText variant = "subtitle" >
311
+ { item . label }
312
+ </ NativeText >
313
+ < NativeText variant = "body" >
314
+ { item . value }
315
+ </ NativeText >
316
+ </ NativeItem >
317
+ ) ) }
318
+ </ NativeList >
319
+ ) }
231
320
</ ScrollView >
232
321
</ KeyboardAvoidingView >
233
322
) ;
0 commit comments