@applicaster/zapp-react-native-utils
Version:
Applicaster Zapp React Native utilities package
77 lines (70 loc) • 2.07 kB
JavaScript
const NavigationCallbackOptions = {
DEFAULT: "default",
GO_HOME: "go_home",
GO_BACK: "go_back",
GO_TO_SCREEN: "go_to_screen",
};
const ResultType = {
login: "login",
logout: "logout",
};
const CALLBACK_NAVIGATION_KEY = "completion_action";
const CALLBACK_NAVIGATION_GO_TO_SCREEN_KEY =
"completion_action_navigation_go_to_screen";
const callbackKeyPrefix = (key, prefix, keySeparator = "_") =>
prefix ? `${prefix}${keySeparator}${key}` : key;
const extendManifestWithHookCallback = (prefix = null) => ({
group: true,
label: "CallBack Navigation",
folded: true,
fields: [
{
type: "select",
key: callbackKeyPrefix(CALLBACK_NAVIGATION_KEY, prefix),
label: callbackKeyPrefix(
"Callback Navigation",
prefix?.toUpperCase(),
" "
),
label_tooltip:
"Defines what navigation action should be performed after the callback is called.",
options: [
{
text: "Use default flow",
value: NavigationCallbackOptions.DEFAULT,
},
{
text: "Go Back to home screen",
value: NavigationCallbackOptions.GO_HOME,
},
{
text: "Go Back to previous screen",
value: NavigationCallbackOptions.GO_BACK,
},
{
text: "Move to specific screen",
value: NavigationCallbackOptions.GO_TO_SCREEN,
},
],
initial_value: "default",
},
{
type: "screen_selector",
key: callbackKeyPrefix(CALLBACK_NAVIGATION_GO_TO_SCREEN_KEY, prefix),
label: callbackKeyPrefix(
"Navigate to screen",
prefix?.toUpperCase(),
" "
),
label_tooltip: "Screen you wish to navigate to after success purchase",
rules: "conditional",
conditional_fields: [
{
key: `general/${callbackKeyPrefix(CALLBACK_NAVIGATION_KEY, prefix)}`,
condition_value: NavigationCallbackOptions.GO_TO_SCREEN,
},
],
},
],
});
module.exports = { extendManifestWithHookCallback, ResultType };