You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
actionIdentifier: "approve",// TODO must get the actionIdentifier from the button AND categoryIdentifier OF REQUEST
importReact,{useState,useContext}from"react";import{SafeAreaView,View,useColorScheme}from"react-native";import{Appbar,Menu,IconButton,Colors,Button,Modal,Dialog,Portal,Paragraph,}from"react-native-paper";import*asNotificationsfrom"expo-notifications";// import { Picker } from "@react-native-picker/picker";// import { PaperSelect } from "react-native-paper-select";importDropDownfrom"react-native-paper-dropdown";import{Separator}from"../components/Shared";import{useTheme}from"react-native-paper";import{AppReducer}from"../const";import{setPushResponse}from"../reducers/app";importapiServicefrom"../service/api";importstylesfrom"../styles";exportdefaultfunctionNotificationPopup(){consttheme=useTheme();constcolorScheme=useColorScheme();const{ state, dispatch }=useContext(AppReducer);const[visible,setVisible]=useState(false);const[loading,setLoading]=useState(false);const[pushContent,setPushContent]=useState(null);constthemedStyles=styles(colorScheme);constlastNotificationResponse=Notifications.useLastNotificationResponse();React.useEffect(()=>{if(!lastNotificationResponse)return;console.log("lastNotificationResponse",lastNotificationResponse);setPushContent(lastNotificationResponse.notification.request.content);// only load for the default typeif(lastNotificationResponse&&lastNotificationResponse.actionIdentifier===Notifications.DEFAULT_ACTION_IDENTIFIER){setVisible(true);}},[lastNotificationResponse]);// TODO build a list of categories and functions to generate action buttonsreturn(<Portal><Modalstyle={{backgroundColor: "#000000FF"}}visible={visible}onDismiss={()=>setVisible(false)}contentContainerStyle={{backgroundColor: theme.colors.backdrop,margin: 20,}}><Dialog.Title>Incoming Push</Dialog.Title><Dialog.Content>{lastNotificationResponse&&pushContent&&(<View><Paragraph>
actionIdentifier: {lastNotificationResponse.actionIdentifier}</Paragraph><Paragraph>title: {pushContent.title}</Paragraph><Paragraph>body: {pushContent.body}</Paragraph><Paragraph>categoryIdentifier: {pushContent.categoryIdentifier}</Paragraph><Paragraph>pushIdent: {pushContent.data.pushIdent}</Paragraph><Paragraph>pushId: {pushContent.data.pushId}</Paragraph><Separator/><Paragraph>{JSON.stringify(lastNotificationResponse)}</Paragraph></View>)}</Dialog.Content><Dialog.Actions><ButtononPress={()=>setVisible(false)}>Thanks</Button><ButtononPress={()=>{constresponseData={pushIdent: pushContent.data.pushIdent,pushId: pushContent.data.pushId,actionIdentifier: "reject",// TODO must get the actionIdentifier from the button AND categoryIdentifier OF REQUESTcategoryIdentifier: pushContent.categoryIdentifier,responseText: null,};dispatch(setPushResponse(responseData));setVisible(false);}}loading={loading}>
Reject
</Button><ButtononPress={()=>{constresponseData={pushIdent: pushContent.data.pushIdent,pushId: pushContent.data.pushId,actionIdentifier: "approve",// TODO must get the actionIdentifier from the button AND categoryIdentifier OF REQUESTcategoryIdentifier: pushContent.categoryIdentifier,responseText: null,};dispatch(setPushResponse(responseData));setVisible(false);}}loading={loading}>
Approve
</Button></Dialog.Actions></Modal></Portal>);}
The text was updated successfully, but these errors were encountered:
PushMeApp/components/NotificationPopup.js
Line 117 in 9b2ebc3
The text was updated successfully, but these errors were encountered: