@appcorp/fusion-storybook 0.3.45 → 0.3.47

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.
@@ -0,0 +1,9 @@
1
+ import { PushCampaignBE } from "../../type";
2
+ export declare const getCachedPushCampaignsSync: () => import("@react-pakistan/util-functions/general/generic-cache").ListResponse<PushCampaignBE>;
3
+ export declare const getCachedPushCampaigns: ({ params, }: {
4
+ params: Record<string, unknown>;
5
+ }) => Promise<import("@react-pakistan/util-functions/general/generic-cache").ListResponse<PushCampaignBE>>;
6
+ export declare const getCachedPushCampaignById: (campaignId: string) => PushCampaignBE | null;
7
+ export declare const invalidatePushCampaignsCache: () => void;
8
+ export declare const preloadPushCampaigns: () => Promise<import("@react-pakistan/util-functions/general/generic-cache").ListResponse<PushCampaignBE>>;
9
+ export declare const isPushCampaignsCacheStale: () => boolean;
@@ -0,0 +1,16 @@
1
+ import { LS_KEYS, PUSH_CAMPAIGN_API_ROUTES } from "../../constants";
2
+ import { getCachedData, getCachedDataSync, getCachedItemById, invalidateCache, isCacheStale, preloadCache, } from "@react-pakistan/util-functions/general/generic-cache";
3
+ const PUSH_CAMPAIGN_CACHE_CONFIG = {
4
+ cacheKey: LS_KEYS.CAMPAIGNS,
5
+ apiUrl: PUSH_CAMPAIGN_API_ROUTES.UNIT,
6
+ };
7
+ export const getCachedPushCampaignsSync = () => getCachedDataSync(LS_KEYS.CAMPAIGNS);
8
+ export const getCachedPushCampaigns = ({ params, }) => getCachedData({
9
+ config: PUSH_CAMPAIGN_CACHE_CONFIG,
10
+ params,
11
+ headers: { "Content-Type": "application/json" },
12
+ });
13
+ export const getCachedPushCampaignById = (campaignId) => getCachedItemById(LS_KEYS.CAMPAIGNS, campaignId);
14
+ export const invalidatePushCampaignsCache = () => invalidateCache(LS_KEYS.CAMPAIGNS);
15
+ export const preloadPushCampaigns = () => preloadCache(PUSH_CAMPAIGN_CACHE_CONFIG);
16
+ export const isPushCampaignsCacheStale = () => isCacheStale(LS_KEYS.CAMPAIGNS);
@@ -0,0 +1,24 @@
1
+ import { CAMPAIGN_STATUS } from "../../type";
2
+ export declare const pageLimit: number;
3
+ export declare const STATUS_OPTIONS: readonly [{
4
+ readonly label: "filterOptionAll";
5
+ readonly value: "";
6
+ }, {
7
+ readonly label: "filterOptionDraft";
8
+ readonly value: CAMPAIGN_STATUS.DRAFT;
9
+ }, {
10
+ readonly label: "filterOptionScheduled";
11
+ readonly value: CAMPAIGN_STATUS.SCHEDULED;
12
+ }, {
13
+ readonly label: "filterOptionRunning";
14
+ readonly value: CAMPAIGN_STATUS.RUNNING;
15
+ }, {
16
+ readonly label: "filterOptionCompleted";
17
+ readonly value: CAMPAIGN_STATUS.COMPLETED;
18
+ }, {
19
+ readonly label: "filterOptionFailed";
20
+ readonly value: CAMPAIGN_STATUS.FAILED;
21
+ }, {
22
+ readonly label: "filterOptionPaused";
23
+ readonly value: CAMPAIGN_STATUS.PAUSED;
24
+ }];
@@ -0,0 +1,11 @@
1
+ import { CAMPAIGN_STATUS } from "../../type";
2
+ export const pageLimit = Number(process.env.NEXT_PUBLIC_PAGE_LIMIT) || 10;
3
+ export const STATUS_OPTIONS = [
4
+ { label: "filterOptionAll", value: "" },
5
+ { label: "filterOptionDraft", value: CAMPAIGN_STATUS.DRAFT },
6
+ { label: "filterOptionScheduled", value: CAMPAIGN_STATUS.SCHEDULED },
7
+ { label: "filterOptionRunning", value: CAMPAIGN_STATUS.RUNNING },
8
+ { label: "filterOptionCompleted", value: CAMPAIGN_STATUS.COMPLETED },
9
+ { label: "filterOptionFailed", value: CAMPAIGN_STATUS.FAILED },
10
+ { label: "filterOptionPaused", value: CAMPAIGN_STATUS.PAUSED },
11
+ ];
@@ -0,0 +1,181 @@
1
+ import { PushCampaignBE } from "../../../type";
2
+ export declare const PUSH_CAMPAIGN_DRAWER: {
3
+ readonly FILTER_DRAWER: string;
4
+ readonly FORM_DRAWER: string;
5
+ readonly VIEW_DRAWER: string;
6
+ };
7
+ export declare const PUSH_CAMPAIGN_ACTION_TYPES: {
8
+ readonly RESET_FORM: "RESET_FORM";
9
+ readonly SET_CURRENT_PAGE: "SET_CURRENT_PAGE";
10
+ readonly SET_PAGE_LIMIT: "SET_PAGE_LIMIT";
11
+ readonly SET_SEARCH_QUERY: "SET_SEARCH_QUERY";
12
+ readonly SET_DRAWER: "SET_DRAWER";
13
+ readonly SET_ITEMS: "SET_ITEMS";
14
+ readonly SET_FORM_DATA: "SET_FORM_DATA";
15
+ readonly SET_DISABLE_SAVE_BUTTON: "SET_DISABLE_SAVE_BUTTON";
16
+ readonly SET_INPUT_FIELD: "SET_INPUT_FIELD";
17
+ readonly SET_ERRORS: "SET_ERRORS";
18
+ readonly SET_FILTERS: "SET_FILTERS";
19
+ }, pushCampaignModuleConfig: import("@react-pakistan/util-functions/factory/generic-module-factory").ModuleConfig<{
20
+ items: PushCampaignBE[];
21
+ count: number;
22
+ currentPage: number;
23
+ pageLimit: number;
24
+ searchQuery: string;
25
+ disableSaveButton: boolean;
26
+ drawer: string | null;
27
+ errors: Record<string, string>;
28
+ id: string;
29
+ name: string;
30
+ title: string;
31
+ body: string;
32
+ schoolId: string;
33
+ scheduledAt: string;
34
+ status: string;
35
+ enabled: boolean;
36
+ allStudents: boolean;
37
+ successCount: number;
38
+ failedCount: number;
39
+ totalCount: number;
40
+ workerJobId: string | null;
41
+ audience: Array<{
42
+ classId: string | null;
43
+ sectionId: string | null;
44
+ }>;
45
+ filterEnabled: boolean | undefined;
46
+ filterStatus: string | undefined;
47
+ aiCheckPassed: boolean;
48
+ aiCheckLoading: boolean;
49
+ aiCheckScore: number | null;
50
+ aiSuggestions: string;
51
+ }>, initialPushCampaignState: {
52
+ items: PushCampaignBE[];
53
+ count: number;
54
+ currentPage: number;
55
+ pageLimit: number;
56
+ searchQuery: string;
57
+ disableSaveButton: boolean;
58
+ drawer: string | null;
59
+ errors: Record<string, string>;
60
+ id: string;
61
+ name: string;
62
+ title: string;
63
+ body: string;
64
+ schoolId: string;
65
+ scheduledAt: string;
66
+ status: string;
67
+ enabled: boolean;
68
+ allStudents: boolean;
69
+ successCount: number;
70
+ failedCount: number;
71
+ totalCount: number;
72
+ workerJobId: string | null;
73
+ audience: Array<{
74
+ classId: string | null;
75
+ sectionId: string | null;
76
+ }>;
77
+ filterEnabled: boolean | undefined;
78
+ filterStatus: string | undefined;
79
+ aiCheckPassed: boolean;
80
+ aiCheckLoading: boolean;
81
+ aiCheckScore: number | null;
82
+ aiSuggestions: string;
83
+ }, PushCampaignProvider: import("react").FC<{
84
+ children: React.ReactNode;
85
+ }>, pushCampaignReducer: (state: {
86
+ items: PushCampaignBE[];
87
+ count: number;
88
+ currentPage: number;
89
+ pageLimit: number;
90
+ searchQuery: string;
91
+ disableSaveButton: boolean;
92
+ drawer: string | null;
93
+ errors: Record<string, string>;
94
+ id: string;
95
+ name: string;
96
+ title: string;
97
+ body: string;
98
+ schoolId: string;
99
+ scheduledAt: string;
100
+ status: string;
101
+ enabled: boolean;
102
+ allStudents: boolean;
103
+ successCount: number;
104
+ failedCount: number;
105
+ totalCount: number;
106
+ workerJobId: string | null;
107
+ audience: Array<{
108
+ classId: string | null;
109
+ sectionId: string | null;
110
+ }>;
111
+ filterEnabled: boolean | undefined;
112
+ filterStatus: string | undefined;
113
+ aiCheckPassed: boolean;
114
+ aiCheckLoading: boolean;
115
+ aiCheckScore: number | null;
116
+ aiSuggestions: string;
117
+ }, action: any) => {
118
+ items: PushCampaignBE[];
119
+ count: number;
120
+ currentPage: number;
121
+ pageLimit: number;
122
+ searchQuery: string;
123
+ disableSaveButton: boolean;
124
+ drawer: string | null;
125
+ errors: Record<string, string>;
126
+ id: string;
127
+ name: string;
128
+ title: string;
129
+ body: string;
130
+ schoolId: string;
131
+ scheduledAt: string;
132
+ status: string;
133
+ enabled: boolean;
134
+ allStudents: boolean;
135
+ successCount: number;
136
+ failedCount: number;
137
+ totalCount: number;
138
+ workerJobId: string | null;
139
+ audience: Array<{
140
+ classId: string | null;
141
+ sectionId: string | null;
142
+ }>;
143
+ filterEnabled: boolean | undefined;
144
+ filterStatus: string | undefined;
145
+ aiCheckPassed: boolean;
146
+ aiCheckLoading: boolean;
147
+ aiCheckScore: number | null;
148
+ aiSuggestions: string;
149
+ }, usePushCampaignContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
150
+ items: PushCampaignBE[];
151
+ count: number;
152
+ currentPage: number;
153
+ pageLimit: number;
154
+ searchQuery: string;
155
+ disableSaveButton: boolean;
156
+ drawer: string | null;
157
+ errors: Record<string, string>;
158
+ id: string;
159
+ name: string;
160
+ title: string;
161
+ body: string;
162
+ schoolId: string;
163
+ scheduledAt: string;
164
+ status: string;
165
+ enabled: boolean;
166
+ allStudents: boolean;
167
+ successCount: number;
168
+ failedCount: number;
169
+ totalCount: number;
170
+ workerJobId: string | null;
171
+ audience: Array<{
172
+ classId: string | null;
173
+ sectionId: string | null;
174
+ }>;
175
+ filterEnabled: boolean | undefined;
176
+ filterStatus: string | undefined;
177
+ aiCheckPassed: boolean;
178
+ aiCheckLoading: boolean;
179
+ aiCheckScore: number | null;
180
+ aiSuggestions: string;
181
+ }>;
@@ -0,0 +1,45 @@
1
+ import { createGenericModule } from "@react-pakistan/util-functions/factory/generic-module-factory";
2
+ import { DRAWER_TYPES } from "@react-pakistan/util-functions/factory/generic-component-factory";
3
+ import { CAMPAIGN_STATUS } from "../../../type";
4
+ import { pageLimit } from "../constants";
5
+ export const PUSH_CAMPAIGN_DRAWER = {
6
+ FILTER_DRAWER: DRAWER_TYPES.FILTER_DRAWER,
7
+ FORM_DRAWER: DRAWER_TYPES.FORM_DRAWER,
8
+ VIEW_DRAWER: DRAWER_TYPES.VIEW_DRAWER,
9
+ };
10
+ const pushCampaignConfig = {
11
+ name: "PushCampaign",
12
+ displayName: "Push Campaign",
13
+ drawerTypes: DRAWER_TYPES,
14
+ initialState: {
15
+ items: [],
16
+ count: 0,
17
+ currentPage: 1,
18
+ pageLimit,
19
+ searchQuery: "",
20
+ disableSaveButton: false,
21
+ drawer: null,
22
+ errors: {},
23
+ id: "",
24
+ name: "",
25
+ title: "",
26
+ body: "",
27
+ schoolId: "",
28
+ scheduledAt: "",
29
+ status: CAMPAIGN_STATUS.DRAFT,
30
+ enabled: true,
31
+ allStudents: false,
32
+ successCount: 0,
33
+ failedCount: 0,
34
+ totalCount: 0,
35
+ workerJobId: null,
36
+ audience: [],
37
+ filterEnabled: undefined,
38
+ filterStatus: undefined,
39
+ aiCheckPassed: false,
40
+ aiCheckLoading: false,
41
+ aiCheckScore: null,
42
+ aiSuggestions: "",
43
+ },
44
+ };
45
+ export const { actionTypes: PUSH_CAMPAIGN_ACTION_TYPES, config: pushCampaignModuleConfig, initialState: initialPushCampaignState, Provider: PushCampaignProvider, reducer: pushCampaignReducer, useContext: usePushCampaignContext, } = createGenericModule(pushCampaignConfig);
@@ -0,0 +1,66 @@
1
+ import { PushCampaignBE } from "../../../type";
2
+ import { type RowAction, type TableRow } from "@appcorp/shadcn/components/enhanced-table";
3
+ export declare const usePushCampaignModule: () => {
4
+ applyFilters: () => void;
5
+ byIdLoading: boolean;
6
+ clearFilters: () => void;
7
+ closeDrawer: () => void;
8
+ deleteLoading: boolean;
9
+ handleAiCheck: () => Promise<void>;
10
+ handleChange: (field: string, value: string | number | boolean | undefined | null) => void;
11
+ handleCreate: () => void;
12
+ handleDelete: (row?: TableRow) => void;
13
+ handleEdit: (row?: TableRow) => void;
14
+ handleFilters: () => void;
15
+ handleLaunch: (row?: TableRow) => Promise<void>;
16
+ handlePageChange: (page: number | unknown) => void;
17
+ handlePageLimitChange: (k: string, value: object) => void;
18
+ handleSearch: (query: string) => void;
19
+ handleSubmit: () => void;
20
+ handleView: (row?: TableRow) => void;
21
+ headerActions: {
22
+ enabled: boolean;
23
+ handleOnClick: () => void;
24
+ label: string;
25
+ order: number;
26
+ }[];
27
+ listFetchNow: (url?: string, config?: import("@react-pakistan/util-functions/hooks/use-fetch").FetchConfig) => void;
28
+ listLoading: boolean;
29
+ rowActions: RowAction[];
30
+ updateLoading: boolean;
31
+ handleCloseDrawer?: () => void;
32
+ state: {
33
+ items: PushCampaignBE[];
34
+ count: number;
35
+ currentPage: number;
36
+ pageLimit: number;
37
+ searchQuery: string;
38
+ disableSaveButton: boolean;
39
+ drawer: string | null;
40
+ errors: Record<string, string>;
41
+ id: string;
42
+ name: string;
43
+ title: string;
44
+ body: string;
45
+ schoolId: string;
46
+ scheduledAt: string;
47
+ status: string;
48
+ enabled: boolean;
49
+ allStudents: boolean;
50
+ successCount: number;
51
+ failedCount: number;
52
+ totalCount: number;
53
+ workerJobId: string | null;
54
+ audience: Array<{
55
+ classId: string | null;
56
+ sectionId: string | null;
57
+ }>;
58
+ filterEnabled: boolean | undefined;
59
+ filterStatus: string | undefined;
60
+ aiCheckPassed: boolean;
61
+ aiCheckLoading: boolean;
62
+ aiCheckScore: number | null;
63
+ aiSuggestions: string;
64
+ };
65
+ dispatch: React.Dispatch<any>;
66
+ };