Files
super-app/App/common/actions/GenericAction.ts
2025-01-13 14:19:39 +00:00

44 lines
1.4 KiB
TypeScript

import { Dispatch, SetStateAction } from "react";
import { AnalyticsEvent, CtaData } from "../interface";
import { ScreenData } from "../interface/widgets/screenData/ScreenData";
import { ScreenState } from "../screen/BaseScreen";
export interface GenericActionPayload {
baseActionType?: string;
type?: string; // type is used for analytics seggregations and also screen level API call or handling seggregation
metaData?: ActionMetaData[];
ctaData?: CtaData;
setScreenData?: Dispatch<SetStateAction<ScreenData | null>>;
setScreenState?: Dispatch<SetStateAction<ScreenState | null>>;
setErrorMetaData?: Dispatch<SetStateAction<ActionMetaData[] | null>>;
screenData?: ScreenData | null;
}
export interface ErrorMetaData extends GenericActionPayload {
errorStatusCode?: number;
errorAxiosCode?: string;
}
export interface ActionMetaData {
actionType?: string;
// ActionMetaData has some key attributes required to perform any action e.g. critical widget communications i.e. inter/intra widget, screen level API calls, bottom sheet, modal, etc.
data?: any;
analyticsEventProperties?: AnalyticsEvent;
screenName?: string;
}
export interface TargetWidgetPayload {
targetWidgetId?: string;
keyPath?: string;
newValue?: any;
valueType: string;
widgetId?: string;
actionId?: string;
}
export const BaseActionTypes = {
SCREEN_ACTION: "SCREEN_ACTION",
WIDGET_ACTION: "WIDGET_ACTION",
ANALYTICS_EVENT_ACTION: "CLICKSTREAM_ACTION",
};