@planningcenter/chat-react-native 3.16.0-rc.5 → 3.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/build/contexts/chat_context.d.ts +3 -0
  2. package/build/contexts/chat_context.d.ts.map +1 -1
  3. package/build/contexts/chat_context.js +3 -1
  4. package/build/contexts/chat_context.js.map +1 -1
  5. package/build/hooks/index.d.ts +3 -0
  6. package/build/hooks/index.d.ts.map +1 -1
  7. package/build/hooks/index.js +3 -0
  8. package/build/hooks/index.js.map +1 -1
  9. package/build/hooks/use_current_person.d.ts.map +1 -1
  10. package/build/hooks/use_current_person.js +9 -1
  11. package/build/hooks/use_current_person.js.map +1 -1
  12. package/build/hooks/use_organization.d.ts +39 -0
  13. package/build/hooks/use_organization.d.ts.map +1 -0
  14. package/build/hooks/use_organization.js +14 -0
  15. package/build/hooks/use_organization.js.map +1 -0
  16. package/build/hooks/use_qualified_by_age.d.ts +2 -0
  17. package/build/hooks/use_qualified_by_age.d.ts.map +1 -0
  18. package/build/hooks/use_qualified_by_age.js +14 -0
  19. package/build/hooks/use_qualified_by_age.js.map +1 -0
  20. package/build/hooks/use_submit_age_check.d.ts +78 -0
  21. package/build/hooks/use_submit_age_check.d.ts.map +1 -0
  22. package/build/hooks/use_submit_age_check.js +37 -0
  23. package/build/hooks/use_submit_age_check.js.map +1 -0
  24. package/build/index.d.ts +1 -0
  25. package/build/index.d.ts.map +1 -1
  26. package/build/index.js +1 -0
  27. package/build/index.js.map +1 -1
  28. package/build/navigation/chat_access_gate.d.ts +3 -0
  29. package/build/navigation/chat_access_gate.d.ts.map +1 -0
  30. package/build/navigation/chat_access_gate.js +46 -0
  31. package/build/navigation/chat_access_gate.js.map +1 -0
  32. package/build/navigation/index.d.ts +6 -4
  33. package/build/navigation/index.d.ts.map +1 -1
  34. package/build/navigation/index.js +6 -3
  35. package/build/navigation/index.js.map +1 -1
  36. package/build/navigation/screenLayout.d.ts +3 -0
  37. package/build/navigation/screenLayout.d.ts.map +1 -1
  38. package/build/navigation/screenLayout.js +8 -0
  39. package/build/navigation/screenLayout.js.map +1 -1
  40. package/build/screens/age_check/age_check_required_screen.d.ts +3 -0
  41. package/build/screens/age_check/age_check_required_screen.d.ts.map +1 -0
  42. package/build/screens/age_check/age_check_required_screen.js +148 -0
  43. package/build/screens/age_check/age_check_required_screen.js.map +1 -0
  44. package/build/screens/age_check/age_check_underage_screen.d.ts +6 -0
  45. package/build/screens/age_check/age_check_underage_screen.d.ts.map +1 -0
  46. package/build/screens/age_check/age_check_underage_screen.js +71 -0
  47. package/build/screens/age_check/age_check_underage_screen.js.map +1 -0
  48. package/build/screens/age_check/components/age_check_select_birthdate_modal.d.ts +11 -0
  49. package/build/screens/age_check/components/age_check_select_birthdate_modal.d.ts.map +1 -0
  50. package/build/screens/age_check/components/age_check_select_birthdate_modal.js +91 -0
  51. package/build/screens/age_check/components/age_check_select_birthdate_modal.js.map +1 -0
  52. package/build/screens/age_check/index.d.ts +3 -0
  53. package/build/screens/age_check/index.d.ts.map +1 -0
  54. package/build/screens/age_check/index.js +3 -0
  55. package/build/screens/age_check/index.js.map +1 -0
  56. package/build/screens/age_check/screen_props.d.ts +5 -0
  57. package/build/screens/age_check/screen_props.d.ts.map +1 -0
  58. package/build/screens/age_check/screen_props.js +2 -0
  59. package/build/screens/age_check/screen_props.js.map +1 -0
  60. package/build/types/resources/index.d.ts +1 -0
  61. package/build/types/resources/index.d.ts.map +1 -1
  62. package/build/types/resources/index.js +1 -0
  63. package/build/types/resources/index.js.map +1 -1
  64. package/build/types/resources/organization.d.ts +6 -0
  65. package/build/types/resources/organization.d.ts.map +1 -0
  66. package/build/types/resources/organization.js +2 -0
  67. package/build/types/resources/organization.js.map +1 -0
  68. package/build/types/resources/person.d.ts +7 -0
  69. package/build/types/resources/person.d.ts.map +1 -1
  70. package/build/types/resources/person.js +5 -1
  71. package/build/types/resources/person.js.map +1 -1
  72. package/package.json +3 -2
  73. package/src/contexts/chat_context.tsx +14 -1
  74. package/src/hooks/index.ts +3 -0
  75. package/src/hooks/use_current_person.ts +9 -1
  76. package/src/hooks/use_organization.ts +17 -0
  77. package/src/hooks/use_qualified_by_age.ts +17 -0
  78. package/src/hooks/use_submit_age_check.ts +48 -0
  79. package/src/index.tsx +1 -0
  80. package/src/navigation/chat_access_gate.tsx +60 -0
  81. package/src/navigation/index.tsx +6 -3
  82. package/src/navigation/screenLayout.tsx +11 -0
  83. package/src/screens/age_check/age_check_required_screen.tsx +197 -0
  84. package/src/screens/age_check/age_check_underage_screen.tsx +96 -0
  85. package/src/screens/age_check/components/age_check_select_birthdate_modal.tsx +143 -0
  86. package/src/screens/age_check/index.ts +2 -0
  87. package/src/screens/age_check/screen_props.ts +3 -0
  88. package/src/types/resources/index.ts +1 -0
  89. package/src/types/resources/organization.ts +6 -0
  90. package/src/types/resources/person.ts +10 -0
@@ -0,0 +1,143 @@
1
+ import React from 'react'
2
+ import { Modal, Platform, StyleSheet, View } from 'react-native'
3
+ import DateTimePicker, { DateTimePickerEvent } from '@react-native-community/datetimepicker'
4
+ import FormSheet from '../../../components/primitive/form_sheet'
5
+ import { Text } from '../../../components/display/text'
6
+ import { useTheme } from '../../../hooks'
7
+
8
+ export type AgeCheckSelectBirthdateProps = {
9
+ onChange: (date: Date) => void
10
+ onDismiss?: () => void
11
+ onRequestClose: () => void
12
+ onSubmit: (date: Date) => void
13
+ value?: Date | null
14
+ visible?: boolean
15
+ }
16
+
17
+ export function AgeCheckSelectBirthdateModal(props: AgeCheckSelectBirthdateProps) {
18
+ if (Platform.OS === 'ios') return <IOSBirthdateModal {...props} />
19
+ if (Platform.OS === 'android') return <AndroidBirthdatePicker {...props} />
20
+
21
+ return <Text>Birthdate selection is not supported on this platform.</Text>
22
+ }
23
+
24
+ function IOSBirthdateModal({
25
+ onChange,
26
+ onDismiss,
27
+ onRequestClose,
28
+ onSubmit,
29
+ value,
30
+ visible,
31
+ }: AgeCheckSelectBirthdateProps) {
32
+ const styles = useStyles()
33
+ const today = React.useMemo(() => new Date(), [])
34
+ const selected = value || today
35
+
36
+ const handleChange = (_event: DateTimePickerEvent, date?: Date) => {
37
+ if (date) onChange(date)
38
+ }
39
+
40
+ const handleSave = () => {
41
+ onSubmit(selected)
42
+ onRequestClose()
43
+ }
44
+
45
+ return (
46
+ <Modal
47
+ visible={visible}
48
+ animationType="slide"
49
+ presentationStyle="pageSheet"
50
+ onRequestClose={onRequestClose}
51
+ onDismiss={onDismiss}
52
+ >
53
+ <FormSheet.Root style={styles.formSheet} contentStyle={styles.formSheetContent}>
54
+ <FormSheet.Header>
55
+ <FormSheet.HeaderTitle>Your birthdate</FormSheet.HeaderTitle>
56
+ <FormSheet.HeaderActions>
57
+ <FormSheet.HeaderTextButton onPress={onRequestClose}>Cancel</FormSheet.HeaderTextButton>
58
+ <FormSheet.HeaderButton title="Save" onPress={handleSave} />
59
+ </FormSheet.HeaderActions>
60
+ </FormSheet.Header>
61
+ <View style={styles.content}>
62
+ <View style={styles.card}>
63
+ <Text nativeID="birthdateLabel" variant="tertiary" style={styles.label}>
64
+ Birthdate
65
+ </Text>
66
+ <View style={styles.pickerContainer}>
67
+ <DateTimePicker
68
+ accessibilityLabelledBy="birthdateLabel"
69
+ testID="age-check-date-picker"
70
+ mode="date"
71
+ display="spinner"
72
+ value={selected}
73
+ maximumDate={today}
74
+ onChange={handleChange}
75
+ />
76
+ </View>
77
+ </View>
78
+ </View>
79
+ </FormSheet.Root>
80
+ </Modal>
81
+ )
82
+ }
83
+
84
+ function AndroidBirthdatePicker({
85
+ onRequestClose,
86
+ onSubmit,
87
+ value,
88
+ visible,
89
+ }: AgeCheckSelectBirthdateProps) {
90
+ if (!visible) return null
91
+
92
+ const today = new Date()
93
+ const selected = value || today
94
+
95
+ const handleAndroidDateChange = (event: DateTimePickerEvent, selectedDate?: Date) => {
96
+ if (event.type === 'set' && selectedDate) {
97
+ onSubmit(selectedDate)
98
+ }
99
+ onRequestClose()
100
+ }
101
+
102
+ return (
103
+ <DateTimePicker
104
+ testID="age-check-date-picker-android"
105
+ mode="date"
106
+ display="spinner"
107
+ value={selected}
108
+ maximumDate={today}
109
+ onChange={handleAndroidDateChange}
110
+ />
111
+ )
112
+ }
113
+
114
+ const useStyles = () => {
115
+ const { colors } = useTheme()
116
+ return StyleSheet.create({
117
+ formSheet: {
118
+ backgroundColor: colors.surfaceColor080,
119
+ },
120
+ formSheetContent: {
121
+ flex: 1,
122
+ },
123
+ content: {
124
+ flex: 1,
125
+ backgroundColor: colors.surfaceColor080,
126
+ padding: 16,
127
+ justifyContent: 'flex-start',
128
+ },
129
+ card: {
130
+ backgroundColor: colors.surfaceColor100,
131
+ borderRadius: 8,
132
+ padding: 16,
133
+ },
134
+ label: {
135
+ marginBottom: 8,
136
+ textTransform: 'uppercase',
137
+ },
138
+ pickerContainer: {
139
+ backgroundColor: colors.surfaceColor100,
140
+ borderRadius: 8,
141
+ },
142
+ })
143
+ }
@@ -0,0 +1,2 @@
1
+ export * from './age_check_required_screen'
2
+ export * from './age_check_underage_screen'
@@ -0,0 +1,3 @@
1
+ export type AgeCheckContactInfo = { contactEmail?: string }
2
+
3
+ export type AgeCheckParams = Record<string, AgeCheckContactInfo>
@@ -6,3 +6,4 @@ export * from './person'
6
6
  export * from './groups'
7
7
  export * from './app_grant'
8
8
  export * from './services'
9
+ export * from './organization'
@@ -0,0 +1,6 @@
1
+ import { ResourceObject } from '../api_primitives'
2
+
3
+ export interface OrganizationResource extends ResourceObject {
4
+ type: 'Organization'
5
+ contactEmail?: string
6
+ }
@@ -1,5 +1,14 @@
1
1
  import { ResourceObject } from '../api_primitives'
2
2
 
3
+ export const AgeQualificationStatus = {
4
+ QUALIFIED: 'qualified',
5
+ DISQUALIFIED: 'disqualified',
6
+ UNKNOWN: 'unknown',
7
+ } as const
8
+
9
+ export type AgeQualificationStatus =
10
+ (typeof AgeQualificationStatus)[keyof typeof AgeQualificationStatus]
11
+
3
12
  export interface PersonResource extends ResourceObject {
4
13
  id: number
5
14
  type: 'Person'
@@ -11,4 +20,5 @@ export interface CurrentPersonResource extends PersonResource {
11
20
  canChat: boolean
12
21
  unreadCount: number
13
22
  pcoChatEnabled: boolean
23
+ ageQualificationStatus?: AgeQualificationStatus
14
24
  }