@helpdice/sdk 0.0.1
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/README.md +1 -0
- package/dist/account/endpoint.d.ts +6 -0
- package/dist/account/endpoint.js +7 -0
- package/dist/account/endpoint.js.map +1 -0
- package/dist/account/index.d.ts +4 -0
- package/dist/account/index.js +7 -0
- package/dist/account/index.js.map +1 -0
- package/dist/accounting/endpoint.d.ts +7 -0
- package/dist/accounting/endpoint.js +9 -0
- package/dist/accounting/endpoint.js.map +1 -0
- package/dist/accounting/index.d.ts +5 -0
- package/dist/accounting/index.js +12 -0
- package/dist/accounting/index.js.map +1 -0
- package/dist/auth/endpoint.d.ts +8 -0
- package/dist/auth/endpoint.js +9 -0
- package/dist/auth/endpoint.js.map +1 -0
- package/dist/auth/index.d.ts +41 -0
- package/dist/auth/index.js +41 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/logout.d.ts +12 -0
- package/dist/auth/logout.js +18 -0
- package/dist/auth/logout.js.map +1 -0
- package/dist/auth/signInWithGoogle.d.ts +8 -0
- package/dist/auth/signInWithGoogle.js +47 -0
- package/dist/auth/signInWithGoogle.js.map +1 -0
- package/dist/auth/signin.d.ts +11 -0
- package/dist/auth/signin.js +13 -0
- package/dist/auth/signin.js.map +1 -0
- package/dist/auth/signup.d.ts +11 -0
- package/dist/auth/signup.js +13 -0
- package/dist/auth/signup.js.map +1 -0
- package/dist/auth/types.d.ts +15 -0
- package/dist/auth/types.js +2 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/config/Env.d.ts +38 -0
- package/dist/config/Env.js +50 -0
- package/dist/config/Env.js.map +1 -0
- package/dist/config/axios.d.ts +11 -0
- package/dist/config/axios.js +85 -0
- package/dist/config/axios.js.map +1 -0
- package/dist/config/constants.d.ts +12 -0
- package/dist/config/constants.js +19 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/config/fetch.d.ts +7 -0
- package/dist/config/fetch.js +36 -0
- package/dist/config/fetch.js.map +1 -0
- package/dist/config/firebase.d.ts +3 -0
- package/dist/config/firebase.js +15 -0
- package/dist/config/firebase.js.map +1 -0
- package/dist/config/handler.d.ts +13 -0
- package/dist/config/handler.js +31 -0
- package/dist/config/handler.js.map +1 -0
- package/dist/config/local-storage.d.ts +1 -0
- package/dist/config/local-storage.js +30 -0
- package/dist/config/local-storage.js.map +1 -0
- package/dist/config/route.d.ts +1 -0
- package/dist/config/route.js +25 -0
- package/dist/config/route.js.map +1 -0
- package/dist/content/endpoint.d.ts +14 -0
- package/dist/content/endpoint.js +15 -0
- package/dist/content/endpoint.js.map +1 -0
- package/dist/content/index.d.ts +12 -0
- package/dist/content/index.js +27 -0
- package/dist/content/index.js.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useAuth.d.ts +1 -0
- package/dist/hooks/useAuth.js +24 -0
- package/dist/hooks/useAuth.js.map +1 -0
- package/dist/hooks/usePrivate.d.ts +1 -0
- package/dist/hooks/usePrivate.js +16 -0
- package/dist/hooks/usePrivate.js.map +1 -0
- package/dist/hooks/useUser.d.ts +8 -0
- package/dist/hooks/useUser.js +11 -0
- package/dist/hooks/useUser.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/order/create.d.ts +9 -0
- package/dist/order/create.js +13 -0
- package/dist/order/create.js.map +1 -0
- package/dist/order/endpoint.d.ts +6 -0
- package/dist/order/endpoint.js +7 -0
- package/dist/order/endpoint.js.map +1 -0
- package/dist/order/index.d.ts +10 -0
- package/dist/order/index.js +6 -0
- package/dist/order/index.js.map +1 -0
- package/dist/order/types.d.ts +10 -0
- package/dist/order/types.js +2 -0
- package/dist/order/types.js.map +1 -0
- package/dist/payment/endpoint.d.ts +7 -0
- package/dist/payment/endpoint.js +8 -0
- package/dist/payment/endpoint.js.map +1 -0
- package/dist/payment/index.d.ts +17 -0
- package/dist/payment/index.js +8 -0
- package/dist/payment/index.js.map +1 -0
- package/dist/payment/start.d.ts +21 -0
- package/dist/payment/start.js +59 -0
- package/dist/payment/start.js.map +1 -0
- package/dist/payment/types.d.ts +17 -0
- package/dist/payment/types.js +2 -0
- package/dist/payment/types.js.map +1 -0
- package/dist/payment/verify.d.ts +10 -0
- package/dist/payment/verify.js +13 -0
- package/dist/payment/verify.js.map +1 -0
- package/dist/support/endpoint.d.ts +8 -0
- package/dist/support/endpoint.js +9 -0
- package/dist/support/endpoint.js.map +1 -0
- package/dist/support/index.d.ts +22 -0
- package/dist/support/index.js +11 -0
- package/dist/support/index.js.map +1 -0
- package/dist/support/newsletter.d.ts +10 -0
- package/dist/support/newsletter.js +13 -0
- package/dist/support/newsletter.js.map +1 -0
- package/dist/support/ticket.d.ts +10 -0
- package/dist/support/ticket.js +13 -0
- package/dist/support/ticket.js.map +1 -0
- package/dist/utils/auth.d.ts +4 -0
- package/dist/utils/auth.js +11 -0
- package/dist/utils/auth.js.map +1 -0
- package/dist/utils/localStorage.d.ts +34 -0
- package/dist/utils/localStorage.js +127 -0
- package/dist/utils/localStorage.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { get } from "./axios.js";
|
|
2
|
+
async function fetch(url, config) {
|
|
3
|
+
// Define states
|
|
4
|
+
let state = {
|
|
5
|
+
loading: true,
|
|
6
|
+
data: null,
|
|
7
|
+
error: null,
|
|
8
|
+
settled: false,
|
|
9
|
+
};
|
|
10
|
+
// Update state to reflect loading
|
|
11
|
+
// console.log('Loading:', state.loading);
|
|
12
|
+
await get(url, config)
|
|
13
|
+
.then((response) => {
|
|
14
|
+
// Update state on success
|
|
15
|
+
state = {
|
|
16
|
+
loading: false,
|
|
17
|
+
data: response.data,
|
|
18
|
+
error: null,
|
|
19
|
+
settled: true,
|
|
20
|
+
};
|
|
21
|
+
// console.log('Success:', state);
|
|
22
|
+
})
|
|
23
|
+
.catch((error) => {
|
|
24
|
+
// Update state on error
|
|
25
|
+
state = {
|
|
26
|
+
loading: false,
|
|
27
|
+
data: null,
|
|
28
|
+
error: error.message,
|
|
29
|
+
settled: true,
|
|
30
|
+
};
|
|
31
|
+
// console.log('Error:', state);
|
|
32
|
+
});
|
|
33
|
+
return state;
|
|
34
|
+
}
|
|
35
|
+
export default fetch;
|
|
36
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/config/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,KAAK,UAAU,KAAK,CAAC,GAAW,EAAE,MAAc;IAC/C,gBAAgB;IAChB,IAAI,KAAK,GAAG;QACX,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,KAAK;KACd,CAAC;IAEF,kCAAkC;IAClC,0CAA0C;IAE1C,MAAM,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC;SACpB,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;QAClB,0BAA0B;QAC1B,KAAK,GAAG;YACP,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,IAAI;SACb,CAAC;QACF,kCAAkC;IACnC,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAChB,wBAAwB;QACxB,KAAK,GAAG;YACP,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK,CAAC,OAAO;YACpB,OAAO,EAAE,IAAI;SACb,CAAC;QACF,gCAAgC;IACjC,CAAC,CAAC,CAAC;IAEJ,OAAO,KAAK,CAAC;AACd,CAAC;AAED,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as firebase } from "firebase/compat/app";
|
|
2
|
+
import { Env } from "./Env.js";
|
|
3
|
+
// Initialize Firebase (Make sure you replace the config with your Firebase project config)
|
|
4
|
+
const firebaseConfig = {
|
|
5
|
+
apiKey: Env.firebase.FIREBASE_API_KEY,
|
|
6
|
+
authDomain: Env.firebase.FIREBASE_AUTH_DOMAIN,
|
|
7
|
+
projectId: Env.firebase.FIREBASE_PROJECT_ID,
|
|
8
|
+
storageBucket: Env.firebase.FIREBASE_STORAGE_BUCKET,
|
|
9
|
+
messagingSenderId: Env.firebase.FIREBASE_MESSAGING_SENDER_ID,
|
|
10
|
+
appId: Env.firebase.FIREBASE_APP_ID,
|
|
11
|
+
measurementId: Env.firebase.FIREBASE_MEASUREMENT_ID,
|
|
12
|
+
};
|
|
13
|
+
const app = firebase.default.initializeApp(firebaseConfig);
|
|
14
|
+
export default app;
|
|
15
|
+
//# sourceMappingURL=firebase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase.js","sourceRoot":"","sources":["../../src/config/firebase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,2FAA2F;AAC3F,MAAM,cAAc,GAAG;IACtB,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,gBAAgB;IACrC,UAAU,EAAE,GAAG,CAAC,QAAQ,CAAC,oBAAoB;IAC7C,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,mBAAmB;IAC3C,aAAa,EAAE,GAAG,CAAC,QAAQ,CAAC,uBAAuB;IACnD,iBAAiB,EAAE,GAAG,CAAC,QAAQ,CAAC,4BAA4B;IAC5D,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,eAAe;IACnC,aAAa,EAAE,GAAG,CAAC,QAAQ,CAAC,uBAAuB;CACnD,CAAC;AAEF,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;AAE3D,eAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AxiosResponse } from "axios";
|
|
2
|
+
export interface Callbacks {
|
|
3
|
+
onFetching?: () => void;
|
|
4
|
+
onSuccess?: (response: {
|
|
5
|
+
data: object;
|
|
6
|
+
status: number;
|
|
7
|
+
statusText: string;
|
|
8
|
+
}) => void;
|
|
9
|
+
onError?: (error: string) => void;
|
|
10
|
+
onSettled?: () => void;
|
|
11
|
+
}
|
|
12
|
+
declare function handler(promise: Promise<AxiosResponse>, callbacks?: Callbacks): Promise<void>;
|
|
13
|
+
export default handler;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// The fetchDataWithCallbacks function that accepts a Promise and a callbacks object
|
|
2
|
+
async function handler(promise, callbacks) {
|
|
3
|
+
// Destructure callbacks from the object
|
|
4
|
+
const { onFetching, onSuccess, onError, onSettled } = callbacks ?? {};
|
|
5
|
+
// Call the onFetching callback before making the request
|
|
6
|
+
if (onFetching)
|
|
7
|
+
onFetching();
|
|
8
|
+
// Handle the Promise passed as an argument
|
|
9
|
+
promise
|
|
10
|
+
.then((response) => {
|
|
11
|
+
// Call the onSuccess callback if the Promise resolves successfully
|
|
12
|
+
if (onSuccess)
|
|
13
|
+
onSuccess({
|
|
14
|
+
data: response.data,
|
|
15
|
+
status: response.status,
|
|
16
|
+
statusText: response.statusText,
|
|
17
|
+
});
|
|
18
|
+
})
|
|
19
|
+
.catch((error) => {
|
|
20
|
+
// Call the onError callback if the Promise is rejected
|
|
21
|
+
if (onError)
|
|
22
|
+
onError(error);
|
|
23
|
+
})
|
|
24
|
+
.finally(() => {
|
|
25
|
+
// Call the onSettled callback after the Promise is settled
|
|
26
|
+
if (onSettled)
|
|
27
|
+
onSettled();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export default handler;
|
|
31
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/config/handler.ts"],"names":[],"mappings":"AAcA,oFAAoF;AACpF,KAAK,UAAU,OAAO,CAAC,OAA+B,EAAE,SAAqB;IAC5E,wCAAwC;IACxC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,SAAS,IAAI,EAAE,CAAC;IAEtE,yDAAyD;IACzD,IAAI,UAAU;QAAE,UAAU,EAAE,CAAC;IAE7B,2CAA2C;IAC3C,OAAO;SACL,IAAI,CACJ,CAAC,QAIA,EAAE,EAAE;QACJ,mEAAmE;QACnE,IAAI,SAAS;YACZ,SAAS,CAAC;gBACT,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;aAC/B,CAAC,CAAC;IACL,CAAC,CACD;SACA,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAChB,uDAAuD;QACvD,IAAI,OAAO;YAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC,CAAC;SACD,OAAO,CAAC,GAAG,EAAE;QACb,2DAA2D;QAC3D,IAAI,SAAS;YAAE,SAAS,EAAE,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// import { add, getUnixTime } from 'date-fns';
|
|
2
|
+
export {};
|
|
3
|
+
// import { AuthAction } from '@store/interfaces';
|
|
4
|
+
// import { REFRESH_TOKEN_KEY, TOKEN_KEY, TOKEN_THRESHOLD_KEY } from './constants';
|
|
5
|
+
// export const setThreshold = (time: number): string =>
|
|
6
|
+
// getUnixTime(
|
|
7
|
+
// add(new Date(), {
|
|
8
|
+
// seconds: time || 3600,
|
|
9
|
+
// }),
|
|
10
|
+
// ).toString();
|
|
11
|
+
// export const handleItem = (key: string, value?: string): void => {
|
|
12
|
+
// if (value) {
|
|
13
|
+
// localStorage.setItem(key, value);
|
|
14
|
+
// } else {
|
|
15
|
+
// localStorage.removeItem(key);
|
|
16
|
+
// }
|
|
17
|
+
// };
|
|
18
|
+
// /* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
19
|
+
// export const setItems = (data: any): void => {
|
|
20
|
+
// handleItem(TOKEN_KEY, data!.token);
|
|
21
|
+
// handleItem(TOKEN_THRESHOLD_KEY, setThreshold(data!.threshold!));
|
|
22
|
+
// handleItem(REFRESH_TOKEN_KEY, data!.refreshToken);
|
|
23
|
+
// };
|
|
24
|
+
// /* eslint-enable @typescript-eslint/no-non-null-assertion */
|
|
25
|
+
// export const removeItems = (): void => {
|
|
26
|
+
// handleItem(TOKEN_KEY);
|
|
27
|
+
// handleItem(TOKEN_THRESHOLD_KEY);
|
|
28
|
+
// handleItem(REFRESH_TOKEN_KEY);
|
|
29
|
+
// };
|
|
30
|
+
//# sourceMappingURL=local-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-storage.js","sourceRoot":"","sources":["../../src/config/local-storage.ts"],"names":[],"mappings":"AAAA,+CAA+C;;AAE/C,kDAAkD;AAClD,mFAAmF;AAEnF,wDAAwD;AACxD,iBAAiB;AACjB,wBAAwB;AACxB,+BAA+B;AAC/B,UAAU;AACV,kBAAkB;AAElB,qEAAqE;AACrE,iBAAiB;AACjB,wCAAwC;AACxC,aAAa;AACb,oCAAoC;AACpC,MAAM;AACN,KAAK;AAEL,gEAAgE;AAChE,iDAAiD;AACjD,wCAAwC;AACxC,qEAAqE;AACrE,uDAAuD;AACvD,KAAK;AACL,+DAA+D;AAE/D,2CAA2C;AAC3C,2BAA2B;AAC3B,qCAAqC;AACrC,mCAAmC;AACnC,KAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getUrl(category: string, version: string, action: string): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import account from "../account/endpoint.js";
|
|
2
|
+
import accounting from "../accounting/endpoint.js";
|
|
3
|
+
import auth from "../auth/endpoint.js";
|
|
4
|
+
import cms from "../content/endpoint.js";
|
|
5
|
+
import support from "../support/endpoint.js";
|
|
6
|
+
const urls = {
|
|
7
|
+
auth,
|
|
8
|
+
cms,
|
|
9
|
+
account,
|
|
10
|
+
accounting,
|
|
11
|
+
support,
|
|
12
|
+
};
|
|
13
|
+
// Function to get the URL dynamically based on category, version, and action
|
|
14
|
+
export function getUrl(category, version, action) {
|
|
15
|
+
const categoryData = urls[category]; // Access the correct category dynamically
|
|
16
|
+
if (categoryData) {
|
|
17
|
+
const versionData = categoryData[version]; // Access the correct version dynamically
|
|
18
|
+
if (versionData?.[action]) {
|
|
19
|
+
return `/api/${version}/${category}/${versionData[action]}`; // Construct the URL
|
|
20
|
+
}
|
|
21
|
+
throw new Error(`Invalid action: ${action} for version: ${version} in category: ${category}`);
|
|
22
|
+
}
|
|
23
|
+
throw new Error(`Invalid category: ${category}`);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../src/config/route.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,UAAU,MAAM,2BAA2B,CAAC;AACnD,OAAO,IAAI,MAAM,qBAAqB,CAAC;AACvC,OAAO,GAAG,MAAM,wBAAwB,CAAC;AACzC,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAY7C,MAAM,IAAI,GAAS;IAClB,IAAI;IACJ,GAAG;IACH,OAAO;IACP,UAAU;IACV,OAAO;CACP,CAAC;AAEF,6EAA6E;AAC7E,MAAM,UAAU,MAAM,CACrB,QAAgB,EAChB,OAAe,EACf,MAAc;IAEd,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,0CAA0C;IAC/E,IAAI,YAAY,EAAE,CAAC;QAClB,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,yCAAyC;QACpF,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3B,OAAO,QAAQ,OAAO,IAAI,QAAQ,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,oBAAoB;QAClF,CAAC;QACD,MAAM,IAAI,KAAK,CACd,mBAAmB,MAAM,iBAAiB,OAAO,iBAAiB,QAAQ,EAAE,CAC5E,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,EAAE,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const cms = {
|
|
2
|
+
v1: {
|
|
3
|
+
article: "article",
|
|
4
|
+
articles: "articles",
|
|
5
|
+
articleCategories: "article/categories",
|
|
6
|
+
mcq: "mcq",
|
|
7
|
+
mcqs: "mcqs",
|
|
8
|
+
mcqCategories: "mcq/categories",
|
|
9
|
+
qna: "qna",
|
|
10
|
+
qnas: "qnas",
|
|
11
|
+
qnaCategories: "qna/categories",
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default cms;
|
|
15
|
+
//# sourceMappingURL=endpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../src/content/endpoint.ts"],"names":[],"mappings":"AAAA,MAAM,GAAG,GAAG;IACX,EAAE,EAAE;QACH,OAAO,EAAE,SAAS;QAClB,QAAQ,EAAE,UAAU;QACpB,iBAAiB,EAAE,oBAAoB;QACvC,GAAG,EAAE,KAAK;QACV,IAAI,EAAE,MAAM;QACZ,aAAa,EAAE,gBAAgB;QAC/B,GAAG,EAAE,KAAK;QACV,IAAI,EAAE,MAAM;QACZ,aAAa,EAAE,gBAAgB;KAC/B;CACD,CAAC;AAEF,eAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const Content: {
|
|
2
|
+
article: (slug: string) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
3
|
+
articles: (config?: object | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
4
|
+
articleCategories: (config?: object | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
5
|
+
mcq: (slug: string) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
6
|
+
mcqs: (config?: object | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
7
|
+
mcqsCategories: (config?: object | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
8
|
+
qna: (slug: string) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
9
|
+
qnas: (config?: object | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
10
|
+
qnasCategories: (config?: object | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
11
|
+
};
|
|
12
|
+
export default Content;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { get } from "../config/axios.js";
|
|
2
|
+
import { getUrl } from "../config/route.js";
|
|
3
|
+
const Content = {
|
|
4
|
+
article: (slug) => get(getUrl("cms", "v1", "article"), {
|
|
5
|
+
params: {
|
|
6
|
+
slug,
|
|
7
|
+
},
|
|
8
|
+
}),
|
|
9
|
+
articles: (config) => get(getUrl("cms", "v1", "articles"), config),
|
|
10
|
+
articleCategories: (config) => get(getUrl("cms", "v1", "articleCategories"), config),
|
|
11
|
+
mcq: (slug) => get(getUrl("cms", "v1", "mcq"), {
|
|
12
|
+
params: {
|
|
13
|
+
slug,
|
|
14
|
+
},
|
|
15
|
+
}),
|
|
16
|
+
mcqs: (config) => get(getUrl("cms", "v1", "mcqs"), config),
|
|
17
|
+
mcqsCategories: (config) => get(getUrl("cms", "v1", "mcqCategories"), config),
|
|
18
|
+
qna: (slug) => get(getUrl("cms", "v1", "qna"), {
|
|
19
|
+
params: {
|
|
20
|
+
slug,
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
qnas: (config) => get(getUrl("cms", "v1", "qnas"), config),
|
|
24
|
+
qnasCategories: (config) => get(getUrl("cms", "v1", "qnaCategories"), config),
|
|
25
|
+
};
|
|
26
|
+
export default Content;
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/content/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,OAAO,GAAG;IACf,OAAO,EAAE,CAAC,IAAY,EAAE,EAAE,CACzB,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE;QACnC,MAAM,EAAE;YACP,IAAI;SACJ;KACD,CAAC;IACH,QAAQ,EAAE,CAAC,MAA2B,EAAE,EAAE,CACzC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7C,iBAAiB,EAAE,CAAC,MAA2B,EAAE,EAAE,CAClD,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtD,GAAG,EAAE,CAAC,IAAY,EAAE,EAAE,CACrB,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE;QAC/B,MAAM,EAAE;YACP,IAAI;SACJ;KACD,CAAC;IACH,IAAI,EAAE,CAAC,MAA2B,EAAE,EAAE,CACrC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IACzC,cAAc,EAAE,CAAC,MAA2B,EAAE,EAAE,CAC/C,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,eAAe,CAAC,EAAE,MAAM,CAAC;IAClD,GAAG,EAAE,CAAC,IAAY,EAAE,EAAE,CACrB,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE;QAC/B,MAAM,EAAE;YACP,IAAI;SACJ;KACD,CAAC;IACH,IAAI,EAAE,CAAC,MAA2B,EAAE,EAAE,CACrC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IACzC,cAAc,EAAE,CAAC,MAA2B,EAAE,EAAE,CAC/C,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,eAAe,CAAC,EAAE,MAAM,CAAC;CAClD,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as useUser } from "./useUser.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,oDAAoD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// import cookie from "js-cookie";
|
|
2
|
+
// import Router from "next/router";
|
|
3
|
+
// import useUser from "./useUser.js";
|
|
4
|
+
export {};
|
|
5
|
+
// const useAuth = () => {
|
|
6
|
+
// const { mutate } = useUser();
|
|
7
|
+
// const login = (
|
|
8
|
+
// token: string,
|
|
9
|
+
// url: string = "/",
|
|
10
|
+
// noRedirect: boolean = false
|
|
11
|
+
// ) => {
|
|
12
|
+
// cookie.set("token", token, { expires: 1 });
|
|
13
|
+
// mutate();
|
|
14
|
+
// !noRedirect && Router.push(url);
|
|
15
|
+
// };
|
|
16
|
+
// const logout = () => {
|
|
17
|
+
// cookie.remove("token");
|
|
18
|
+
// mutate();
|
|
19
|
+
// Router.replace("/");
|
|
20
|
+
// };
|
|
21
|
+
// return { login, logout };
|
|
22
|
+
// };
|
|
23
|
+
// export default useAuth;
|
|
24
|
+
//# sourceMappingURL=useAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,oCAAoC;AACpC,sCAAsC;;AAEtC,0BAA0B;AAC1B,kCAAkC;AAElC,oBAAoB;AACpB,qBAAqB;AACrB,yBAAyB;AACzB,kCAAkC;AAClC,WAAW;AACX,kDAAkD;AAClD,gBAAgB;AAChB,uCAAuC;AACvC,OAAO;AAEP,2BAA2B;AAC3B,8BAA8B;AAC9B,gBAAgB;AAChB,2BAA2B;AAC3B,OAAO;AACP,8BAA8B;AAC9B,KAAK;AAEL,0BAA0B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// "use client"
|
|
2
|
+
export {};
|
|
3
|
+
// import { useEffect } from "react";
|
|
4
|
+
// import Router from "next/router";
|
|
5
|
+
// import { isAuth } from "../utils/auth.js";
|
|
6
|
+
// const usePrivate = () => {
|
|
7
|
+
// const authenticated = isAuth();
|
|
8
|
+
// useEffect(() => {
|
|
9
|
+
// if (!authenticated) {
|
|
10
|
+
// Router.replace("/auth");
|
|
11
|
+
// }
|
|
12
|
+
// }, [authenticated]);
|
|
13
|
+
// return authenticated;
|
|
14
|
+
// };
|
|
15
|
+
// export default usePrivate;
|
|
16
|
+
//# sourceMappingURL=usePrivate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrivate.js","sourceRoot":"","sources":["../../src/hooks/usePrivate.ts"],"names":[],"mappings":"AAAA,eAAe;;AAEf,qCAAqC;AACrC,oCAAoC;AAEpC,6CAA6C;AAE7C,6BAA6B;AAC7B,oCAAoC;AAEpC,sBAAsB;AACtB,4BAA4B;AAC5B,iCAAiC;AACjC,QAAQ;AACR,yBAAyB;AAEzB,0BAA0B;AAC1B,KAAK;AAEL,6BAA6B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import useSWR from "swr";
|
|
3
|
+
import Account from "../account/index.js";
|
|
4
|
+
import { getUrl } from "../config/route.js";
|
|
5
|
+
const useUser = () => {
|
|
6
|
+
const { data: user, error, isLoading, mutate, } = useSWR(getUrl("account", "v1", "profile"), Account.profile);
|
|
7
|
+
const loggedOut = error && error.status === 403;
|
|
8
|
+
return { user, isLoading, error, loggedOut, mutate };
|
|
9
|
+
};
|
|
10
|
+
export default useUser;
|
|
11
|
+
//# sourceMappingURL=useUser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUser.js","sourceRoot":"","sources":["../../src/hooks/useUser.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,MAAM,MAAM,KAAK,CAAC;AAEzB,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,OAAO,GAAG,GAAG,EAAE;IACpB,MAAM,EACL,IAAI,EAAE,IAAI,EACV,KAAK,EACL,SAAS,EACT,MAAM,GACN,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEhE,MAAM,SAAS,GAAG,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,CAAC;IAEhD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;AACtD,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Auth } from "./auth/index.js";
|
|
2
|
+
export { default as Order } from "./order/index.js";
|
|
3
|
+
export { default as Payment } from "./payment/index.js";
|
|
4
|
+
export { default as Content } from "./content/index.js";
|
|
5
|
+
export { default as Accounting } from "./accounting/index.js";
|
|
6
|
+
export { default as Support } from "./support/index.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
/// <reference types="styled-jsx" />
|
|
3
|
+
// export { Protected } from './auth/Protected';
|
|
4
|
+
// export { isAuth } from './utils/auth';
|
|
5
|
+
export { default as Auth } from "./auth/index.js";
|
|
6
|
+
export { default as Order } from "./order/index.js";
|
|
7
|
+
export { default as Payment } from "./payment/index.js";
|
|
8
|
+
export { default as Content } from "./content/index.js";
|
|
9
|
+
export { default as Accounting } from "./accounting/index.js";
|
|
10
|
+
export { default as Support } from "./support/index.js";
|
|
11
|
+
// export { useUser, usePrivate, useAuth } from './hooks';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,oCAAoC;AACpC,gDAAgD;AAChD,yCAAyC;AACzC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,0DAA0D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Order } from "./types.js";
|
|
2
|
+
declare const create: (data: Order, { config, onFetching, onSuccess, onError, onSettled, }: {
|
|
3
|
+
onFetching?: () => void;
|
|
4
|
+
onSuccess?: (data: object) => void;
|
|
5
|
+
onError?: (error: string) => void;
|
|
6
|
+
onSettled?: () => void;
|
|
7
|
+
config?: object;
|
|
8
|
+
}) => Promise<void>;
|
|
9
|
+
export default create;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { post } from "../config/axios.js";
|
|
2
|
+
import handler from "../config/handler.js";
|
|
3
|
+
import { getUrl } from "../config/route.js";
|
|
4
|
+
const create = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
|
|
5
|
+
return handler(post(getUrl("order", "v1", "create"), data, config), {
|
|
6
|
+
onFetching: () => onFetching?.(),
|
|
7
|
+
onError: (error) => onError?.(error),
|
|
8
|
+
onSuccess: (data) => onSuccess?.(data),
|
|
9
|
+
onSettled: () => onSettled?.(),
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
export default create;
|
|
13
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/order/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG5C,MAAM,MAAM,GAAG,CACd,IAAW,EACX,EACC,MAAM,EACN,UAAU,EACV,SAAS,EACT,OAAO,EACP,SAAS,GAOT,EACA,EAAE;IACH,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE;QACnE,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,EAAE;QAChC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC;QACpC,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC;QACtC,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE;KAC9B,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../src/order/endpoint.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG;IACb,EAAE,EAAE;QACH,MAAM,EAAE,EAAE;KACV;CACD,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const Order: {
|
|
2
|
+
create: (data: import("./types.js").Order, { config, onFetching, onSuccess, onError, onSettled, }: {
|
|
3
|
+
onFetching?: () => void;
|
|
4
|
+
onSuccess?: (data: object) => void;
|
|
5
|
+
onError?: (error: string) => void;
|
|
6
|
+
onSettled?: () => void;
|
|
7
|
+
config?: object;
|
|
8
|
+
}) => Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
export default Order;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/order/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,MAAM,KAAK,GAAG;IACb,MAAM;CACN,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/order/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../src/payment/endpoint.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;IACf,EAAE,EAAE;QACH,MAAM,EAAE,EAAE;QACV,MAAM,EAAE,QAAQ;KAChB;CACD,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare const Payment: {
|
|
2
|
+
start: (data: import("../order/types.js").Order, { config, onFetching, onSuccess, onError, onSettled, }: {
|
|
3
|
+
onFetching?: () => void;
|
|
4
|
+
onSuccess?: (data: import("./start.js").SuccessProps) => void;
|
|
5
|
+
onError?: (error: string) => void;
|
|
6
|
+
onSettled?: () => void;
|
|
7
|
+
config?: object;
|
|
8
|
+
}) => Promise<void>;
|
|
9
|
+
verify: (data: import("./types.js").VerifyPayment, { config, onFetching, onSuccess, onError, onSettled, }: {
|
|
10
|
+
onFetching?: () => void;
|
|
11
|
+
onSuccess?: (data: import("./start.js").SuccessProps) => void;
|
|
12
|
+
onError?: (error: string) => void;
|
|
13
|
+
onSettled?: () => void;
|
|
14
|
+
config?: never;
|
|
15
|
+
}) => Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
export default Payment;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/payment/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,MAAM,OAAO,GAAG;IACf,KAAK;IACL,MAAM;CACN,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Order } from "../order/types.js";
|
|
2
|
+
export interface SuccessProps {
|
|
3
|
+
data: unknown;
|
|
4
|
+
status: number;
|
|
5
|
+
statusText: string;
|
|
6
|
+
}
|
|
7
|
+
export interface StartSuccessProp {
|
|
8
|
+
_id: string;
|
|
9
|
+
options: {
|
|
10
|
+
handler: (res: never) => void;
|
|
11
|
+
};
|
|
12
|
+
method: string;
|
|
13
|
+
}
|
|
14
|
+
declare const start: (data: Order, { config, onFetching, onSuccess, onError, onSettled, }: {
|
|
15
|
+
onFetching?: () => void;
|
|
16
|
+
onSuccess?: (data: SuccessProps) => void;
|
|
17
|
+
onError?: (error: string) => void;
|
|
18
|
+
onSettled?: () => void;
|
|
19
|
+
config?: object;
|
|
20
|
+
}) => Promise<void>;
|
|
21
|
+
export default start;
|