@appcorp/fusion-storybook 0.1.68 → 0.1.72
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/base-modules/campus/cache.d.ts +14 -0
- package/base-modules/campus/cache.js +31 -0
- package/base-modules/campus/constants.d.ts +9 -0
- package/base-modules/campus/constants.js +17 -0
- package/base-modules/campus/context.d.ts +175 -0
- package/base-modules/campus/context.js +459 -0
- package/base-modules/campus/filter.d.ts +1 -0
- package/base-modules/campus/filter.js +28 -0
- package/base-modules/campus/form.d.ts +1 -0
- package/base-modules/campus/form.js +17 -0
- package/base-modules/campus/more-actions.d.ts +1 -0
- package/base-modules/campus/more-actions.js +40 -0
- package/base-modules/campus/page.d.ts +29 -0
- package/base-modules/campus/page.js +117 -0
- package/base-modules/campus/validate.d.ts +16 -0
- package/base-modules/campus/validate.js +47 -0
- package/base-modules/campus/view.d.ts +1 -0
- package/base-modules/campus/view.js +20 -0
- package/constants.d.ts +1 -0
- package/constants.js +1 -0
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/type.d.ts +30 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Campus Module Cache Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides localStorage-based caching for campuses using generic cache system.
|
|
5
|
+
*/
|
|
6
|
+
import { CampusBE } from "../../type";
|
|
7
|
+
export declare const getCachedCampusesSync: () => import("@react-pakistan/util-functions").ListResponse<CampusBE>;
|
|
8
|
+
export declare const getCachedCampuses: ({ params, }: {
|
|
9
|
+
params: Record<string, unknown>;
|
|
10
|
+
}) => Promise<import("@react-pakistan/util-functions").ListResponse<CampusBE>>;
|
|
11
|
+
export declare const getCachedCampusById: (campusId: string) => CampusBE | null;
|
|
12
|
+
export declare const invalidateCampusesCache: () => void;
|
|
13
|
+
export declare const isCampusesCacheStale: () => boolean;
|
|
14
|
+
export declare const preloadCampuses: () => Promise<import("@react-pakistan/util-functions").ListResponse<CampusBE>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Campus Module Cache Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides localStorage-based caching for campuses using generic cache system.
|
|
5
|
+
*/
|
|
6
|
+
import { LS_KEYS } from "../../constants";
|
|
7
|
+
import { CAMPUS_API_ROUTES } from "./constants";
|
|
8
|
+
import { getCachedData, getCachedDataSync, getCachedItemById, invalidateCache, isCacheStale, preloadCache, } from "@react-pakistan/util-functions";
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// CACHE CONFIGURATION
|
|
11
|
+
// ============================================================================
|
|
12
|
+
const CAMPUS_CACHE_CONFIG = {
|
|
13
|
+
apiUrl: CAMPUS_API_ROUTES.UNIT,
|
|
14
|
+
cacheKey: LS_KEYS.CAMPUSES,
|
|
15
|
+
};
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// CAMPUS-SPECIFIC CACHE FUNCTIONS
|
|
18
|
+
// ============================================================================
|
|
19
|
+
export const getCachedCampusesSync = () => getCachedDataSync(LS_KEYS.CAMPUSES);
|
|
20
|
+
export const getCachedCampuses = ({ params, }) => getCachedData({
|
|
21
|
+
config: CAMPUS_CACHE_CONFIG,
|
|
22
|
+
params,
|
|
23
|
+
headers: {
|
|
24
|
+
"Content-Type": "application/json",
|
|
25
|
+
"x-api-token": process.env.NEXT_PUBLIC_API_KEY,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
export const getCachedCampusById = (campusId) => getCachedItemById(LS_KEYS.CAMPUSES, campusId);
|
|
29
|
+
export const invalidateCampusesCache = () => invalidateCache(LS_KEYS.CAMPUSES);
|
|
30
|
+
export const isCampusesCacheStale = () => isCacheStale(LS_KEYS.CAMPUSES);
|
|
31
|
+
export const preloadCampuses = () => preloadCache(CAMPUS_CACHE_CONFIG);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Campus Constants
|
|
3
|
+
*
|
|
4
|
+
* Organization:
|
|
5
|
+
* - Page Configuration
|
|
6
|
+
* - API Routes
|
|
7
|
+
*/
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// PAGE CONFIGURATION
|
|
10
|
+
// ============================================================================
|
|
11
|
+
export const pageLimit = Number(process.env.NEXT_PUBLIC_PAGE_LIMIT) || 10;
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// API ROUTES
|
|
14
|
+
// ============================================================================
|
|
15
|
+
export const CAMPUS_API_ROUTES = {
|
|
16
|
+
UNIT: "/api/v1/campus",
|
|
17
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { CampusBE } from "../../type";
|
|
2
|
+
import { type RowAction, type TableRow } from "@appcorp/shadcn/components/enhanced-table";
|
|
3
|
+
export declare const CAMPUS_DRAWER: {
|
|
4
|
+
readonly FILTER_DRAWER: string;
|
|
5
|
+
readonly FORM_DRAWER: string;
|
|
6
|
+
readonly MORE_ACTIONS_DRAWER: string;
|
|
7
|
+
readonly VIEW_DRAWER: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const CAMPUS_ACTION_TYPES: {
|
|
10
|
+
readonly RESET_FORM: "RESET_FORM";
|
|
11
|
+
readonly SET_CURRENT_PAGE: "SET_CURRENT_PAGE";
|
|
12
|
+
readonly SET_PAGE_LIMIT: "SET_PAGE_LIMIT";
|
|
13
|
+
readonly SET_SEARCH_QUERY: "SET_SEARCH_QUERY";
|
|
14
|
+
readonly SET_DRAWER: "SET_DRAWER";
|
|
15
|
+
readonly SET_ITEMS: "SET_ITEMS";
|
|
16
|
+
readonly SET_FORM_DATA: "SET_FORM_DATA";
|
|
17
|
+
readonly SET_DISABLE_SAVE_BUTTON: "SET_DISABLE_SAVE_BUTTON";
|
|
18
|
+
readonly SET_INPUT_FIELD: "SET_INPUT_FIELD";
|
|
19
|
+
readonly SET_ERRORS: "SET_ERRORS";
|
|
20
|
+
readonly SET_FILTERS: "SET_FILTERS";
|
|
21
|
+
}, campusModuleConfig: import("@react-pakistan/util-functions/factory/generic-module-factory").ModuleConfig<{
|
|
22
|
+
items: CampusBE[];
|
|
23
|
+
count: number;
|
|
24
|
+
currentPage: number;
|
|
25
|
+
pageLimit: number;
|
|
26
|
+
searchQuery: string;
|
|
27
|
+
disableSaveButton: boolean;
|
|
28
|
+
drawer: string | null;
|
|
29
|
+
errors: Record<string, string>;
|
|
30
|
+
address: string | null;
|
|
31
|
+
city: string | null;
|
|
32
|
+
code: string;
|
|
33
|
+
country: string | null;
|
|
34
|
+
enabled: boolean;
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
phone: string | null;
|
|
38
|
+
schoolId: string;
|
|
39
|
+
state: string | null;
|
|
40
|
+
filterEnabled: boolean | undefined;
|
|
41
|
+
}>, initialCampusState: {
|
|
42
|
+
items: CampusBE[];
|
|
43
|
+
count: number;
|
|
44
|
+
currentPage: number;
|
|
45
|
+
pageLimit: number;
|
|
46
|
+
searchQuery: string;
|
|
47
|
+
disableSaveButton: boolean;
|
|
48
|
+
drawer: string | null;
|
|
49
|
+
errors: Record<string, string>;
|
|
50
|
+
address: string | null;
|
|
51
|
+
city: string | null;
|
|
52
|
+
code: string;
|
|
53
|
+
country: string | null;
|
|
54
|
+
enabled: boolean;
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
phone: string | null;
|
|
58
|
+
schoolId: string;
|
|
59
|
+
state: string | null;
|
|
60
|
+
filterEnabled: boolean | undefined;
|
|
61
|
+
}, CampusProvider: import("react").FC<{
|
|
62
|
+
children: React.ReactNode;
|
|
63
|
+
}>, campusReducer: (state: {
|
|
64
|
+
items: CampusBE[];
|
|
65
|
+
count: number;
|
|
66
|
+
currentPage: number;
|
|
67
|
+
pageLimit: number;
|
|
68
|
+
searchQuery: string;
|
|
69
|
+
disableSaveButton: boolean;
|
|
70
|
+
drawer: string | null;
|
|
71
|
+
errors: Record<string, string>;
|
|
72
|
+
address: string | null;
|
|
73
|
+
city: string | null;
|
|
74
|
+
code: string;
|
|
75
|
+
country: string | null;
|
|
76
|
+
enabled: boolean;
|
|
77
|
+
id: string;
|
|
78
|
+
name: string;
|
|
79
|
+
phone: string | null;
|
|
80
|
+
schoolId: string;
|
|
81
|
+
state: string | null;
|
|
82
|
+
filterEnabled: boolean | undefined;
|
|
83
|
+
}, action: any) => {
|
|
84
|
+
items: CampusBE[];
|
|
85
|
+
count: number;
|
|
86
|
+
currentPage: number;
|
|
87
|
+
pageLimit: number;
|
|
88
|
+
searchQuery: string;
|
|
89
|
+
disableSaveButton: boolean;
|
|
90
|
+
drawer: string | null;
|
|
91
|
+
errors: Record<string, string>;
|
|
92
|
+
address: string | null;
|
|
93
|
+
city: string | null;
|
|
94
|
+
code: string;
|
|
95
|
+
country: string | null;
|
|
96
|
+
enabled: boolean;
|
|
97
|
+
id: string;
|
|
98
|
+
name: string;
|
|
99
|
+
phone: string | null;
|
|
100
|
+
schoolId: string;
|
|
101
|
+
state: string | null;
|
|
102
|
+
filterEnabled: boolean | undefined;
|
|
103
|
+
}, useCampusContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContext<{
|
|
104
|
+
items: CampusBE[];
|
|
105
|
+
count: number;
|
|
106
|
+
currentPage: number;
|
|
107
|
+
pageLimit: number;
|
|
108
|
+
searchQuery: string;
|
|
109
|
+
disableSaveButton: boolean;
|
|
110
|
+
drawer: string | null;
|
|
111
|
+
errors: Record<string, string>;
|
|
112
|
+
address: string | null;
|
|
113
|
+
city: string | null;
|
|
114
|
+
code: string;
|
|
115
|
+
country: string | null;
|
|
116
|
+
enabled: boolean;
|
|
117
|
+
id: string;
|
|
118
|
+
name: string;
|
|
119
|
+
phone: string | null;
|
|
120
|
+
schoolId: string;
|
|
121
|
+
state: string | null;
|
|
122
|
+
filterEnabled: boolean | undefined;
|
|
123
|
+
}>;
|
|
124
|
+
export declare const useCampusModule: () => {
|
|
125
|
+
applyFilters: () => void;
|
|
126
|
+
byIdLoading: boolean;
|
|
127
|
+
clearFilters: () => void;
|
|
128
|
+
clearSearch: () => void;
|
|
129
|
+
closeDrawer: () => void;
|
|
130
|
+
deleteLoading: boolean;
|
|
131
|
+
handleChange: (field: string, value: string | number | boolean | undefined | null) => void;
|
|
132
|
+
handleCreate: () => void;
|
|
133
|
+
handleDelete: (row?: TableRow) => void;
|
|
134
|
+
handleEdit: (row?: TableRow) => void;
|
|
135
|
+
handleFilters: () => void;
|
|
136
|
+
handleMoreActions: () => void;
|
|
137
|
+
handlePageChange: (page: number) => void;
|
|
138
|
+
handlePageLimitChange: (k: string, value: object) => void;
|
|
139
|
+
handleSearch: (query: string) => void;
|
|
140
|
+
handleSubmit: () => void;
|
|
141
|
+
handleView: (row?: TableRow) => void;
|
|
142
|
+
headerActions: {
|
|
143
|
+
enabled: boolean;
|
|
144
|
+
handleOnClick: () => void;
|
|
145
|
+
label: string;
|
|
146
|
+
order: number;
|
|
147
|
+
}[];
|
|
148
|
+
listFetchNow: (url?: string, config?: import("@react-pakistan/util-functions/hooks/use-fetch").FetchConfig) => void;
|
|
149
|
+
listLoading: boolean;
|
|
150
|
+
rowActions: RowAction[];
|
|
151
|
+
toggleStatus: (row?: TableRow) => void;
|
|
152
|
+
updateLoading: boolean;
|
|
153
|
+
state: {
|
|
154
|
+
items: CampusBE[];
|
|
155
|
+
count: number;
|
|
156
|
+
currentPage: number;
|
|
157
|
+
pageLimit: number;
|
|
158
|
+
searchQuery: string;
|
|
159
|
+
disableSaveButton: boolean;
|
|
160
|
+
drawer: string | null;
|
|
161
|
+
errors: Record<string, string>;
|
|
162
|
+
address: string | null;
|
|
163
|
+
city: string | null;
|
|
164
|
+
code: string;
|
|
165
|
+
country: string | null;
|
|
166
|
+
enabled: boolean;
|
|
167
|
+
id: string;
|
|
168
|
+
name: string;
|
|
169
|
+
phone: string | null;
|
|
170
|
+
schoolId: string;
|
|
171
|
+
state: string | null;
|
|
172
|
+
filterEnabled: boolean | undefined;
|
|
173
|
+
};
|
|
174
|
+
dispatch: React.Dispatch<any>;
|
|
175
|
+
};
|