1- import AntDesign from '@expo/vector-icons/AntDesign' ;
21import { useTheme } from "@react-navigation/native" ;
2+ import { NativeStackScreenProps } from "@react-navigation/native-stack" ;
33import { useState } from "react" ;
44import { View , Text , TouchableOpacity , TextInput , ScrollView , KeyboardAvoidingView , Platform , Linking } from "react-native" ;
5- import Modal from "react-native-modal" ;
65
7- import User from "../../ lib/types/User " ;
8- import { palette } from "../../ theme" ;
6+ import { CardsStackParamList } from "../lib/NavigatorParamList " ;
7+ import { palette } from "../theme" ;
98
10- import CardIcon from "./CardIcon" ;
11- import RepIcon from "./RepIcon" ;
9+ import CardIcon from "../components/cards/CardIcon" ;
10+ import RepIcon from "../components/cards/RepIcon" ;
11+ import { SafeAreaView } from "react-native-safe-area-context" ;
1212
13+ type Props = NativeStackScreenProps < CardsStackParamList , "OrderCard" > ;
1314
14- interface OrderCardModalProps {
15- isVisible : boolean ;
16- onClose : ( ) => void ;
17- user : User ;
18- organizations : string [ ] ;
19- }
15+ export default function OrderCardScreen ( { navigation, route } : Props ) {
16+ const { colors : themeColors } = useTheme ( ) ;
17+ const { user, organizations } = route . params ;
2018
21- export default function OrderCardModal ( { isVisible , onClose , user , organizations } : OrderCardModalProps ) {
19+ // Form state variables
2220 const [ cardType , setCardType ] = useState ( "virtual" ) ; // 'virtual' or 'plastic'
23- const { colors : themeColors } = useTheme ( ) ;
21+ const [ organization , setOrganization ] = useState ( organizations ?. [ 0 ] || "" ) ;
22+ const [ shippingName , setShippingName ] = useState ( user ?. name || "" ) ;
23+ const [ addressLine1 , setAddressLine1 ] = useState ( "" ) ;
24+ const [ addressLine2 , setAddressLine2 ] = useState ( "" ) ;
25+ const [ city , setCity ] = useState ( "" ) ;
26+ const [ stateProvince , setStateProvince ] = useState ( "" ) ;
27+ const [ zipCode , setZipCode ] = useState ( "" ) ;
28+ const [ country , setCountry ] = useState ( "United States" ) ;
2429
2530 return (
26- < Modal
27- isVisible = { isVisible }
28- onBackdropPress = { onClose }
29- animationIn = "zoomIn"
30- animationOut = "zoomOut"
31- backdropOpacity = { 0.5 }
32- style = { { margin : 0 , justifyContent : "center" } }
33- >
31+ < SafeAreaView style = { { flex : 1 , marginTop : 30 } } >
3432 < KeyboardAvoidingView
3533 behavior = { Platform . OS === "ios" ? "padding" : undefined }
36- style = { { flex : 1 , justifyContent : "center" } }
34+ style = { { flex : 1 } }
3735 >
3836 < ScrollView
37+ scrollToOverflowEnabled = { false }
38+ bounces = { false }
39+ showsVerticalScrollIndicator = { false }
3940 contentContainerStyle = { {
4041 flexGrow : 1 ,
41- justifyContent : "center" ,
42- padding : 5 ,
43- paddingBottom : cardType === "plastic" ? 30 : 0 ,
44- } }
45- style = { {
46- backgroundColor : themeColors . background ,
47- borderRadius : 20 ,
48- marginHorizontal : 20 ,
4942 padding : 20 ,
50- maxHeight : cardType === "plastic" ? "80%" : "60%" ,
43+ paddingBottom : cardType === "plastic" ? 50 : 20 ,
5144 } }
5245 >
53- < View style = { { flexDirection : "row" , justifyContent : "space-between" , alignItems : "flex-start" , marginBottom : 20 } } >
54- < Text
55- style = { {
56- color : themeColors . text ,
57- fontSize : 20 ,
58- fontWeight : "bold" ,
59- } }
60- >
61- Order a card
62- </ Text >
63- < AntDesign name = "closecircle" size = { 24 } color = { themeColors . text } />
64- </ View >
46+ < Text
47+ style = { {
48+ color : themeColors . text ,
49+ fontSize : 22 ,
50+ fontWeight : "bold" ,
51+ marginBottom : 20 ,
52+ } }
53+ >
54+ Order a card
55+ </ Text >
56+
6557 < Text
6658 style = { {
6759 color : palette . smoke ,
@@ -97,7 +89,6 @@ export default function OrderCardModal({ isVisible, onClose, user, organizations
9789 style = { {
9890 flexDirection : "row" ,
9991 justifyContent : "space-between" ,
100- marginBottom : 20 ,
10192 } }
10293 >
10394 < TouchableOpacity
@@ -165,8 +156,18 @@ export default function OrderCardModal({ isVisible, onClose, user, organizations
165156 Mailed, 10-12 biz. days
166157 </ Text >
167158 </ TouchableOpacity >
168- </ View >
169159
160+ </ View >
161+ < Text
162+ style = { {
163+ color : palette . smoke ,
164+ fontSize : 12 ,
165+ marginTop : 10 ,
166+ marginBottom : 20 ,
167+ } }
168+ >
169+ Physical cards can only be shipped within the US.
170+ </ Text >
170171 { cardType === "plastic" && (
171172 < >
172173 < Text
@@ -181,7 +182,8 @@ export default function OrderCardModal({ isVisible, onClose, user, organizations
181182 < TextInput
182183 placeholder = "Shipping name"
183184 placeholderTextColor = { palette . muted }
184- value = { user . name }
185+ value = { shippingName }
186+ onChangeText = { setShippingName }
185187 style = { {
186188 backgroundColor : themeColors . card ,
187189 color : themeColors . text ,
@@ -193,6 +195,8 @@ export default function OrderCardModal({ isVisible, onClose, user, organizations
193195 < TextInput
194196 placeholder = "Address (line 1)"
195197 placeholderTextColor = { palette . muted }
198+ value = { addressLine1 }
199+ onChangeText = { setAddressLine1 }
196200 style = { {
197201 backgroundColor : themeColors . card ,
198202 color : themeColors . text ,
@@ -204,6 +208,8 @@ export default function OrderCardModal({ isVisible, onClose, user, organizations
204208 < TextInput
205209 placeholder = "Address (line 2)"
206210 placeholderTextColor = { palette . muted }
211+ value = { addressLine2 }
212+ onChangeText = { setAddressLine2 }
207213 style = { {
208214 backgroundColor : themeColors . card ,
209215 color : themeColors . text ,
@@ -223,6 +229,8 @@ export default function OrderCardModal({ isVisible, onClose, user, organizations
223229 < TextInput
224230 placeholder = "City"
225231 placeholderTextColor = { palette . muted }
232+ value = { city }
233+ onChangeText = { setCity }
226234 style = { {
227235 backgroundColor : themeColors . card ,
228236 color : themeColors . text ,
@@ -234,6 +242,8 @@ export default function OrderCardModal({ isVisible, onClose, user, organizations
234242 < TextInput
235243 placeholder = "State / province"
236244 placeholderTextColor = { palette . muted }
245+ value = { stateProvince }
246+ onChangeText = { setStateProvince }
237247 style = { {
238248 backgroundColor : themeColors . card ,
239249 color : themeColors . text ,
@@ -254,6 +264,8 @@ export default function OrderCardModal({ isVisible, onClose, user, organizations
254264 < TextInput
255265 placeholder = "ZIP code"
256266 placeholderTextColor = { palette . muted }
267+ value = { zipCode }
268+ onChangeText = { setZipCode }
257269 style = { {
258270 backgroundColor : themeColors . card ,
259271 color : themeColors . text ,
@@ -265,6 +277,8 @@ export default function OrderCardModal({ isVisible, onClose, user, organizations
265277 < TextInput
266278 placeholder = "Country"
267279 placeholderTextColor = { palette . muted }
280+ value = { country }
281+ onChangeText = { setCountry }
268282 style = { {
269283 backgroundColor : themeColors . card ,
270284 color : themeColors . text ,
@@ -287,23 +301,23 @@ export default function OrderCardModal({ isVisible, onClose, user, organizations
287301 Plastic cards can only be shipped within the US.
288302 </ Text >
289303
304+ < Text
305+ style = { {
306+ color : palette . muted ,
307+ fontSize : 12 ,
308+ marginBottom : 20 ,
309+ } }
310+ >
311+ By submitting, you agree to Stripe's{ ' ' }
290312 < Text
291- style = { {
292- color : palette . muted ,
293- fontSize : 12 ,
294- marginBottom : 20 ,
295- } }
296- >
297- By submitting, you agree to Stripe's{ ' ' }
298- < Text
299- style = { { textDecorationLine : 'underline' } }
300- onPress = { ( ) => Linking . openURL ( 'https://www.stripe.com/cardholder-terms' ) }
301- >
302- cardholder terms
303- </ Text > . Your name,
304- birthday, and contact information is shared with them and their
305- banking partners.
306- </ Text >
313+ style = { { textDecorationLine : 'underline' } }
314+ onPress = { ( ) => Linking . openURL ( 'https://www.stripe.com/cardholder-terms' ) }
315+ >
316+ cardholder terms
317+ </ Text > . Your name,
318+ birthday, and contact information is shared with them and their
319+ banking partners.
320+ </ Text >
307321
308322 < TouchableOpacity
309323 style = { {
@@ -312,14 +326,14 @@ export default function OrderCardModal({ isVisible, onClose, user, organizations
312326 borderRadius : 10 ,
313327 alignItems : "center" ,
314328 } }
315- onPress = { onClose }
329+ onPress = { ( ) => navigation . goBack ( ) }
316330 >
317331 < Text style = { { color : themeColors . text , fontWeight : "bold" } } >
318332 Issue my card
319333 </ Text >
320334 </ TouchableOpacity >
321335 </ ScrollView >
322336 </ KeyboardAvoidingView >
323- </ Modal >
337+ </ SafeAreaView >
324338 ) ;
325- }
339+ }
0 commit comments