@planningcenter/chat-react-native 3.24.0-rc.1 → 3.24.0-rc.10
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.
- package/build/components/conversations/conversation_actions.d.ts.map +1 -1
- package/build/components/conversations/conversation_actions.js +5 -1
- package/build/components/conversations/conversation_actions.js.map +1 -1
- package/build/components/conversations/conversations.d.ts.map +1 -1
- package/build/components/conversations/conversations.js +5 -1
- package/build/components/conversations/conversations.js.map +1 -1
- package/build/components/display/platform_modal_header_buttons.d.ts +8 -0
- package/build/components/display/platform_modal_header_buttons.d.ts.map +1 -1
- package/build/components/display/platform_modal_header_buttons.js +8 -0
- package/build/components/display/platform_modal_header_buttons.js.map +1 -1
- package/build/components/primitive/form_sheet.d.ts +1 -1
- package/build/components/primitive/form_sheet.d.ts.map +1 -1
- package/build/components/primitive/form_sheet.js +1 -1
- package/build/components/primitive/form_sheet.js.map +1 -1
- package/build/hooks/index.d.ts +1 -0
- package/build/hooks/index.d.ts.map +1 -1
- package/build/hooks/index.js +1 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use_features.d.ts +1 -0
- package/build/hooks/use_features.d.ts.map +1 -1
- package/build/hooks/use_features.js +1 -0
- package/build/hooks/use_features.js.map +1 -1
- package/build/hooks/use_new_conversation_entry.d.ts +3 -0
- package/build/hooks/use_new_conversation_entry.d.ts.map +1 -0
- package/build/hooks/use_new_conversation_entry.js +20 -0
- package/build/hooks/use_new_conversation_entry.js.map +1 -0
- package/build/hooks/use_report_message.d.ts +6 -0
- package/build/hooks/use_report_message.d.ts.map +1 -0
- package/build/hooks/use_report_message.js +28 -0
- package/build/hooks/use_report_message.js.map +1 -0
- package/build/hooks/use_teams.d.ts.map +1 -1
- package/build/hooks/use_teams.js +1 -0
- package/build/hooks/use_teams.js.map +1 -1
- package/build/navigation/index.d.ts +52 -10
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +41 -7
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_new_entry_screen.d.ts +4 -0
- package/build/screens/conversation_select_recipients/conversation_new_entry_screen.d.ts.map +1 -0
- package/build/screens/conversation_select_recipients/conversation_new_entry_screen.js +67 -0
- package/build/screens/conversation_select_recipients/conversation_new_entry_screen.js.map +1 -0
- package/build/screens/conversation_select_recipients/conversation_select_teams_i_lead_recipients_screen.d.ts.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_select_teams_i_lead_recipients_screen.js +17 -2
- package/build/screens/conversation_select_recipients/conversation_select_teams_i_lead_recipients_screen.js.map +1 -1
- package/build/screens/conversation_select_type_screen.d.ts +11 -0
- package/build/screens/conversation_select_type_screen.d.ts.map +1 -0
- package/build/screens/conversation_select_type_screen.js +38 -0
- package/build/screens/conversation_select_type_screen.js.map +1 -0
- package/build/screens/conversations/components/list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/list_header_component.js +18 -7
- package/build/screens/conversations/components/list_header_component.js.map +1 -1
- package/build/screens/group_notification_settings_screen.d.ts +8 -0
- package/build/screens/group_notification_settings_screen.d.ts.map +1 -0
- package/build/screens/group_notification_settings_screen.js +79 -0
- package/build/screens/group_notification_settings_screen.js.map +1 -0
- package/build/screens/index.d.ts +4 -1
- package/build/screens/index.d.ts.map +1 -1
- package/build/screens/index.js +4 -1
- package/build/screens/index.js.map +1 -1
- package/build/screens/message_actions_screen.js +14 -2
- package/build/screens/message_actions_screen.js.map +1 -1
- package/build/screens/message_report/components/message_preview.d.ts +10 -0
- package/build/screens/message_report/components/message_preview.d.ts.map +1 -0
- package/build/screens/message_report/components/message_preview.js +74 -0
- package/build/screens/message_report/components/message_preview.js.map +1 -0
- package/build/screens/message_report/components/report_reason_list.d.ts +9 -0
- package/build/screens/message_report/components/report_reason_list.d.ts.map +1 -0
- package/build/screens/message_report/components/report_reason_list.js +67 -0
- package/build/screens/message_report/components/report_reason_list.js.map +1 -0
- package/build/screens/message_report_screen.d.ts +10 -0
- package/build/screens/message_report_screen.d.ts.map +1 -0
- package/build/screens/message_report_screen.js +214 -0
- package/build/screens/message_report_screen.js.map +1 -0
- package/build/screens/notification_settings/hooks/groups.d.ts +94 -0
- package/build/screens/notification_settings/hooks/groups.d.ts.map +1 -0
- package/build/screens/notification_settings/hooks/groups.js +92 -0
- package/build/screens/notification_settings/hooks/groups.js.map +1 -0
- package/build/screens/notification_settings_screen.d.ts +5 -0
- package/build/screens/notification_settings_screen.d.ts.map +1 -0
- package/build/screens/notification_settings_screen.js +234 -0
- package/build/screens/notification_settings_screen.js.map +1 -0
- package/build/screens/preferred_app/hooks/use_chat_types.d.ts +39 -0
- package/build/screens/preferred_app/hooks/use_chat_types.d.ts.map +1 -0
- package/build/screens/preferred_app/hooks/use_chat_types.js +12 -0
- package/build/screens/preferred_app/hooks/use_chat_types.js.map +1 -0
- package/build/screens/preferred_app_selection_screen.d.ts +10 -0
- package/build/screens/preferred_app_selection_screen.d.ts.map +1 -0
- package/build/screens/preferred_app_selection_screen.js +128 -0
- package/build/screens/preferred_app_selection_screen.js.map +1 -0
- package/build/types/resources/group_membership.d.ts +6 -0
- package/build/types/resources/group_membership.d.ts.map +1 -0
- package/build/types/resources/group_membership.js +2 -0
- package/build/types/resources/group_membership.js.map +1 -0
- package/build/types/resources/group_resource.d.ts +4 -0
- package/build/types/resources/group_resource.d.ts.map +1 -1
- package/build/types/resources/group_resource.js.map +1 -1
- package/build/types/resources/index.d.ts +2 -0
- package/build/types/resources/index.d.ts.map +1 -1
- package/build/types/resources/index.js +2 -0
- package/build/types/resources/index.js.map +1 -1
- package/build/types/resources/message_report.d.ts +19 -0
- package/build/types/resources/message_report.d.ts.map +1 -0
- package/build/types/resources/message_report.js +9 -0
- package/build/types/resources/message_report.js.map +1 -0
- package/package.json +2 -2
- package/src/components/conversations/conversation_actions.tsx +6 -1
- package/src/components/conversations/conversations.tsx +6 -1
- package/src/components/display/platform_modal_header_buttons.tsx +16 -0
- package/src/components/primitive/form_sheet.tsx +4 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use_features.ts +1 -0
- package/src/hooks/use_new_conversation_entry.ts +31 -0
- package/src/hooks/use_report_message.ts +37 -0
- package/src/hooks/use_teams.ts +1 -0
- package/src/navigation/index.tsx +51 -7
- package/src/screens/conversation_select_recipients/conversation_new_entry_screen.tsx +100 -0
- package/src/screens/conversation_select_recipients/conversation_select_teams_i_lead_recipients_screen.tsx +23 -3
- package/src/screens/conversation_select_type_screen.tsx +59 -0
- package/src/screens/conversations/components/list_header_component.tsx +20 -7
- package/src/screens/group_notification_settings_screen.tsx +92 -0
- package/src/screens/index.ts +4 -1
- package/src/screens/message_actions_screen.tsx +24 -2
- package/src/screens/message_report/components/message_preview.tsx +92 -0
- package/src/screens/message_report/components/report_reason_list.tsx +106 -0
- package/src/screens/message_report_screen.tsx +278 -0
- package/src/screens/notification_settings/hooks/groups.ts +101 -0
- package/src/screens/notification_settings_screen.tsx +383 -0
- package/src/screens/preferred_app/hooks/use_chat_types.ts +25 -0
- package/src/screens/preferred_app_selection_screen.tsx +169 -0
- package/src/types/images.d.ts +14 -0
- package/src/types/resources/group_membership.ts +6 -0
- package/src/types/resources/group_resource.ts +5 -0
- package/src/types/resources/index.ts +2 -0
- package/src/types/resources/message_report.ts +20 -0
- package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.d.ts +0 -4
- package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.d.ts.map +0 -1
- package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.js +0 -146
- package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.js.map +0 -1
- package/src/screens/conversation_select_recipients/conversation_select_recipients_screen.tsx +0 -215
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, StyleSheet } from 'react-native';
|
|
3
|
+
import { PlatformPressable } from '@react-navigation/elements';
|
|
4
|
+
import { Text } from '../../../components';
|
|
5
|
+
import { useTheme, useCreateAndroidRippleColor } from '../../../hooks';
|
|
6
|
+
import { Haptic } from '../../../utils/native_adapters';
|
|
7
|
+
import { MESSAGE_REPORT_REASONS, } from '../../../types/resources/message_report';
|
|
8
|
+
const MESSAGE_REPORT_REASONS_LIST = Object.entries(MESSAGE_REPORT_REASONS).map(([key, label]) => ({
|
|
9
|
+
key: key,
|
|
10
|
+
label,
|
|
11
|
+
}));
|
|
12
|
+
export function ReportReasonList({ selectedReason, onReasonChange }) {
|
|
13
|
+
return (<View>
|
|
14
|
+
{MESSAGE_REPORT_REASONS_LIST.map(({ key, label }) => (<ReportReasonButton key={key} reason={key} label={label} isSelected={selectedReason === key} onPress={() => {
|
|
15
|
+
Haptic.impactLight();
|
|
16
|
+
onReasonChange(key);
|
|
17
|
+
}}/>))}
|
|
18
|
+
</View>);
|
|
19
|
+
}
|
|
20
|
+
function ReportReasonButton({ label, isSelected, onPress }) {
|
|
21
|
+
const styles = useStyles({ isSelected });
|
|
22
|
+
const { colors } = useTheme();
|
|
23
|
+
const androidRippleColor = useCreateAndroidRippleColor({ color: colors.fillColorNeutral060 });
|
|
24
|
+
return (<PlatformPressable onPress={onPress} style={styles.pressable} android_ripple={{ color: androidRippleColor }} accessibilityRole="radio" accessibilityState={{ selected: isSelected }} accessibilityLabel={label}>
|
|
25
|
+
<View style={styles.row}>
|
|
26
|
+
<View style={styles.radioButton}>
|
|
27
|
+
{isSelected && <View style={styles.radioButtonInner}/>}
|
|
28
|
+
</View>
|
|
29
|
+
<Text style={styles.label}>{label}</Text>
|
|
30
|
+
</View>
|
|
31
|
+
</PlatformPressable>);
|
|
32
|
+
}
|
|
33
|
+
const useStyles = ({ isSelected }) => {
|
|
34
|
+
const { colors } = useTheme();
|
|
35
|
+
return StyleSheet.create({
|
|
36
|
+
pressable: {
|
|
37
|
+
paddingVertical: 16,
|
|
38
|
+
paddingHorizontal: 16,
|
|
39
|
+
},
|
|
40
|
+
row: {
|
|
41
|
+
flexDirection: 'row',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
gap: 12,
|
|
44
|
+
},
|
|
45
|
+
radioButton: {
|
|
46
|
+
width: 20,
|
|
47
|
+
height: 20,
|
|
48
|
+
borderRadius: 10,
|
|
49
|
+
borderWidth: 2,
|
|
50
|
+
borderColor: isSelected ? colors.interaction : colors.borderColorDefaultBase,
|
|
51
|
+
justifyContent: 'center',
|
|
52
|
+
alignItems: 'center',
|
|
53
|
+
},
|
|
54
|
+
radioButtonInner: {
|
|
55
|
+
width: 10,
|
|
56
|
+
height: 10,
|
|
57
|
+
borderRadius: 5,
|
|
58
|
+
backgroundColor: colors.interaction,
|
|
59
|
+
},
|
|
60
|
+
label: {
|
|
61
|
+
fontSize: 16,
|
|
62
|
+
color: colors.textColorDefaultPrimary,
|
|
63
|
+
flex: 1,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=report_reason_list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report_reason_list.js","sourceRoot":"","sources":["../../../../src/screens/message_report/components/report_reason_list.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAA;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAA;AACvD,OAAO,EACL,sBAAsB,GAEvB,MAAM,yCAAyC,CAAA;AAEhD,MAAM,2BAA2B,GAAG,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IAChG,GAAG,EAAE,GAA0B;IAC/B,KAAK;CACN,CAAC,CAAC,CAAA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CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { View, StyleSheet } from 'react-native'\nimport { PlatformPressable } from '@react-navigation/elements'\nimport { Text } from '../../../components'\nimport { useTheme, useCreateAndroidRippleColor } from '../../../hooks'\nimport { Haptic } from '../../../utils/native_adapters'\nimport {\n MESSAGE_REPORT_REASONS,\n MessageReportReason,\n} from '../../../types/resources/message_report'\n\nconst MESSAGE_REPORT_REASONS_LIST = Object.entries(MESSAGE_REPORT_REASONS).map(([key, label]) => ({\n key: key as MessageReportReason,\n label,\n}))\n\ninterface ReportReasonListProps {\n selectedReason: MessageReportReason | null\n onReasonChange: (reason: MessageReportReason) => void\n}\n\nexport function ReportReasonList({ selectedReason, onReasonChange }: ReportReasonListProps) {\n return (\n <View>\n {MESSAGE_REPORT_REASONS_LIST.map(({ key, label }) => (\n <ReportReasonButton\n key={key}\n reason={key}\n label={label}\n isSelected={selectedReason === key}\n onPress={() => {\n Haptic.impactLight()\n onReasonChange(key)\n }}\n />\n ))}\n </View>\n )\n}\n\ninterface ReportReasonButtonProps {\n reason: MessageReportReason\n label: string\n isSelected: boolean\n onPress: () => void\n}\n\nfunction ReportReasonButton({ label, isSelected, onPress }: ReportReasonButtonProps) {\n const styles = useStyles({ isSelected })\n const { colors } = useTheme()\n const androidRippleColor = useCreateAndroidRippleColor({ color: colors.fillColorNeutral060 })\n\n return (\n <PlatformPressable\n onPress={onPress}\n style={styles.pressable}\n android_ripple={{ color: androidRippleColor }}\n accessibilityRole=\"radio\"\n accessibilityState={{ selected: isSelected }}\n accessibilityLabel={label}\n >\n <View style={styles.row}>\n <View style={styles.radioButton}>\n {isSelected && <View style={styles.radioButtonInner} />}\n </View>\n <Text style={styles.label}>{label}</Text>\n </View>\n </PlatformPressable>\n )\n}\n\nconst useStyles = ({ isSelected }: { isSelected: boolean }) => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n pressable: {\n paddingVertical: 16,\n paddingHorizontal: 16,\n },\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 12,\n },\n radioButton: {\n width: 20,\n height: 20,\n borderRadius: 10,\n borderWidth: 2,\n borderColor: isSelected ? colors.interaction : colors.borderColorDefaultBase,\n justifyContent: 'center',\n alignItems: 'center',\n },\n radioButtonInner: {\n width: 10,\n height: 10,\n borderRadius: 5,\n backgroundColor: colors.interaction,\n },\n label: {\n fontSize: 16,\n color: colors.textColorDefaultPrimary,\n flex: 1,\n },\n })\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { NativeStackNavigationOptions, NativeStackScreenProps } from '@react-navigation/native-stack';
|
|
3
|
+
import { StaticScreenProps } from '@react-navigation/native';
|
|
4
|
+
export declare const MessageReportScreenOptions: ({ navigation, }: NativeStackScreenProps<any>) => NativeStackNavigationOptions;
|
|
5
|
+
export type MessageReportScreenProps = StaticScreenProps<{
|
|
6
|
+
conversation_id: number;
|
|
7
|
+
message_id: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function MessageReportScreen({ route }: MessageReportScreenProps): React.JSX.Element | null;
|
|
10
|
+
//# sourceMappingURL=message_report_screen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message_report_screen.d.ts","sourceRoot":"","sources":["../../src/screens/message_report_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0D,MAAM,OAAO,CAAA;AAE9E,OAAO,KAAK,EACV,4BAA4B,EAC5B,sBAAsB,EACvB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAA+B,MAAM,0BAA0B,CAAA;AAmBzF,eAAO,MAAM,0BAA0B,oBAEpC,sBAAsB,CAAC,GAAG,CAAC,KAAG,4BAI/B,CAAA;AAEF,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;IACvD,eAAe,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAC,CAAA;AAEF,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,EAAE,wBAAwB,4BAStE"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import React, { useCallback, useLayoutEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { View, StyleSheet, TextInput, ScrollView } from 'react-native';
|
|
3
|
+
import { useNavigation, StackActions } from '@react-navigation/native';
|
|
4
|
+
import { Spinner, Text, KeyboardView } from '../components';
|
|
5
|
+
import BlankState from '../components/primitive/blank_state_primitive';
|
|
6
|
+
import { useTheme } from '../hooks';
|
|
7
|
+
import { useReportMessage } from '../hooks/use_report_message';
|
|
8
|
+
import { HeaderDismissButton, HeaderTextButton, } from '../components/display/platform_modal_header_buttons';
|
|
9
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
10
|
+
import { useConversationMessages } from '../hooks/use_conversation_messages';
|
|
11
|
+
import { MessagePreview } from './message_report/components/message_preview';
|
|
12
|
+
import { ReportReasonList } from './message_report/components/report_reason_list';
|
|
13
|
+
import { platformFontWeightBold } from '../utils';
|
|
14
|
+
const MAX_DETAIL_LENGTH = 500;
|
|
15
|
+
export const MessageReportScreenOptions = ({ navigation, }) => ({
|
|
16
|
+
presentation: 'modal',
|
|
17
|
+
title: 'Report message',
|
|
18
|
+
headerLeft: () => <HeaderDismissButton title="Cancel" onPress={() => navigation.goBack()}/>,
|
|
19
|
+
});
|
|
20
|
+
export function MessageReportScreen({ route }) {
|
|
21
|
+
const { conversation_id, message_id } = route.params;
|
|
22
|
+
const { messages } = useConversationMessages({ conversation_id }, { refetchOnMount: false });
|
|
23
|
+
const message = messages.find(m => m.id === message_id);
|
|
24
|
+
if (!message)
|
|
25
|
+
return null;
|
|
26
|
+
return <MessageReportScreenContent message={message} conversation_id={conversation_id}/>;
|
|
27
|
+
}
|
|
28
|
+
function MessageReportScreenContent({ message, conversation_id, }) {
|
|
29
|
+
const styles = useStyles();
|
|
30
|
+
const navigation = useNavigation();
|
|
31
|
+
const [selectedReason, setSelectedReason] = useState(null);
|
|
32
|
+
const [reasonDetail, setReasonDetail] = useState('');
|
|
33
|
+
const { mutate: submitReport, status } = useReportMessage(conversation_id, message.id);
|
|
34
|
+
const handleReasonChange = useCallback((reason) => {
|
|
35
|
+
setSelectedReason(reason);
|
|
36
|
+
if (reason !== 'other') {
|
|
37
|
+
setReasonDetail('');
|
|
38
|
+
}
|
|
39
|
+
}, []);
|
|
40
|
+
const isFormValid = useMemo(() => {
|
|
41
|
+
if (selectedReason === null)
|
|
42
|
+
return false;
|
|
43
|
+
if (selectedReason === 'other' && reasonDetail.trim().length === 0) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (status === 'pending')
|
|
47
|
+
return false;
|
|
48
|
+
return true;
|
|
49
|
+
}, [selectedReason, reasonDetail, status]);
|
|
50
|
+
const handleSubmit = useCallback(() => {
|
|
51
|
+
if (!isFormValid || !selectedReason)
|
|
52
|
+
return;
|
|
53
|
+
submitReport({
|
|
54
|
+
reason: selectedReason,
|
|
55
|
+
reasonDetail: selectedReason === 'other' ? reasonDetail : undefined,
|
|
56
|
+
});
|
|
57
|
+
}, [isFormValid, selectedReason, reasonDetail, submitReport]);
|
|
58
|
+
const handleClose = useCallback(() => {
|
|
59
|
+
navigation.dispatch(StackActions.popTo('Conversation', { conversation_id }));
|
|
60
|
+
}, [navigation, conversation_id]);
|
|
61
|
+
const HeaderRight = useCallback(() => <HeaderTextButton title="Submit" onPress={handleSubmit} disabled={!isFormValid}/>, [handleSubmit, isFormValid]);
|
|
62
|
+
useLayoutEffect(() => {
|
|
63
|
+
if (status === 'pending' || status === 'success') {
|
|
64
|
+
navigation.setOptions({
|
|
65
|
+
headerRight: () => null,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
navigation.setOptions({
|
|
70
|
+
headerTitle: 'Report message',
|
|
71
|
+
headerRight: HeaderRight,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}, [HeaderRight, navigation, status]);
|
|
75
|
+
if (status === 'pending') {
|
|
76
|
+
return (<View style={styles.fullScreenContainer}>
|
|
77
|
+
<Spinner />
|
|
78
|
+
<Text style={styles.loadingText}>Submitting report...</Text>
|
|
79
|
+
</View>);
|
|
80
|
+
}
|
|
81
|
+
if (status === 'success') {
|
|
82
|
+
return (<View style={styles.fullScreenContainer}>
|
|
83
|
+
<BlankState.Root>
|
|
84
|
+
<BlankState.Imagery name="general.checkCircle" style={styles.successIcon}/>
|
|
85
|
+
<BlankState.Content>
|
|
86
|
+
<BlankState.Heading style={styles.successTitle}>Message reported</BlankState.Heading>
|
|
87
|
+
<BlankState.Text style={styles.successSubtitle}>
|
|
88
|
+
The message has been reported and a church leader will be contacted.
|
|
89
|
+
</BlankState.Text>
|
|
90
|
+
</BlankState.Content>
|
|
91
|
+
<BlankState.Button title="Close" onPress={handleClose} size="lg" variant="fill"/>
|
|
92
|
+
</BlankState.Root>
|
|
93
|
+
</View>);
|
|
94
|
+
}
|
|
95
|
+
if (status === 'error') {
|
|
96
|
+
return (<BlankState.Root>
|
|
97
|
+
<BlankState.Imagery name="general.exclamationTriangle"/>
|
|
98
|
+
<BlankState.Content>
|
|
99
|
+
<BlankState.Heading>Unable to submit report</BlankState.Heading>
|
|
100
|
+
<BlankState.Text>
|
|
101
|
+
We were unable to report this message. Please try again.
|
|
102
|
+
</BlankState.Text>
|
|
103
|
+
</BlankState.Content>
|
|
104
|
+
<BlankState.Button title="Close" onPress={handleClose} size="lg" variant="outline"/>
|
|
105
|
+
</BlankState.Root>);
|
|
106
|
+
}
|
|
107
|
+
return (<KeyboardView>
|
|
108
|
+
<ScrollView contentContainerStyle={styles.container}>
|
|
109
|
+
<Text style={styles.warningText}>
|
|
110
|
+
Reporting this message will notify a church leader. The person you are reporting will not
|
|
111
|
+
receive a notification from Church Center. If someone is in immediate danger, call local
|
|
112
|
+
emergency services. Don't wait.
|
|
113
|
+
</Text>
|
|
114
|
+
|
|
115
|
+
<MessagePreview message={message}/>
|
|
116
|
+
|
|
117
|
+
<View style={styles.reasonSection}>
|
|
118
|
+
<Text style={styles.fieldLabel}>
|
|
119
|
+
What best describes the problem? <Text style={styles.required}>*</Text>
|
|
120
|
+
</Text>
|
|
121
|
+
|
|
122
|
+
<View style={styles.reasonListContainer}>
|
|
123
|
+
<ReportReasonList selectedReason={selectedReason} onReasonChange={handleReasonChange}/>
|
|
124
|
+
</View>
|
|
125
|
+
</View>
|
|
126
|
+
|
|
127
|
+
{selectedReason === 'other' && (<View style={styles.detailSection}>
|
|
128
|
+
<Text style={styles.fieldLabel}>
|
|
129
|
+
Please provide more details <Text style={styles.required}>*</Text>
|
|
130
|
+
</Text>
|
|
131
|
+
<TextInput style={styles.textInput} multiline placeholder="Describe the issue..." value={reasonDetail} onChangeText={setReasonDetail} maxLength={MAX_DETAIL_LENGTH} accessibilityLabel="Additional details" accessibilityHint="Provide more information about why you're reporting this message"/>
|
|
132
|
+
{reasonDetail.length >= MAX_DETAIL_LENGTH - 100 && (<Text variant="footnote">
|
|
133
|
+
{reasonDetail.length}/{MAX_DETAIL_LENGTH}
|
|
134
|
+
</Text>)}
|
|
135
|
+
</View>)}
|
|
136
|
+
</ScrollView>
|
|
137
|
+
</KeyboardView>);
|
|
138
|
+
}
|
|
139
|
+
const useStyles = () => {
|
|
140
|
+
const { bottom } = useSafeAreaInsets();
|
|
141
|
+
const { colors } = useTheme();
|
|
142
|
+
return StyleSheet.create({
|
|
143
|
+
container: {
|
|
144
|
+
padding: 16,
|
|
145
|
+
paddingBottom: 16 + bottom,
|
|
146
|
+
gap: 24,
|
|
147
|
+
},
|
|
148
|
+
fullHeight: {
|
|
149
|
+
flex: 1,
|
|
150
|
+
justifyContent: 'center',
|
|
151
|
+
alignItems: 'center',
|
|
152
|
+
},
|
|
153
|
+
fullScreenContainer: {
|
|
154
|
+
flex: 1,
|
|
155
|
+
justifyContent: 'center',
|
|
156
|
+
alignItems: 'center',
|
|
157
|
+
backgroundColor: colors.surfaceColor100,
|
|
158
|
+
},
|
|
159
|
+
loadingText: {
|
|
160
|
+
marginTop: 16,
|
|
161
|
+
fontSize: 16,
|
|
162
|
+
fontWeight: '600',
|
|
163
|
+
color: colors.textColorDefaultPrimary,
|
|
164
|
+
},
|
|
165
|
+
warningText: {
|
|
166
|
+
fontSize: 14,
|
|
167
|
+
lineHeight: 20,
|
|
168
|
+
color: colors.textColorDefaultSecondary,
|
|
169
|
+
},
|
|
170
|
+
reasonSection: {
|
|
171
|
+
gap: 8,
|
|
172
|
+
},
|
|
173
|
+
fieldLabel: {
|
|
174
|
+
fontSize: 16,
|
|
175
|
+
fontWeight: platformFontWeightBold,
|
|
176
|
+
color: colors.textColorDefaultPrimary,
|
|
177
|
+
},
|
|
178
|
+
required: {
|
|
179
|
+
color: colors.statusErrorText,
|
|
180
|
+
},
|
|
181
|
+
reasonListContainer: {
|
|
182
|
+
backgroundColor: colors.surfaceColor100,
|
|
183
|
+
},
|
|
184
|
+
detailSection: {
|
|
185
|
+
gap: 8,
|
|
186
|
+
},
|
|
187
|
+
textInput: {
|
|
188
|
+
color: colors.textColorDefaultPrimary,
|
|
189
|
+
fontSize: 16,
|
|
190
|
+
textAlignVertical: 'top',
|
|
191
|
+
minHeight: 120,
|
|
192
|
+
maxHeight: 200,
|
|
193
|
+
borderWidth: 1,
|
|
194
|
+
borderColor: colors.borderColorDefaultBase,
|
|
195
|
+
borderRadius: 8,
|
|
196
|
+
paddingHorizontal: 16,
|
|
197
|
+
paddingVertical: 12,
|
|
198
|
+
backgroundColor: colors.surfaceColor100,
|
|
199
|
+
},
|
|
200
|
+
successIcon: {
|
|
201
|
+
color: colors.statusSuccessIcon,
|
|
202
|
+
fontSize: 48,
|
|
203
|
+
},
|
|
204
|
+
successTitle: {
|
|
205
|
+
fontSize: 24,
|
|
206
|
+
marginBottom: 4,
|
|
207
|
+
},
|
|
208
|
+
successSubtitle: {
|
|
209
|
+
fontSize: 16,
|
|
210
|
+
marginBottom: 4,
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
//# sourceMappingURL=message_report_screen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message_report_screen.js","sourceRoot":"","sources":["../../src/screens/message_report_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC9E,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAKtE,OAAO,EAAqB,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACzF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,UAAU,MAAM,+CAA+C,CAAA;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EACL,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,qDAAqD,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAG5E,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAA;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAA;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAEjD,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAE7B,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,EACzC,UAAU,GACkB,EAAgC,EAAE,CAAC,CAAC;IAChE,YAAY,EAAE,OAAO;IACrB,KAAK,EAAE,gBAAgB;IACvB,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,U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,WAAW,EAAE,CAAC;YACd,WAAW,EAAE,MAAM,CAAC,sBAAsB;YAC1C,YAAY,EAAE,CAAC;YACf,iBAAiB,EAAE,EAAE;YACrB,eAAe,EAAE,EAAE;YACnB,eAAe,EAAE,MAAM,CAAC,eAAe;SACxC;QACD,WAAW,EAAE;YACX,KAAK,EAAE,MAAM,CAAC,iBAAiB;YAC/B,QAAQ,EAAE,EAAE;SACb;QACD,YAAY,EAAE;YACZ,QAAQ,EAAE,EAAE;YACZ,YAAY,EAAE,CAAC;SAChB;QACD,eAAe,EAAE;YACf,QAAQ,EAAE,EAAE;YACZ,YAAY,EAAE,CAAC;SAChB;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React, { useCallback, useLayoutEffect, useMemo, useState } from 'react'\nimport { View, StyleSheet, TextInput, ScrollView } from 'react-native'\nimport type {\n NativeStackNavigationOptions,\n NativeStackScreenProps,\n} from '@react-navigation/native-stack'\nimport { StaticScreenProps, useNavigation, StackActions } from '@react-navigation/native'\nimport { Spinner, Text, KeyboardView } from '../components'\nimport BlankState from '../components/primitive/blank_state_primitive'\nimport { useTheme } from '../hooks'\nimport { useReportMessage } from '../hooks/use_report_message'\nimport {\n HeaderDismissButton,\n HeaderTextButton,\n} from '../components/display/platform_modal_header_buttons'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { MessageResource } from '../types'\nimport { MessageReportReason } from '../types/resources/message_report'\nimport { MessagePreview } from './message_report/components/message_preview'\nimport { ReportReasonList } from './message_report/components/report_reason_list'\nimport { platformFontWeightBold } from '../utils'\n\nconst MAX_DETAIL_LENGTH = 500\n\nexport const MessageReportScreenOptions = ({\n navigation,\n}: NativeStackScreenProps<any>): NativeStackNavigationOptions => ({\n presentation: 'modal',\n title: 'Report message',\n headerLeft: () => <HeaderDismissButton title=\"Cancel\" onPress={() => navigation.goBack()} />,\n})\n\nexport type MessageReportScreenProps = StaticScreenProps<{\n conversation_id: number\n message_id: string\n}>\n\nexport function MessageReportScreen({ route }: MessageReportScreenProps) {\n const { conversation_id, message_id } = route.params\n\n const { messages } = useConversationMessages({ conversation_id }, { refetchOnMount: false })\n const message = messages.find(m => m.id === message_id)\n\n if (!message) return null\n\n return <MessageReportScreenContent message={message} conversation_id={conversation_id} />\n}\n\nfunction MessageReportScreenContent({\n message,\n conversation_id,\n}: {\n message: MessageResource\n conversation_id: number\n}) {\n const styles = useStyles()\n const navigation = useNavigation()\n const [selectedReason, setSelectedReason] = useState<MessageReportReason | null>(null)\n const [reasonDetail, setReasonDetail] = useState('')\n const { mutate: submitReport, status } = useReportMessage(conversation_id, message.id)\n\n const handleReasonChange = useCallback((reason: MessageReportReason) => {\n setSelectedReason(reason)\n\n if (reason !== 'other') {\n setReasonDetail('')\n }\n }, [])\n\n const isFormValid = useMemo(() => {\n if (selectedReason === null) return false\n\n if (selectedReason === 'other' && reasonDetail.trim().length === 0) {\n return false\n }\n\n if (status === 'pending') return false\n\n return true\n }, [selectedReason, reasonDetail, status])\n\n const handleSubmit = useCallback(() => {\n if (!isFormValid || !selectedReason) return\n\n submitReport({\n reason: selectedReason,\n reasonDetail: selectedReason === 'other' ? reasonDetail : undefined,\n })\n }, [isFormValid, selectedReason, reasonDetail, submitReport])\n\n const handleClose = useCallback(() => {\n navigation.dispatch(StackActions.popTo('Conversation', { conversation_id }))\n }, [navigation, conversation_id])\n\n const HeaderRight = useCallback(\n () => <HeaderTextButton title=\"Submit\" onPress={handleSubmit} disabled={!isFormValid} />,\n [handleSubmit, isFormValid]\n )\n\n useLayoutEffect(() => {\n if (status === 'pending' || status === 'success') {\n navigation.setOptions({\n headerRight: () => null,\n })\n } else {\n navigation.setOptions({\n headerTitle: 'Report message',\n headerRight: HeaderRight,\n })\n }\n }, [HeaderRight, navigation, status])\n\n if (status === 'pending') {\n return (\n <View style={styles.fullScreenContainer}>\n <Spinner />\n <Text style={styles.loadingText}>Submitting report...</Text>\n </View>\n )\n }\n\n if (status === 'success') {\n return (\n <View style={styles.fullScreenContainer}>\n <BlankState.Root>\n <BlankState.Imagery name=\"general.checkCircle\" style={styles.successIcon} />\n <BlankState.Content>\n <BlankState.Heading style={styles.successTitle}>Message reported</BlankState.Heading>\n <BlankState.Text style={styles.successSubtitle}>\n The message has been reported and a church leader will be contacted.\n </BlankState.Text>\n </BlankState.Content>\n <BlankState.Button title=\"Close\" onPress={handleClose} size=\"lg\" variant=\"fill\" />\n </BlankState.Root>\n </View>\n )\n }\n\n if (status === 'error') {\n return (\n <BlankState.Root>\n <BlankState.Imagery name=\"general.exclamationTriangle\" />\n <BlankState.Content>\n <BlankState.Heading>Unable to submit report</BlankState.Heading>\n <BlankState.Text>\n We were unable to report this message. Please try again.\n </BlankState.Text>\n </BlankState.Content>\n <BlankState.Button title=\"Close\" onPress={handleClose} size=\"lg\" variant=\"outline\" />\n </BlankState.Root>\n )\n }\n\n return (\n <KeyboardView>\n <ScrollView contentContainerStyle={styles.container}>\n <Text style={styles.warningText}>\n Reporting this message will notify a church leader. The person you are reporting will not\n receive a notification from Church Center. If someone is in immediate danger, call local\n emergency services. Don't wait.\n </Text>\n\n <MessagePreview message={message} />\n\n <View style={styles.reasonSection}>\n <Text style={styles.fieldLabel}>\n What best describes the problem? <Text style={styles.required}>*</Text>\n </Text>\n\n <View style={styles.reasonListContainer}>\n <ReportReasonList selectedReason={selectedReason} onReasonChange={handleReasonChange} />\n </View>\n </View>\n\n {selectedReason === 'other' && (\n <View style={styles.detailSection}>\n <Text style={styles.fieldLabel}>\n Please provide more details <Text style={styles.required}>*</Text>\n </Text>\n <TextInput\n style={styles.textInput}\n multiline\n placeholder=\"Describe the issue...\"\n value={reasonDetail}\n onChangeText={setReasonDetail}\n maxLength={MAX_DETAIL_LENGTH}\n accessibilityLabel=\"Additional details\"\n accessibilityHint=\"Provide more information about why you're reporting this message\"\n />\n {reasonDetail.length >= MAX_DETAIL_LENGTH - 100 && (\n <Text variant=\"footnote\">\n {reasonDetail.length}/{MAX_DETAIL_LENGTH}\n </Text>\n )}\n </View>\n )}\n </ScrollView>\n </KeyboardView>\n )\n}\n\nconst useStyles = () => {\n const { bottom } = useSafeAreaInsets()\n const { colors } = useTheme()\n\n return StyleSheet.create({\n container: {\n padding: 16,\n paddingBottom: 16 + bottom,\n gap: 24,\n },\n fullHeight: {\n flex: 1,\n justifyContent: 'center',\n alignItems: 'center',\n },\n fullScreenContainer: {\n flex: 1,\n justifyContent: 'center',\n alignItems: 'center',\n backgroundColor: colors.surfaceColor100,\n },\n loadingText: {\n marginTop: 16,\n fontSize: 16,\n fontWeight: '600',\n color: colors.textColorDefaultPrimary,\n },\n warningText: {\n fontSize: 14,\n lineHeight: 20,\n color: colors.textColorDefaultSecondary,\n },\n reasonSection: {\n gap: 8,\n },\n fieldLabel: {\n fontSize: 16,\n fontWeight: platformFontWeightBold,\n color: colors.textColorDefaultPrimary,\n },\n required: {\n color: colors.statusErrorText,\n },\n reasonListContainer: {\n backgroundColor: colors.surfaceColor100,\n },\n detailSection: {\n gap: 8,\n },\n textInput: {\n color: colors.textColorDefaultPrimary,\n fontSize: 16,\n textAlignVertical: 'top',\n minHeight: 120,\n maxHeight: 200,\n borderWidth: 1,\n borderColor: colors.borderColorDefaultBase,\n borderRadius: 8,\n paddingHorizontal: 16,\n paddingVertical: 12,\n backgroundColor: colors.surfaceColor100,\n },\n successIcon: {\n color: colors.statusSuccessIcon,\n fontSize: 48,\n },\n successTitle: {\n fontSize: 24,\n marginBottom: 4,\n },\n successSubtitle: {\n fontSize: 16,\n marginBottom: 4,\n },\n })\n}\n"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ApiResource } from '../../../types';
|
|
2
|
+
import { GroupMembership, GroupResourceWithMembership } from '../../../types/resources';
|
|
3
|
+
export declare const getGroupsRequestArgs: () => {
|
|
4
|
+
url: string;
|
|
5
|
+
data: {
|
|
6
|
+
perPage: number;
|
|
7
|
+
include: string[];
|
|
8
|
+
filter: string;
|
|
9
|
+
fields: {
|
|
10
|
+
Group: never[];
|
|
11
|
+
GroupMembership: string[];
|
|
12
|
+
};
|
|
13
|
+
order: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare const getGroupRequestArgs: ({ groupId }: {
|
|
17
|
+
groupId: number | string;
|
|
18
|
+
}) => {
|
|
19
|
+
url: string;
|
|
20
|
+
data: {
|
|
21
|
+
include: string[];
|
|
22
|
+
fields: {
|
|
23
|
+
Group: string[];
|
|
24
|
+
GroupMembership: string[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare const useGroups: () => {
|
|
29
|
+
data: GroupResourceWithMembership[];
|
|
30
|
+
totalCount: number;
|
|
31
|
+
error: Response | null;
|
|
32
|
+
status: "success" | "error";
|
|
33
|
+
isError: boolean;
|
|
34
|
+
isPending: false;
|
|
35
|
+
isLoading: false;
|
|
36
|
+
isLoadingError: false;
|
|
37
|
+
isRefetchError: boolean;
|
|
38
|
+
isSuccess: boolean;
|
|
39
|
+
dataUpdatedAt: number;
|
|
40
|
+
errorUpdatedAt: number;
|
|
41
|
+
failureCount: number;
|
|
42
|
+
failureReason: Response | null;
|
|
43
|
+
errorUpdateCount: number;
|
|
44
|
+
isFetched: boolean;
|
|
45
|
+
isFetchedAfterMount: boolean;
|
|
46
|
+
isFetching: boolean;
|
|
47
|
+
isInitialLoading: boolean;
|
|
48
|
+
isPaused: boolean;
|
|
49
|
+
isRefetching: boolean;
|
|
50
|
+
isStale: boolean;
|
|
51
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("../../../types").ApiCollection<GroupResourceWithMembership>, unknown>, Response>>;
|
|
52
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
53
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("../../../types").ApiCollection<GroupResourceWithMembership>, unknown>, Response>>;
|
|
54
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("../../../types").ApiCollection<GroupResourceWithMembership>, unknown>, Response>>;
|
|
55
|
+
hasNextPage: boolean;
|
|
56
|
+
hasPreviousPage: boolean;
|
|
57
|
+
isFetchNextPageError: boolean;
|
|
58
|
+
isFetchingNextPage: boolean;
|
|
59
|
+
isFetchPreviousPageError: boolean;
|
|
60
|
+
isFetchingPreviousPage: boolean;
|
|
61
|
+
};
|
|
62
|
+
export declare const useGroup: ({ groupId }: {
|
|
63
|
+
groupId: number | string;
|
|
64
|
+
}) => {
|
|
65
|
+
error: import("../../../types").FailedResponse | null;
|
|
66
|
+
status: "success" | "error";
|
|
67
|
+
isError: boolean;
|
|
68
|
+
isPending: false;
|
|
69
|
+
isLoading: false;
|
|
70
|
+
isLoadingError: false;
|
|
71
|
+
isRefetchError: boolean;
|
|
72
|
+
isSuccess: boolean;
|
|
73
|
+
dataUpdatedAt: number;
|
|
74
|
+
errorUpdatedAt: number;
|
|
75
|
+
failureCount: number;
|
|
76
|
+
failureReason: import("../../../types").FailedResponse | null;
|
|
77
|
+
errorUpdateCount: number;
|
|
78
|
+
isFetched: boolean;
|
|
79
|
+
isFetchedAfterMount: boolean;
|
|
80
|
+
isFetching: boolean;
|
|
81
|
+
isInitialLoading: boolean;
|
|
82
|
+
isPaused: boolean;
|
|
83
|
+
isRefetching: boolean;
|
|
84
|
+
isStale: boolean;
|
|
85
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<ApiResource<GroupResourceWithMembership>, import("../../../types").FailedResponse>>;
|
|
86
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
87
|
+
data: GroupResourceWithMembership;
|
|
88
|
+
links: Record<string, string>;
|
|
89
|
+
meta: Record<string, unknown>;
|
|
90
|
+
};
|
|
91
|
+
export declare const useGroupMembershipUpdate: ({ groupId }: {
|
|
92
|
+
groupId: number | string;
|
|
93
|
+
}) => import("@tanstack/react-query").UseMutationResult<ApiResource<GroupMembership>, Error, string, void>;
|
|
94
|
+
//# sourceMappingURL=groups.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groups.d.ts","sourceRoot":"","sources":["../../../../src/screens/notification_settings/hooks/groups.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAA;AAGvF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;CAY/B,CAAA;AAEF,eAAO,MAAM,mBAAmB,gBAAiB;IAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE;;;;;;;;;CAS3E,CAAA;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIrB,CAAA;AAED,eAAO,MAAM,QAAQ,gBAAiB;IAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;CAIjE,CAAA;AAED,eAAO,MAAM,wBAAwB,gBAAiB;IAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,yGAwDjF,CAAA"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { getRequestQueryKey, useApiClient } from '../../../hooks';
|
|
3
|
+
import { useSuspenseGet, useSuspensePaginator } from '../../../hooks';
|
|
4
|
+
import { throwResponseError } from '../../../utils/response_error';
|
|
5
|
+
export const getGroupsRequestArgs = () => ({
|
|
6
|
+
url: '/me/groups',
|
|
7
|
+
data: {
|
|
8
|
+
perPage: 100,
|
|
9
|
+
include: ['my_group_membership'],
|
|
10
|
+
filter: 'user_settable_notification_level',
|
|
11
|
+
fields: {
|
|
12
|
+
Group: [],
|
|
13
|
+
GroupMembership: ['notification_level', 'notification_level_description'],
|
|
14
|
+
},
|
|
15
|
+
order: 'name',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
export const getGroupRequestArgs = ({ groupId }) => ({
|
|
19
|
+
url: `/me/groups/${groupId}`,
|
|
20
|
+
data: {
|
|
21
|
+
include: ['my_group_membership'],
|
|
22
|
+
fields: {
|
|
23
|
+
Group: ['name', 'source_app_name', 'source_type', 'my_group_membership'],
|
|
24
|
+
GroupMembership: ['notification_level', 'notification_level_description'],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
export const useGroups = () => {
|
|
29
|
+
const args = getGroupsRequestArgs();
|
|
30
|
+
return useSuspensePaginator(args);
|
|
31
|
+
};
|
|
32
|
+
export const useGroup = ({ groupId }) => {
|
|
33
|
+
const args = getGroupRequestArgs({ groupId });
|
|
34
|
+
return useSuspenseGet(args);
|
|
35
|
+
};
|
|
36
|
+
export const useGroupMembershipUpdate = ({ groupId }) => {
|
|
37
|
+
const apiClient = useApiClient();
|
|
38
|
+
const queryClient = useQueryClient();
|
|
39
|
+
const requestArgs = getGroupRequestArgs({ groupId });
|
|
40
|
+
const queryKey = getRequestQueryKey(requestArgs);
|
|
41
|
+
return useMutation({
|
|
42
|
+
throwOnError: true,
|
|
43
|
+
onMutate: notificationLevel => {
|
|
44
|
+
queryClient.setQueryData(queryKey, groupData => {
|
|
45
|
+
if (!groupData?.data.myGroupMembership)
|
|
46
|
+
return groupData;
|
|
47
|
+
return {
|
|
48
|
+
...groupData,
|
|
49
|
+
data: {
|
|
50
|
+
...groupData.data,
|
|
51
|
+
myGroupMembership: {
|
|
52
|
+
...groupData.data.myGroupMembership,
|
|
53
|
+
notificationLevel,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
onSuccess: response => {
|
|
60
|
+
queryClient.setQueryData(queryKey, groupData => {
|
|
61
|
+
if (!groupData?.data.myGroupMembership)
|
|
62
|
+
return groupData;
|
|
63
|
+
return {
|
|
64
|
+
...groupData,
|
|
65
|
+
data: {
|
|
66
|
+
...groupData.data,
|
|
67
|
+
myGroupMembership: {
|
|
68
|
+
...groupData.data.myGroupMembership,
|
|
69
|
+
...response.data,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
mutationFn: (notificationLevel) => {
|
|
76
|
+
return apiClient.chat
|
|
77
|
+
.patch({
|
|
78
|
+
url: `/me/groups/${groupId}/my_group_membership`,
|
|
79
|
+
data: {
|
|
80
|
+
data: {
|
|
81
|
+
type: 'GroupMembership',
|
|
82
|
+
attributes: {
|
|
83
|
+
notification_level: notificationLevel,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
})
|
|
88
|
+
.catch(throwResponseError);
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=groups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groups.js","sourceRoot":"","sources":["../../../../src/screens/notification_settings/hooks/groups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAGrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAElE,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE,CAAC,CAAC;IACzC,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE;QACJ,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,CAAC,qBA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-query'\nimport { getRequestQueryKey, useApiClient } from '../../../hooks'\nimport { useSuspenseGet, useSuspensePaginator } from '../../../hooks'\nimport { ApiResource } from '../../../types'\nimport { GroupMembership, GroupResourceWithMembership } from '../../../types/resources'\nimport { throwResponseError } from '../../../utils/response_error'\n\nexport const getGroupsRequestArgs = () => ({\n url: '/me/groups',\n data: {\n perPage: 100,\n include: ['my_group_membership'],\n filter: 'user_settable_notification_level',\n fields: {\n Group: [],\n GroupMembership: ['notification_level', 'notification_level_description'],\n },\n order: 'name',\n },\n})\n\nexport const getGroupRequestArgs = ({ groupId }: { groupId: number | string }) => ({\n url: `/me/groups/${groupId}`,\n data: {\n include: ['my_group_membership'],\n fields: {\n Group: ['name', 'source_app_name', 'source_type', 'my_group_membership'],\n GroupMembership: ['notification_level', 'notification_level_description'],\n },\n },\n})\n\nexport const useGroups = () => {\n const args = getGroupsRequestArgs()\n\n return useSuspensePaginator<GroupResourceWithMembership>(args)\n}\n\nexport const useGroup = ({ groupId }: { groupId: number | string }) => {\n const args = getGroupRequestArgs({ groupId })\n\n return useSuspenseGet<GroupResourceWithMembership>(args)\n}\n\nexport const useGroupMembershipUpdate = ({ groupId }: { groupId: number | string }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getGroupRequestArgs({ groupId })\n const queryKey = getRequestQueryKey(requestArgs)\n\n return useMutation({\n throwOnError: true,\n onMutate: notificationLevel => {\n queryClient.setQueryData<ApiResource<GroupResourceWithMembership>>(queryKey, groupData => {\n if (!groupData?.data.myGroupMembership) return groupData\n\n return {\n ...groupData,\n data: {\n ...groupData.data,\n myGroupMembership: {\n ...groupData.data.myGroupMembership,\n notificationLevel,\n },\n },\n }\n })\n },\n onSuccess: response => {\n queryClient.setQueryData<ApiResource<GroupResourceWithMembership>>(queryKey, groupData => {\n if (!groupData?.data.myGroupMembership) return groupData\n\n return {\n ...groupData,\n data: {\n ...groupData.data,\n myGroupMembership: {\n ...groupData.data.myGroupMembership,\n ...response.data,\n },\n },\n }\n })\n },\n mutationFn: (notificationLevel: string) => {\n return apiClient.chat\n .patch<ApiResource<GroupMembership>>({\n url: `/me/groups/${groupId}/my_group_membership`,\n data: {\n data: {\n type: 'GroupMembership',\n attributes: {\n notification_level: notificationLevel,\n },\n },\n },\n })\n .catch(throwResponseError)\n },\n })\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { StaticScreenProps } from '@react-navigation/native';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type NotificationSettingsScreenProps = StaticScreenProps<{}>;
|
|
4
|
+
export declare function NotificationSettingsScreen({}: NotificationSettingsScreenProps): React.JSX.Element;
|
|
5
|
+
//# sourceMappingURL=notification_settings_screen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification_settings_screen.d.ts","sourceRoot":"","sources":["../../src/screens/notification_settings_screen.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,0BAA0B,CAAA;AAE3E,OAAO,KAAiD,MAAM,OAAO,CAAA;AAiDrE,MAAM,MAAM,+BAA+B,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAA;AAEnE,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,+BAA+B,qBAiK7E"}
|