@helpdice/sdk 0.5.1 → 0.5.2

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.
Files changed (86) hide show
  1. package/dist/index.js +10 -12
  2. package/dist/index.js.map +1 -1
  3. package/dist/types/config/index.d.ts +2 -28
  4. package/dist/types/config/state.d.ts +31 -0
  5. package/package.json +9 -9
  6. package/dist/cjs/account/endpoint.js +0 -8
  7. package/dist/cjs/account/index.js +0 -17
  8. package/dist/cjs/account/types.js +0 -2
  9. package/dist/cjs/account/update_profile.js +0 -17
  10. package/dist/cjs/accounting/createInvoice.js +0 -17
  11. package/dist/cjs/accounting/endpoint.js +0 -14
  12. package/dist/cjs/accounting/index.js +0 -25
  13. package/dist/cjs/accounting/submitInvoice.js +0 -17
  14. package/dist/cjs/accounting/types.js +0 -2
  15. package/dist/cjs/accounting/updateInvoice.js +0 -17
  16. package/dist/cjs/apis/cities.js +0 -17
  17. package/dist/cjs/apis/countries.js +0 -17
  18. package/dist/cjs/apis/index.js +0 -14
  19. package/dist/cjs/apis/states.js +0 -17
  20. package/dist/cjs/assets/endpoint.js +0 -9
  21. package/dist/cjs/assets/index.js +0 -11
  22. package/dist/cjs/auth/authWithKey.js +0 -17
  23. package/dist/cjs/auth/authWithToken.js +0 -17
  24. package/dist/cjs/auth/endpoint.js +0 -15
  25. package/dist/cjs/auth/index.js +0 -94
  26. package/dist/cjs/auth/logout.js +0 -22
  27. package/dist/cjs/auth/register.js +0 -17
  28. package/dist/cjs/auth/resetPassword.js +0 -17
  29. package/dist/cjs/auth/signInWithGoogle.js +0 -56
  30. package/dist/cjs/auth/signin.js +0 -17
  31. package/dist/cjs/auth/signup.js +0 -17
  32. package/dist/cjs/auth/types.js +0 -2
  33. package/dist/cjs/config/axios.js +0 -120
  34. package/dist/cjs/config/constants.js +0 -12
  35. package/dist/cjs/config/fetch.js +0 -37
  36. package/dist/cjs/config/handler.js +0 -32
  37. package/dist/cjs/config/index.js +0 -37
  38. package/dist/cjs/config/local-storage.js +0 -29
  39. package/dist/cjs/config/route.js +0 -47
  40. package/dist/cjs/config/validate.js +0 -15
  41. package/dist/cjs/content/endpoint.js +0 -17
  42. package/dist/cjs/content/index.js +0 -29
  43. package/dist/cjs/hooks/index.js +0 -10
  44. package/dist/cjs/hooks/useAuth.js +0 -23
  45. package/dist/cjs/hooks/usePrivate.js +0 -15
  46. package/dist/cjs/hooks/useUser.js +0 -15
  47. package/dist/cjs/index.js +0 -59
  48. package/dist/cjs/inventory/endpoint.js +0 -9
  49. package/dist/cjs/inventory/index.js +0 -26
  50. package/dist/cjs/linkie/endpoint.js +0 -8
  51. package/dist/cjs/linkie/index.js +0 -20
  52. package/dist/cjs/linkie/shortUrl.js +0 -17
  53. package/dist/cjs/linkie/types.js +0 -2
  54. package/dist/cjs/order/create.js +0 -17
  55. package/dist/cjs/order/endpoint.js +0 -8
  56. package/dist/cjs/order/index.js +0 -10
  57. package/dist/cjs/order/types.js +0 -2
  58. package/dist/cjs/payment/components/ProcessPayment.js +0 -266
  59. package/dist/cjs/payment/endpoint.js +0 -9
  60. package/dist/cjs/payment/index.js +0 -12
  61. package/dist/cjs/payment/start.js +0 -38
  62. package/dist/cjs/payment/types.js +0 -2
  63. package/dist/cjs/payment/verify.js +0 -17
  64. package/dist/cjs/sales/endpoint.js +0 -8
  65. package/dist/cjs/sales/index.js +0 -7
  66. package/dist/cjs/sales/lead.js +0 -22
  67. package/dist/cjs/sales/types.js +0 -17
  68. package/dist/cjs/support/endpoint.js +0 -10
  69. package/dist/cjs/support/index.js +0 -15
  70. package/dist/cjs/support/newsletter.js +0 -17
  71. package/dist/cjs/support/ticket.js +0 -17
  72. package/dist/cjs/tools/endpoint.js +0 -8
  73. package/dist/cjs/tools/exchangeRates.js +0 -30
  74. package/dist/cjs/tools/index.js +0 -10
  75. package/dist/cjs/types.js +0 -9
  76. package/dist/cjs/utils/auth.js +0 -23
  77. package/dist/cjs/utils/handler.js +0 -35
  78. package/dist/cjs/utils/localStorage.js +0 -137
  79. package/dist/cjs/utils/share.js +0 -25
  80. package/dist/types/config/local-storage.d.ts +0 -0
  81. package/dist/types/config/validate.d.ts +0 -4
  82. package/dist/types/hooks/index.d.ts +0 -1
  83. package/dist/types/hooks/useAuth.d.ts +0 -0
  84. package/dist/types/hooks/usePrivate.d.ts +0 -0
  85. package/dist/types/hooks/useUser.d.ts +0 -8
  86. package/dist/types/payment/components/ProcessPayment.d.ts +0 -0
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const order = {
4
- v1: {
5
- create: "",
6
- },
7
- };
8
- exports.default = order;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const create_1 = __importDefault(require("./create"));
7
- const Order = {
8
- create: create_1.default,
9
- };
10
- exports.default = Order;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,266 +0,0 @@
1
- "use strict";
2
- // /* eslint-disable jsx-a11y/no-static-element-interactions */
3
- // /* eslint-disable jsx-a11y/click-events-have-key-events */
4
- // /* eslint-disable react/prop-types */
5
- // import * as Yup from 'yup';
6
- // import Proptypes from 'prop-types';
7
- // import { USD_TO_INR } from '../../utils/config';
8
- // import { razorPay } from '../../utils/paymentFunctions';
9
- // import { Grid, Modal, Text, FormWrapper } from '@helpdice/ui';
10
- // import { getExchangeRates } from '../../utils/exchangeRates';
11
- // import { toast } from 'react-toastify';
12
- // const PAYMENT_SERVICE = [
13
- // { label: 'Razor Pay', currency: 'INR', enable: true },
14
- // { label: 'Paypal', currency: 'USD', enable: false },
15
- // { label: 'Stripe', currency: 'USD', enable: false }
16
- // ];
17
- // type ProcessPaymentProps = {
18
- // visible: boolean;
19
- // setVisible?: () => void;
20
- // currency: string;
21
- // amount: number;
22
- // entity?: string;
23
- // term?: string;
24
- // data?: any;
25
- // token?: string;
26
- // paymentFn?: () => void;
27
- // verifyFn?: () => void;
28
- // onComplete?: (result?: any) => void
29
- // }
30
- // function ProcessPayment({
31
- // visible = false,
32
- // setVisible = () => {},
33
- // currency,
34
- // amount = 0,
35
- // entity,
36
- // term,
37
- // data,
38
- // token,
39
- // paymentFn,
40
- // verifyFn,
41
- // onComplete = (result) => {}
42
- // }: ProcessPaymentProps) {
43
- // return (
44
- // <FormWrapper
45
- // enableReinitialize
46
- // initialValues={{
47
- // data: data,
48
- // token: token ?? '',
49
- // method: {
50
- // label: 'Paypal',
51
- // currency: currency
52
- // },
53
- // amount: amount,
54
- // entity: entity,
55
- // term: 1
56
- // }}
57
- // validationSchema={Yup.object().shape({
58
- // method: Yup.object().shape({
59
- // label: Yup.string().required('Please select Payment Service'),
60
- // currency: Yup.string().required('Please select Payment Service'),
61
- // enable: Yup.bool().required()
62
- // }),
63
- // term: Yup.string(),
64
- // token: Yup.string(),
65
- // data: Yup.object()
66
- // })}
67
- // onSubmit={async (values, { resetForm, setSubmitting }) => {
68
- // // console.log('Process Payment');
69
- // return toast.promise(paymentFn({ ...values, order: data?.order }), {
70
- // pending: 'Processing Payment...',
71
- // success: {
72
- // render({ data }) {
73
- // // const order = data.order;
74
- // const options = data.options;
75
- // options.handler = async (response) => {
76
- // toast.dismiss();
77
- // const body = {
78
- // id: values.data._id,
79
- // payment: response
80
- // };
81
- // toast
82
- // .promise(verifyFn(body), {
83
- // pending: 'Verifying Payment...',
84
- // success: {
85
- // render({ data }) {
86
- // setVisible(null);
87
- // return data.message;
88
- // }
89
- // },
90
- // error: {
91
- // render({ data }) {
92
- // // When the promise reject, data will contains the error
93
- // return data.message;
94
- // }
95
- // }
96
- // })
97
- // .then(() => {
98
- // cache.invalidateQueries('susbscriptions');
99
- // });
100
- // // const validateRes = await fetch('http://localhost:5000/order/validate', {
101
- // // method: 'POST',
102
- // // body: JSON.stringify(body),
103
- // // headers: {
104
- // // 'Content-Type': 'application/json'
105
- // // }
106
- // // });
107
- // // const jsonRes = await validateReson();
108
- // // console.log(jsonRes);
109
- // };
110
- // var rzp1 = new window.Razorpay(data.options);
111
- // rzp1.on('payment.failed', function (response) {
112
- // toast.dismiss();
113
- // toast.error('Payment Failed, Please Try Again Later');
114
- // // alert(response.error.code);
115
- // // alert(response.error.description);
116
- // // alert(response.error.source);
117
- // // alert(response.error.step);
118
- // // alert(response.error.reason);
119
- // // alert(response.error.metadata.order_id);
120
- // // alert(response.error.metadata.payment_id);
121
- // });
122
- // rzp1.open();
123
- // return data.message;
124
- // },
125
- // icon: '🟢'
126
- // },
127
- // error: {
128
- // render({ data }) {
129
- // // When the promise reject, data will contains the error
130
- // return data.message;
131
- // }
132
- // }
133
- // });
134
- // }}
135
- // >
136
- // {({ handleChange, handleSubmit, setFieldValue, isSubmitting, values, errors }) => {
137
- // // console.log(values);
138
- // console.log(errors);
139
- // return (
140
- // <form noValidate onSubmit={handleSubmit}>
141
- // <Modal visible={visible}>
142
- // <Modal.Title>Payment Information</Modal.Title>
143
- // {/* <Modal.Subtitle>This is a modal</Modal.Subtitle> */}
144
- // <Modal.Content>
145
- // <Grid.Container gap={1.5}>
146
- // <Grid xs={24}>
147
- // <InputLabel>Select Service</InputLabel>
148
- // </Grid>
149
- // {PAYMENT_SERVICE.map((mhd, inx) => (
150
- // <Grid key={`${inx}-payment-service`} xs={12} sm={8}>
151
- // <div
152
- // onClick={async () => {
153
- // setFieldValue('method', { ...mhd });
154
- // const rate = await getExchangeRates(currency, mhd?.currency);
155
- // setFieldValue('amount', (Number(amount) * rate).toFixed(2));
156
- // }}
157
- // style={{
158
- // width: '100%',
159
- // display: 'flex',
160
- // alignItems: 'center',
161
- // justifyContent: 'center',
162
- // height: 60,
163
- // cursor: 'pointer',
164
- // position: 'relative',
165
- // border: `2px solid ${values.method?.label === mhd.label ? '#333' : '#dcdcdc'}`,
166
- // borderRadius: '10px'
167
- // }}
168
- // >
169
- // <Text h6>{mhd.label}</Text>
170
- // <Typography
171
- // sx={{ position: 'absolute', bottom: 0, right: 0, mr: 1, mb: 0.3 }}
172
- // variant="subtitle2"
173
- // >
174
- // {mhd.currency}
175
- // </Typography>
176
- // </div>
177
- // </Grid>
178
- // ))}
179
- // {errors.method && (
180
- // <Grid xs={24}>
181
- // <Typography sx={{ mt: 0.5 }} color="error">
182
- // {errors.method.label}
183
- // </Typography>{' '}
184
- // </Grid>
185
- // )}
186
- // {term && (
187
- // <Grid xs={24}>
188
- // <InputLabel>Payment Term</InputLabel>
189
- // <FormControl sx={{ mt: 2, width: 250 }} required>
190
- // <Select
191
- // inputProps={{
192
- // name: 'term',
193
- // id: 'payment_term'
194
- // }}
195
- // value={values.term}
196
- // onChange={handleChange}
197
- // >
198
- // <MenuItem value="" disabled>
199
- // Choose Term
200
- // </MenuItem>
201
- // {[
202
- // { label: '1 Month', value: 1 },
203
- // { label: '12 Month', value: 12 },
204
- // { label: '24 Month', value: 24 },
205
- // { label: '36 Month', value: 36 }
206
- // ].map((term, inx) => (
207
- // <MenuItem key={`id-term-${inx}`} value={term.value}>
208
- // {term.label}
209
- // </MenuItem>
210
- // ))}
211
- // </Select>
212
- // </FormControl>
213
- // </Grid>
214
- // )}
215
- // <Grid xs={24}>
216
- // <div>
217
- // <InputLabel>Payment Amount</InputLabel>
218
- // <Typography sx={{ mt: 2 }}>
219
- // {formatCurrency(values.amount, null, values.method?.currency)}
220
- // </Typography>
221
- // </div>
222
- // </Grid>
223
- // </Grid.Container>
224
- // {/* <Stack spacing={1}> */}
225
- // {/* <Typography sx={{ color: '#333' }} variant="subtitle2">
226
- // Card Holder Name
227
- // </Typography>
228
- // <TextField autoComplete="off" style={{ width: '100%' }} />
229
- // <br />
230
- // <CardElement options={CARD_ELEMENT_OPTIONS} />
231
- // <br />
232
- // {errors && (
233
- // <Typography variant="subtitle2" color="danger">
234
- // {errors}
235
- // </Typography>
236
- // )}
237
- // <button style={{ cursor: 'pointer' }} type="submit" className="button">
238
- // CheckOut
239
- // </button> */}
240
- // {/* </Stack> */}
241
- // </Modal.Content>
242
- // <Modal.Action
243
- // passive
244
- // onClick={() => {
245
- // setVisible(null);
246
- // toast.dismiss();
247
- // }}
248
- // >
249
- // Cancel
250
- // </Modal.Action>
251
- // {/* {console.log(values.method)} */}
252
- // <Modal.Action disabled={!values.method?.enable} onClick={handleSubmit} type="submit" loading={isSubmitting}>
253
- // Pay Now
254
- // </Modal.Action>
255
- // </Modal>
256
- // </form>
257
- // );
258
- // }}
259
- // </FormWrapper>
260
- // );
261
- // }
262
- // ProcessPayment.prototype = {
263
- // paymentFn: Proptypes.func.isRequired,
264
- // verifyFn: Proptypes.func.isRequired
265
- // };
266
- // export default ProcessPayment;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const payment = {
4
- v1: {
5
- create: "",
6
- verify: "verify",
7
- },
8
- };
9
- exports.default = payment;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const start_1 = __importDefault(require("./start"));
7
- const verify_1 = __importDefault(require("./verify"));
8
- const Payment = {
9
- start: start_1.default,
10
- verify: verify_1.default,
11
- };
12
- exports.default = Payment;
@@ -1,38 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const axios_1 = require("../config/axios");
7
- const route_1 = require("../config/route");
8
- const handler_1 = __importDefault(require("../utils/handler"));
9
- function start(data, { config = null, onLoading = () => { }, onSuccess = () => { }, onError = () => { }, onSettled = () => { }, } = {}) {
10
- return (0, handler_1.default)({
11
- promise: (0, axios_1.post)((0, route_1.getUrl)("payment", "v1", "create"), {
12
- ...data,
13
- method: {
14
- label: data.paymentService,
15
- currency: data.currency,
16
- },
17
- }, config || undefined),
18
- onLoading,
19
- onError: (error) => onError(error),
20
- onSuccess: (responseData) => {
21
- if (responseData?.method === "Razor Pay") {
22
- const options = responseData.options;
23
- options.handler = async (response) => {
24
- // console.log("Payment Success:", response);
25
- onSuccess(response);
26
- // Validation call (if needed)
27
- };
28
- const rzp1 = new window.Razorpay(options);
29
- rzp1.on("payment.failed", (response) => {
30
- onError(response);
31
- });
32
- rzp1.open();
33
- }
34
- },
35
- onSettled,
36
- });
37
- }
38
- exports.default = start;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const axios_1 = require("../config/axios");
7
- const handler_1 = __importDefault(require("../config/handler"));
8
- const route_1 = require("../config/route");
9
- const verify = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
10
- return (0, handler_1.default)((0, axios_1.post)((0, route_1.getUrl)("payment", "v1", "verify"), data, config), {
11
- onFetching: () => onFetching?.(),
12
- onError: (error) => onError?.(error),
13
- onSuccess: (data) => onSuccess?.(data),
14
- onSettled: () => onSettled?.(),
15
- });
16
- };
17
- exports.default = verify;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const sales = {
4
- v1: {
5
- addLead: "lead"
6
- },
7
- };
8
- exports.default = sales;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const lead_1 = require("./lead");
4
- const Sales = {
5
- addLead: lead_1.addLead,
6
- };
7
- exports.default = Sales;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.addLead = addLead;
7
- const axios_1 = require("../config/axios");
8
- const route_1 = require("../config/route");
9
- const handler_1 = __importDefault(require("../utils/handler"));
10
- function addLead(data, { config = null, onLoading = () => { }, onSuccess = () => { }, onError = () => { }, onSettled = () => { }, } = {}) {
11
- return (0, handler_1.default)({
12
- promise: (0, axios_1.post)((0, route_1.getUrl)("sales", "v1", "addLead"), {
13
- ...data
14
- }, config || undefined),
15
- onLoading,
16
- onError: (error) => onError(error),
17
- onSuccess: (responseData) => {
18
- onSuccess(responseData);
19
- },
20
- onSettled,
21
- });
22
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LeadStatus = exports.LeadSource = void 0;
4
- var LeadSource;
5
- (function (LeadSource) {
6
- LeadSource["Paid"] = "Paid";
7
- LeadSource["Organic"] = "Organic";
8
- })(LeadSource || (exports.LeadSource = LeadSource = {}));
9
- var LeadStatus;
10
- (function (LeadStatus) {
11
- LeadStatus["Raw"] = "Raw";
12
- LeadStatus["InProgress"] = "In-Progress";
13
- LeadStatus["NoResponse"] = "No-response";
14
- LeadStatus["Won"] = "Won";
15
- LeadStatus["Bad"] = "Bad";
16
- LeadStatus["Archived"] = "Archived";
17
- })(LeadStatus || (exports.LeadStatus = LeadStatus = {}));
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const support = {
4
- v1: {
5
- ticket: "ticket",
6
- tickets: "tickets",
7
- newsletter: "newsletter",
8
- },
9
- };
10
- exports.default = support;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const axios_1 = require("../config/axios");
7
- const route_1 = require("../config/route");
8
- const newsletter_1 = __importDefault(require("./newsletter"));
9
- const ticket_1 = __importDefault(require("./ticket"));
10
- const Support = {
11
- ticket: ticket_1.default,
12
- newsletter: newsletter_1.default,
13
- tickets: (config) => (0, axios_1.get)((0, route_1.getUrl)("support", "v1", "tickets"), config),
14
- };
15
- exports.default = Support;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const axios_1 = require("../config/axios");
7
- const handler_1 = __importDefault(require("../config/handler"));
8
- const route_1 = require("../config/route");
9
- const newsletter = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
10
- return (0, handler_1.default)((0, axios_1.post)((0, route_1.getUrl)("support", "v1", "newsletter"), data, config), {
11
- onFetching: () => onFetching?.(),
12
- onError: (error) => onError?.(error),
13
- onSuccess: (data) => onSuccess?.(data),
14
- onSettled: () => onSettled?.(),
15
- });
16
- };
17
- exports.default = newsletter;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const axios_1 = require("../config/axios");
7
- const handler_1 = __importDefault(require("../config/handler"));
8
- const route_1 = require("../config/route");
9
- const ticket = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
10
- return (0, handler_1.default)((0, axios_1.post)((0, route_1.getUrl)("support", "v1", "ticket"), data, config), {
11
- onFetching: () => onFetching?.(),
12
- onError: (error) => onError?.(error),
13
- onSuccess: (data) => onSuccess?.(data),
14
- onSettled: () => onSettled?.(),
15
- });
16
- };
17
- exports.default = ticket;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tools = {
4
- v1: {
5
- exchangeRates: "exchange-rates",
6
- },
7
- };
8
- exports.default = tools;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const axios_1 = require("../config/axios");
7
- const handler_1 = __importDefault(require("../config/handler"));
8
- const route_1 = require("../config/route");
9
- const exchangeRates = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
10
- return (0, handler_1.default)((0, axios_1.get)((0, route_1.getUrl)("tools", "v1", "exchangeRates"), config), {
11
- onFetching: () => onFetching?.(),
12
- onError: (error) => onError?.(error),
13
- onSuccess: (data) => onSuccess?.(data),
14
- onSettled: () => onSettled?.(),
15
- });
16
- };
17
- exports.default = exchangeRates;
18
- // export async function convertCurrency(amount: number, fromCurrency?: string, toCurrency?: string) {
19
- // try {
20
- // const rates = await getExchangeRates(fromCurrency);
21
- // if (!rates[toCurrency]) {
22
- // throw new Error(`Currency ${toCurrency} is not available.`);
23
- // }
24
- // const convertedAmount = (amount * rates[toCurrency]).toFixed(2);
25
- // return convertedAmount;
26
- // } catch (error) {
27
- // console.error('Error converting currency:', error);
28
- // throw error;
29
- // }
30
- // }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const exchangeRates_1 = __importDefault(require("./exchangeRates"));
7
- const Tools = {
8
- exchangeRates: exchangeRates_1.default,
9
- };
10
- exports.default = Tools;
package/dist/cjs/types.js DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Gender = void 0;
4
- var Gender;
5
- (function (Gender) {
6
- Gender["Male"] = "Male";
7
- Gender["Female"] = "Female";
8
- Gender["Other"] = "Other";
9
- })(Gender || (exports.Gender = Gender = {}));
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isAuth = exports.getCookie = void 0;
7
- const js_cookie_1 = __importDefault(require("js-cookie"));
8
- // import type { NextPageContext } from "next";
9
- // import { parseCookies } from "nookies";
10
- const config_1 = require("../config");
11
- const getCookie = (key = (0, config_1.getConfig)().tokenKey) => {
12
- // console.log(Cookies.get(key));
13
- if (key)
14
- return js_cookie_1.default.get(key);
15
- return "";
16
- };
17
- exports.getCookie = getCookie;
18
- const isAuth = () => !!(0, exports.getCookie)();
19
- exports.isAuth = isAuth;
20
- // export const getServerSideToken = (ctx: NextPageContext) => {
21
- // const { token } = parseCookies(ctx);
22
- // return token;
23
- // };
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const handler = ({ promise, onLoading = () => { }, onSuccess = () => { }, onError = () => { }, onSettled = () => { }, onProgress = () => { }, }) => {
4
- // Call onLoading at the start to show loading state
5
- onLoading(true);
6
- // Handling the passed promise
7
- promise
8
- .then((response) => {
9
- // Show success state
10
- console.log("Request Success:", response);
11
- // Execute success callback if provided
12
- if (onSuccess) {
13
- onSuccess(response.data);
14
- }
15
- })
16
- .catch((error) => {
17
- // Show error state
18
- console.error("Request Error:", error);
19
- // Execute error callback if provided
20
- if (onError) {
21
- onError(error);
22
- }
23
- })
24
- .finally(() => {
25
- // Execute settled callback (on success or error)
26
- if (onSettled) {
27
- onSettled();
28
- }
29
- // Call onLoading to hide loading indicator after completion
30
- onLoading(false);
31
- // Hide loading indicator
32
- console.log("Request Completed");
33
- });
34
- };
35
- exports.default = handler;