@ercioko/meblotex-api 0.2.2 → 0.2.3
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/dist/api/Api.d.ts +33 -0
- package/dist/api/Api.js +152 -0
- package/dist/api/Endpoint.d.ts +13 -0
- package/dist/api/Endpoint.js +126 -0
- package/dist/api/createApi.d.ts +52 -0
- package/dist/api/createApi.js +81 -0
- package/dist/api/error.d.ts +15 -0
- package/dist/api/error.js +18 -0
- package/{src/api/index.ts → dist/api/index.d.ts} +0 -1
- package/dist/api/index.js +34 -0
- package/dist/api/status.d.ts +3 -0
- package/dist/api/status.js +6 -0
- package/dist/api/utils/getAlert.d.ts +6 -0
- package/dist/api/utils/getAlert.js +65 -0
- package/dist/api/utils/index.js +8 -0
- package/dist/app_types.d.ts +607 -0
- package/dist/app_types.js +75 -0
- package/dist/components/ApiHostProvider.d.ts +7 -0
- package/dist/components/ApiHostProvider.js +35 -0
- package/dist/components/StatusTag.d.ts +11 -0
- package/dist/components/StatusTag.js +86 -0
- package/dist/components/Table/DataTableWrapper.d.ts +3 -0
- package/dist/components/Table/DataTableWrapper.js +44 -0
- package/dist/components/Table/FloatingActions.d.ts +14 -0
- package/dist/components/Table/FloatingActions.js +32 -0
- package/dist/components/Table/Spinner.d.ts +2 -0
- package/dist/components/Table/Spinner.js +26 -0
- package/dist/components/Table/Table.d.ts +28 -0
- package/dist/components/Table/Table.js +330 -0
- package/dist/components/Table/addIndexToObject.d.ts +3 -0
- package/dist/components/Table/addIndexToObject.js +17 -0
- package/dist/components/Table/areProvidedColumnsDifferent.d.ts +2 -0
- package/dist/components/Table/areProvidedColumnsDifferent.js +16 -0
- package/dist/components/Table/hooks/useFetchPage.d.ts +18 -0
- package/dist/components/Table/hooks/useFetchPage.js +123 -0
- package/dist/components/Table/hooks/useGetCellRenderer.d.ts +25 -0
- package/dist/components/Table/hooks/useGetCellRenderer.js +166 -0
- package/dist/components/Table/hooks/useGetColumnsWithCheckbox.d.ts +5 -0
- package/dist/components/Table/hooks/useGetColumnsWithCheckbox.js +53 -0
- package/dist/components/Table/hooks/useGetDeleteRow.d.ts +9 -0
- package/dist/components/Table/hooks/useGetDeleteRow.js +74 -0
- package/dist/components/Table/hooks/useGetResizeColumn.d.ts +8 -0
- package/dist/components/Table/hooks/useGetResizeColumn.js +28 -0
- package/dist/components/Table/hooks/useGetRowCheckbox.d.ts +5 -0
- package/dist/components/Table/hooks/useGetRowCheckbox.js +54 -0
- package/dist/components/Table/hooks/useLoadDataSource.d.ts +10 -0
- package/dist/components/Table/hooks/useLoadDataSource.js +20 -0
- package/dist/components/Table/hooks/usePageSize.d.ts +5 -0
- package/dist/components/Table/hooks/usePageSize.js +16 -0
- package/dist/components/Table/hooks/useRenderRowActions.d.ts +6 -0
- package/dist/components/Table/hooks/useRenderRowActions.js +51 -0
- package/dist/components/Table/hooks/useResizeColumns.d.ts +9 -0
- package/dist/components/Table/hooks/useResizeColumns.js +60 -0
- package/dist/components/Table/index.d.ts +1 -0
- package/dist/components/Table/index.js +8 -0
- package/dist/components/Table/providers/OrderProvider.d.ts +9 -0
- package/dist/components/Table/providers/OrderProvider.js +17 -0
- package/dist/components/Table/styles.d.ts +6 -0
- package/dist/components/Table/styles.js +37 -0
- package/dist/components/index.js +26 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.js +8 -0
- package/dist/db_types.d.ts +208 -0
- package/dist/db_types.js +2 -0
- package/dist/hooks/index.js +10 -0
- package/dist/hooks/useApi.d.ts +2 -0
- package/dist/hooks/useApi.js +42 -0
- package/dist/hooks/useEndpoint.d.ts +2 -0
- package/dist/hooks/useEndpoint.js +34 -0
- package/dist/index.js +19 -0
- package/dist/lib/index.js +18 -0
- package/dist/lib/jednostkaNazwa.d.ts +6 -0
- package/dist/lib/jednostkaNazwa.js +9 -0
- package/dist/lib/typDokumentuNazwa.d.ts +6 -0
- package/dist/lib/typDokumentuNazwa.js +11 -0
- package/dist/src/api/Api.js +316 -0
- package/dist/src/api/Endpoint.js +365 -0
- package/dist/src/api/createApi.js +50 -0
- package/dist/src/api/error.js +15 -0
- package/dist/src/api/index.js +5 -0
- package/dist/src/api/status.js +3 -0
- package/dist/src/api/utils/getAlert.js +63 -0
- package/dist/src/api/utils/index.js +1 -0
- package/dist/src/app_types.js +72 -0
- package/dist/src/components/ApiHostProvider.js +11 -0
- package/dist/src/components/StatusTag.js +153 -0
- package/dist/src/components/Table/DataTableWrapper.js +115 -0
- package/dist/src/components/Table/FloatingActions.js +60 -0
- package/dist/src/components/Table/Spinner.js +40 -0
- package/dist/src/components/Table/Summary.js +16 -0
- package/dist/src/components/Table/Table.js +498 -0
- package/dist/src/components/Table/addIndexToObject.js +57 -0
- package/dist/src/components/Table/areProvidedColumnsDifferent.js +19 -0
- package/dist/src/components/Table/clicked.js +12 -0
- package/dist/src/components/Table/displayActions.js +11 -0
- package/dist/src/components/Table/hooks/useFetchPage.js +254 -0
- package/dist/src/components/Table/hooks/useGetCellRenderer.js +231 -0
- package/dist/src/components/Table/hooks/useGetColumnsWithCheckbox.js +33 -0
- package/dist/src/components/Table/hooks/useGetDeleteRow.js +181 -0
- package/dist/src/components/Table/hooks/useGetResizeColumn.js +72 -0
- package/dist/src/components/Table/hooks/useGetRowCheckbox.js +55 -0
- package/dist/src/components/Table/hooks/useLoadDataSource.js +16 -0
- package/dist/src/components/Table/hooks/usePageSize.js +15 -0
- package/dist/src/components/Table/hooks/useRenderRowActions.js +50 -0
- package/dist/src/components/Table/hooks/useResizeColumns.js +70 -0
- package/dist/src/components/Table/index.js +1 -0
- package/dist/src/components/Table/providers/OrderProvider.js +65 -0
- package/dist/src/components/Table/styles.js +66 -0
- package/dist/src/components/index.js +4 -0
- package/dist/src/config.js +6 -0
- package/dist/src/db_types.js +1 -0
- package/dist/src/hooks/index.js +2 -0
- package/dist/src/hooks/useApi.js +84 -0
- package/dist/src/hooks/useEndpoint.js +60 -0
- package/dist/src/index.js +3 -0
- package/dist/src/lib/index.js +2 -0
- package/dist/src/lib/jednostkaNazwa.js +6 -0
- package/dist/src/lib/typDokumentuNazwa.js +16 -0
- package/dist/src/utils/Query.js +73 -0
- package/dist/src/utils/getWZNumber.js +4 -0
- package/dist/src/utils/getZamowienieDokumentNumber.js +4 -0
- package/{src/utils/index.ts → dist/src/utils/index.js} +2 -2
- package/dist/utils/Query.d.ts +6 -0
- package/dist/utils/Query.js +33 -0
- package/dist/utils/getWZNumber.d.ts +2 -0
- package/dist/utils/getWZNumber.js +10 -0
- package/dist/utils/getZamowienieDokumentNumber.d.ts +2 -0
- package/dist/utils/getZamowienieDokumentNumber.js +8 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +12 -0
- package/package.json +3 -2
- package/.eslintrc +0 -6
- package/.nvmrc +0 -1
- package/.prettierrc +0 -11
- package/src/api/Api.ts +0 -140
- package/src/api/Endpoint.ts +0 -76
- package/src/api/createApi.ts +0 -116
- package/src/api/error.ts +0 -17
- package/src/api/status.ts +0 -3
- package/src/api/utils/getAlert.ts +0 -75
- package/src/app_types.ts +0 -695
- package/src/components/ApiHostProvider.tsx +0 -13
- package/src/components/StatusTag.tsx +0 -83
- package/src/components/Table/DataTableWrapper.tsx +0 -28
- package/src/components/Table/FloatingActions.tsx +0 -152
- package/src/components/Table/Spinner.tsx +0 -35
- package/src/components/Table/Summary.tsx +0 -18
- package/src/components/Table/Table.tsx +0 -474
- package/src/components/Table/addIndexToObject.ts +0 -6
- package/src/components/Table/areProvidedColumnsDifferent.ts +0 -26
- package/src/components/Table/clicked.js +0 -12
- package/src/components/Table/displayActions.tsx +0 -19
- package/src/components/Table/hooks/useFetchPage.tsx +0 -83
- package/src/components/Table/hooks/useGetCellRenderer.tsx +0 -197
- package/src/components/Table/hooks/useGetColumnsWithCheckbox.tsx +0 -34
- package/src/components/Table/hooks/useGetDeleteRow.tsx +0 -37
- package/src/components/Table/hooks/useGetResizeColumn.ts +0 -33
- package/src/components/Table/hooks/useGetRowCheckbox.tsx +0 -25
- package/src/components/Table/hooks/useLoadDataSource.ts +0 -24
- package/src/components/Table/hooks/usePageSize.tsx +0 -20
- package/src/components/Table/hooks/useRenderRowActions.tsx +0 -45
- package/src/components/Table/hooks/useResizeColumns.ts +0 -61
- package/src/components/Table/index.ts +0 -1
- package/src/components/Table/providers/OrderProvider.tsx +0 -20
- package/src/components/Table/styles.ts +0 -208
- package/src/config.ts +0 -7
- package/src/db_types.ts +0 -220
- package/src/hooks/useApi.ts +0 -43
- package/src/hooks/useEndpoint.ts +0 -35
- package/src/lib/jednostkaNazwa.ts +0 -6
- package/src/lib/typDokumentuNazwa.ts +0 -8
- package/src/utils/Query.ts +0 -30
- package/src/utils/getWZNumber.ts +0 -13
- package/src/utils/getZamowienieDokumentNumber.ts +0 -11
- package/tsconfig.json +0 -25
- package/tsconfig.tsbuildinfo +0 -1
- /package/{src/api/utils/index.ts → dist/api/utils/index.d.ts} +0 -0
- /package/{src/components/index.ts → dist/components/index.d.ts} +0 -0
- /package/{src/hooks/index.ts → dist/hooks/index.d.ts} +0 -0
- /package/{src/index.ts → dist/index.d.ts} +0 -0
- /package/{src/lib/index.ts → dist/lib/index.d.ts} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DataRow, Order } from '../app_types';
|
|
2
|
+
import { createApi } from './createApi';
|
|
3
|
+
type QueryType<T> = {
|
|
4
|
+
page?: number;
|
|
5
|
+
records?: number;
|
|
6
|
+
fields?: (keyof T)[];
|
|
7
|
+
order?: Order[];
|
|
8
|
+
} & Record<string, unknown>;
|
|
9
|
+
export type RequestOptions<T> = {
|
|
10
|
+
token?: string;
|
|
11
|
+
id?: number | string;
|
|
12
|
+
noId?: boolean;
|
|
13
|
+
query?: QueryType<T>;
|
|
14
|
+
};
|
|
15
|
+
export type RequestData = Record<string, unknown>;
|
|
16
|
+
export type ApiResponse<RowType = DataRow> = {
|
|
17
|
+
[key in keyof ReturnType<typeof createApi>]: RowType;
|
|
18
|
+
} & {
|
|
19
|
+
total: number;
|
|
20
|
+
};
|
|
21
|
+
export default class Api {
|
|
22
|
+
host: string;
|
|
23
|
+
namespace: string;
|
|
24
|
+
endpoint: string;
|
|
25
|
+
private endpointUrl;
|
|
26
|
+
constructor(endpoint: string, host?: string);
|
|
27
|
+
get<DataType>(opts?: RequestOptions<DataType extends any[] ? DataType[0] : DataType>): Promise<any>;
|
|
28
|
+
post<T, ResponseType>(data?: T, opts?: RequestOptions<T>): Promise<ResponseType>;
|
|
29
|
+
put(id: number, data: RequestData, opts?: RequestOptions<{}>): Promise<ApiResponse>;
|
|
30
|
+
delete(id: number, opts?: RequestOptions<{}>): Promise<ApiResponse>;
|
|
31
|
+
private getQuery;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
package/dist/api/Api.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var utils_1 = require("../utils");
|
|
40
|
+
function handleResponse(res) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
+
var ok, url, headers, status, statusText, text;
|
|
43
|
+
return __generator(this, function (_a) {
|
|
44
|
+
switch (_a.label) {
|
|
45
|
+
case 0:
|
|
46
|
+
if (res.status === 204)
|
|
47
|
+
return [2 /*return*/, {}];
|
|
48
|
+
if (res.status.toString().startsWith('2'))
|
|
49
|
+
return [2 /*return*/, res.json()];
|
|
50
|
+
ok = res.ok, url = res.url, headers = res.headers, status = res.status, statusText = res.statusText;
|
|
51
|
+
return [4 /*yield*/, res.text()];
|
|
52
|
+
case 1:
|
|
53
|
+
text = _a.sent();
|
|
54
|
+
throw new Error(JSON.stringify({
|
|
55
|
+
ok: ok,
|
|
56
|
+
url: url,
|
|
57
|
+
headers: headers,
|
|
58
|
+
status: status,
|
|
59
|
+
statusText: statusText,
|
|
60
|
+
text: text,
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
var Api = /** @class */ (function () {
|
|
67
|
+
function Api(endpoint, host) {
|
|
68
|
+
this.host = host;
|
|
69
|
+
this.namespace = '';
|
|
70
|
+
this.endpoint = endpoint;
|
|
71
|
+
this.endpointUrl = "".concat(this.host).concat(this.namespace, "/").concat(this.endpoint);
|
|
72
|
+
}
|
|
73
|
+
Api.prototype.get = function () {
|
|
74
|
+
return __awaiter(this, arguments, void 0, function (opts) {
|
|
75
|
+
var headers, options, url;
|
|
76
|
+
if (opts === void 0) { opts = {}; }
|
|
77
|
+
return __generator(this, function (_a) {
|
|
78
|
+
headers = new Headers();
|
|
79
|
+
if (opts.token)
|
|
80
|
+
headers.append('Authorization', "Bearer ".concat(opts.token));
|
|
81
|
+
options = {
|
|
82
|
+
credentials: 'include',
|
|
83
|
+
headers: headers,
|
|
84
|
+
};
|
|
85
|
+
url = "".concat(this.endpointUrl, "/").concat(opts.id || '').concat(this.getQuery(opts.query));
|
|
86
|
+
return [2 /*return*/, fetch(url, options).then(handleResponse)];
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
Api.prototype.post = function (data_1) {
|
|
91
|
+
return __awaiter(this, arguments, void 0, function (data, opts) {
|
|
92
|
+
var headers, body, url;
|
|
93
|
+
if (opts === void 0) { opts = {}; }
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
headers = new Headers();
|
|
96
|
+
body = JSON.stringify(data);
|
|
97
|
+
headers.append('Content-Type', 'application/json');
|
|
98
|
+
if (opts.token)
|
|
99
|
+
headers.append('Authorization', "Bearer ".concat(opts.token));
|
|
100
|
+
url = "".concat(this.endpointUrl).concat(this.getQuery(opts.query));
|
|
101
|
+
return [2 /*return*/, fetch(url, {
|
|
102
|
+
method: 'POST',
|
|
103
|
+
body: body,
|
|
104
|
+
headers: headers,
|
|
105
|
+
credentials: 'include',
|
|
106
|
+
}).then(handleResponse)];
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
Api.prototype.put = function (id_1, data_1) {
|
|
111
|
+
return __awaiter(this, arguments, void 0, function (id, data, opts) {
|
|
112
|
+
var body, headers, url;
|
|
113
|
+
if (opts === void 0) { opts = {}; }
|
|
114
|
+
return __generator(this, function (_a) {
|
|
115
|
+
body = JSON.stringify(data);
|
|
116
|
+
headers = new Headers();
|
|
117
|
+
headers.append('Content-Type', 'application/json');
|
|
118
|
+
if (opts.token)
|
|
119
|
+
headers.append('Authorization', "Bearer ".concat(opts.token));
|
|
120
|
+
url = "".concat(this.endpointUrl).concat(opts.noId ? '' : '/').concat(id || '').concat(this.getQuery(opts.query));
|
|
121
|
+
return [2 /*return*/, fetch(url, {
|
|
122
|
+
method: 'PUT',
|
|
123
|
+
body: body,
|
|
124
|
+
headers: headers,
|
|
125
|
+
credentials: 'include',
|
|
126
|
+
}).then(handleResponse)];
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
Api.prototype.delete = function (id_1) {
|
|
131
|
+
return __awaiter(this, arguments, void 0, function (id, opts) {
|
|
132
|
+
var headers, url;
|
|
133
|
+
if (opts === void 0) { opts = {}; }
|
|
134
|
+
return __generator(this, function (_a) {
|
|
135
|
+
headers = new Headers();
|
|
136
|
+
if (opts.token)
|
|
137
|
+
headers.append('Authorization', "Bearer ".concat(opts.token));
|
|
138
|
+
url = "".concat(this.endpointUrl, "/").concat(id).concat(this.getQuery(opts.query));
|
|
139
|
+
return [2 /*return*/, fetch(url, {
|
|
140
|
+
headers: headers,
|
|
141
|
+
method: 'DELETE',
|
|
142
|
+
credentials: 'include',
|
|
143
|
+
}).then(handleResponse)];
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
Api.prototype.getQuery = function (query) {
|
|
148
|
+
return query ? "?".concat(new URLSearchParams(utils_1.Query.encode(query)).toString()) : '';
|
|
149
|
+
};
|
|
150
|
+
return Api;
|
|
151
|
+
}());
|
|
152
|
+
exports.default = Api;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Api, { ApiResponse, RequestData, RequestOptions } from './Api';
|
|
2
|
+
type CallbackFunction<T> = (reason: unknown) => any;
|
|
3
|
+
export default class Endpoint<GetResponseElement> extends Api {
|
|
4
|
+
endpoint: string;
|
|
5
|
+
errorCallback?: CallbackFunction<any>;
|
|
6
|
+
constructor(endpoint: string, host?: string, errorCallback?: (reason: unknown) => ApiResponse<any>);
|
|
7
|
+
get<DataType = GetResponseElement>(opts?: RequestOptions<DataType extends any[] ? DataType[0] : DataType>): Promise<DataType extends any[] ? ApiResponse<DataType> : DataType>;
|
|
8
|
+
post<T = RequestData, ResponseType = T>(data?: T, opts?: RequestOptions<T>): Promise<ResponseType>;
|
|
9
|
+
put(id: number, data: RequestData, opts?: RequestOptions<{}>): Promise<ApiResponse>;
|
|
10
|
+
delete(id: number, opts?: RequestOptions<{}>): Promise<ApiResponse>;
|
|
11
|
+
toJSON(proto: Record<string, unknown>): Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
|
+
};
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
var Api_1 = __importDefault(require("./Api"));
|
|
58
|
+
var Endpoint = /** @class */ (function (_super) {
|
|
59
|
+
__extends(Endpoint, _super);
|
|
60
|
+
function Endpoint(endpoint, host, errorCallback) {
|
|
61
|
+
if (host === void 0) { host = ''; }
|
|
62
|
+
var _this = _super.call(this, endpoint, host) || this;
|
|
63
|
+
_this.endpoint = endpoint;
|
|
64
|
+
_this.errorCallback = errorCallback;
|
|
65
|
+
return _this;
|
|
66
|
+
}
|
|
67
|
+
Endpoint.prototype.get = function (opts) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
return [2 /*return*/, _super.prototype.get.call(this, opts).catch(this.errorCallback)];
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
Endpoint.prototype.post = function (data, opts) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
return [2 /*return*/, _super.prototype.post.call(this, data, opts)];
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
Endpoint.prototype.put = function (id, data, opts) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
+
return __generator(this, function (_a) {
|
|
84
|
+
return [2 /*return*/, _super.prototype.put.call(this, id, data, opts)];
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
Endpoint.prototype.delete = function (id, opts) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
return [2 /*return*/, _super.prototype.delete.call(this, id, opts)];
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
Endpoint.prototype.toJSON = function (proto) {
|
|
96
|
+
var jsoned = {};
|
|
97
|
+
var toConvert = proto || this;
|
|
98
|
+
Object.getOwnPropertyNames(toConvert).forEach(function (prop) {
|
|
99
|
+
var val = toConvert[prop];
|
|
100
|
+
// don't include those
|
|
101
|
+
if (prop === 'toJSON' || prop === 'constructor') {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (typeof val === 'function') {
|
|
105
|
+
jsoned[prop] = val.bind(jsoned);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
jsoned[prop] = val;
|
|
109
|
+
});
|
|
110
|
+
var inherited = Object.getPrototypeOf(toConvert);
|
|
111
|
+
if (inherited !== null) {
|
|
112
|
+
Object.keys(this.toJSON(inherited)).forEach(function (key) {
|
|
113
|
+
if (!!jsoned[key] || key === 'constructor' || key === 'toJSON')
|
|
114
|
+
return;
|
|
115
|
+
if (typeof inherited[key] === 'function') {
|
|
116
|
+
jsoned[key] = inherited[key].bind(jsoned);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
jsoned[key] = inherited[key];
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return jsoned;
|
|
123
|
+
};
|
|
124
|
+
return Endpoint;
|
|
125
|
+
}(Api_1.default));
|
|
126
|
+
exports.default = Endpoint;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Bufor, BuforInfoResponse, Klient, KlientKategoria, KlientRabat, KlientZamowienie, LoginResponse, NoweZamowienieAtrybutKonfigResponse, RownanieZmienna, RownanieZmiennaKategoria, Wplata, WplataZamowienieDokument, ZaliczkaZamowienieDokument, Zamowienie, ZamowienieInfoResponse, ZamowienieNowyDokumentElement, ZamowienieNowyDokumentRequest } from '../app_types';
|
|
2
|
+
import { ZamowienieDokumentAttributes, ZamowienieDokumentElementAttributes, ZamowienieDokumentMagazynAttributes } from '../db_types';
|
|
3
|
+
import Endpoint from './Endpoint';
|
|
4
|
+
import * as error from './error';
|
|
5
|
+
import * as hooks from '../hooks';
|
|
6
|
+
import * as status from './status';
|
|
7
|
+
import * as utils from './utils';
|
|
8
|
+
export { status, error, utils, hooks };
|
|
9
|
+
export declare const createApi: (host: string) => {
|
|
10
|
+
atrybut_konfig: Endpoint<unknown>;
|
|
11
|
+
bufor: Endpoint<Bufor>;
|
|
12
|
+
bufor_element: Endpoint<unknown>;
|
|
13
|
+
bufor_element_atrybut: Endpoint<unknown>;
|
|
14
|
+
buforinfo: Endpoint<BuforInfoResponse>;
|
|
15
|
+
cecha_wartosc: Endpoint<unknown>;
|
|
16
|
+
get_set_param_number: Endpoint<unknown>;
|
|
17
|
+
klient: Endpoint<Klient>;
|
|
18
|
+
klient_kategoria: Endpoint<KlientKategoria>;
|
|
19
|
+
klient_rabat: Endpoint<KlientRabat[]>;
|
|
20
|
+
klient_zamowienie: Endpoint<KlientZamowienie>;
|
|
21
|
+
login: Endpoint<LoginResponse>;
|
|
22
|
+
logout: Endpoint<unknown>;
|
|
23
|
+
web_login: Endpoint<unknown>;
|
|
24
|
+
web_logout: Endpoint<unknown>;
|
|
25
|
+
nowe_zamowienie_cecha_wartosc: Endpoint<unknown>;
|
|
26
|
+
nowe_zamowienie_towar: Endpoint<unknown>;
|
|
27
|
+
nowe_zamowienie_towar_atrybut: Endpoint<unknown>;
|
|
28
|
+
nowe_zamowienie_towar_atrybut2: Endpoint<unknown>;
|
|
29
|
+
nowe_zamowienie_towar_kategoria: Endpoint<unknown>;
|
|
30
|
+
nowe_zamowienie_towar_cecha_wartosc_pre: Endpoint<unknown>;
|
|
31
|
+
nowe_zamowienie_atrybut_konfig: Endpoint<{
|
|
32
|
+
atrybut_konfig: NoweZamowienieAtrybutKonfigResponse[];
|
|
33
|
+
}>;
|
|
34
|
+
rownanie: Endpoint<unknown>;
|
|
35
|
+
rownanie_zmienna: Endpoint<RownanieZmienna>;
|
|
36
|
+
rownanie_zmienna_kategoria: Endpoint<RownanieZmiennaKategoria>;
|
|
37
|
+
rownanie_js: Endpoint<unknown>;
|
|
38
|
+
towar: Endpoint<unknown>;
|
|
39
|
+
towar_atrybut: Endpoint<unknown>;
|
|
40
|
+
towar_kategoria: Endpoint<unknown>;
|
|
41
|
+
towar_cecha_wartosc_pre: Endpoint<unknown>;
|
|
42
|
+
wplata: Endpoint<Wplata>;
|
|
43
|
+
wplata_zamowienie_dokument: Endpoint<WplataZamowienieDokument[]>;
|
|
44
|
+
zamowienie: Endpoint<Zamowienie>;
|
|
45
|
+
zamowienie_dokument: Endpoint<ZamowienieDokumentAttributes>;
|
|
46
|
+
zamowienieinfo: Endpoint<ZamowienieInfoResponse>;
|
|
47
|
+
zaliczka_zamowienie_dokument: Endpoint<ZaliczkaZamowienieDokument[]>;
|
|
48
|
+
zamowienie_nowy_dokument_element: Endpoint<ZamowienieNowyDokumentElement[]>;
|
|
49
|
+
zamowienie_nowy_dokument: Endpoint<ZamowienieNowyDokumentRequest>;
|
|
50
|
+
zamowienie_dokument_element: Endpoint<ZamowienieDokumentElementAttributes>;
|
|
51
|
+
zamowienie_dokument_magazyn: Endpoint<ZamowienieDokumentMagazynAttributes>;
|
|
52
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.createApi = exports.hooks = exports.utils = exports.error = exports.status = void 0;
|
|
30
|
+
var Endpoint_1 = __importDefault(require("./Endpoint"));
|
|
31
|
+
var error = __importStar(require("./error"));
|
|
32
|
+
exports.error = error;
|
|
33
|
+
var hooks = __importStar(require("../hooks"));
|
|
34
|
+
exports.hooks = hooks;
|
|
35
|
+
var status = __importStar(require("./status"));
|
|
36
|
+
exports.status = status;
|
|
37
|
+
var utils = __importStar(require("./utils"));
|
|
38
|
+
exports.utils = utils;
|
|
39
|
+
var createApi = function (host) { return ({
|
|
40
|
+
atrybut_konfig: new Endpoint_1.default('atrybut_konfig', host),
|
|
41
|
+
bufor: new Endpoint_1.default('bufor', host),
|
|
42
|
+
bufor_element: new Endpoint_1.default('bufor_element', host),
|
|
43
|
+
bufor_element_atrybut: new Endpoint_1.default('bufor_element_atrybut', host),
|
|
44
|
+
buforinfo: new Endpoint_1.default('buforinfo', host),
|
|
45
|
+
cecha_wartosc: new Endpoint_1.default('cecha_wartosc', host),
|
|
46
|
+
get_set_param_number: new Endpoint_1.default('get_set_param_number', host),
|
|
47
|
+
klient: new Endpoint_1.default('klient', host),
|
|
48
|
+
klient_kategoria: new Endpoint_1.default('klient_kategoria', host),
|
|
49
|
+
klient_rabat: new Endpoint_1.default('klient_rabat', host),
|
|
50
|
+
klient_zamowienie: new Endpoint_1.default('klient_zamowienie', host),
|
|
51
|
+
login: new Endpoint_1.default('auth/login', host),
|
|
52
|
+
logout: new Endpoint_1.default('auth/logout', host),
|
|
53
|
+
web_login: new Endpoint_1.default('web_auth/login', host),
|
|
54
|
+
web_logout: new Endpoint_1.default('web_auth/logout', host),
|
|
55
|
+
nowe_zamowienie_cecha_wartosc: new Endpoint_1.default('nowe_zamowienie/cecha_wartosc', host),
|
|
56
|
+
nowe_zamowienie_towar: new Endpoint_1.default('nowe_zamowienie/towar', host),
|
|
57
|
+
nowe_zamowienie_towar_atrybut: new Endpoint_1.default('nowe_zamowienie/towar_atrybut', host),
|
|
58
|
+
nowe_zamowienie_towar_atrybut2: new Endpoint_1.default('nowe_zamowienie/towar_atrybut2', host),
|
|
59
|
+
nowe_zamowienie_towar_kategoria: new Endpoint_1.default('nowe_zamowienie/towar_kategoria', host),
|
|
60
|
+
nowe_zamowienie_towar_cecha_wartosc_pre: new Endpoint_1.default('nowe_zamowienie/towar_cecha_wartosc_pre', host),
|
|
61
|
+
nowe_zamowienie_atrybut_konfig: new Endpoint_1.default('nowe_zamowienie/atrybut_konfig', host),
|
|
62
|
+
rownanie: new Endpoint_1.default('rownanie', host),
|
|
63
|
+
rownanie_zmienna: new Endpoint_1.default('rownanie_zmienna', host),
|
|
64
|
+
rownanie_zmienna_kategoria: new Endpoint_1.default('rownanie_zmienna_kategoria', host),
|
|
65
|
+
rownanie_js: new Endpoint_1.default('rownanie/js', host),
|
|
66
|
+
towar: new Endpoint_1.default('towar', host),
|
|
67
|
+
towar_atrybut: new Endpoint_1.default('towar_atrybut', host),
|
|
68
|
+
towar_kategoria: new Endpoint_1.default('towar_kategoria', host),
|
|
69
|
+
towar_cecha_wartosc_pre: new Endpoint_1.default('towar_cecha_wartosc_pre', host),
|
|
70
|
+
wplata: new Endpoint_1.default('wplata', host),
|
|
71
|
+
wplata_zamowienie_dokument: new Endpoint_1.default('wplata_zamowienie_dokument', host),
|
|
72
|
+
zamowienie: new Endpoint_1.default('zamowienie', host),
|
|
73
|
+
zamowienie_dokument: new Endpoint_1.default('zamowienie_dokument', host),
|
|
74
|
+
zamowienieinfo: new Endpoint_1.default('zamowienieinfo', host),
|
|
75
|
+
zaliczka_zamowienie_dokument: new Endpoint_1.default('zaliczka_zamowienie_dokument', host),
|
|
76
|
+
zamowienie_nowy_dokument_element: new Endpoint_1.default('zamowienie_nowy_dokument_element', host),
|
|
77
|
+
zamowienie_nowy_dokument: new Endpoint_1.default('zamowienie_nowy_dokument', host),
|
|
78
|
+
zamowienie_dokument_element: new Endpoint_1.default('zamowienie_dokument_element', host),
|
|
79
|
+
zamowienie_dokument_magazyn: new Endpoint_1.default('zamowienie_dokument_magazyn', host),
|
|
80
|
+
}); };
|
|
81
|
+
exports.createApi = createApi;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const NOT_FOUND = "not_found";
|
|
2
|
+
export declare const INVALID_DATA = "invalid_data";
|
|
3
|
+
export declare const INVALID_REQUEST = "invalid_request";
|
|
4
|
+
export declare const UNAUTHORIZED = "unauthorized";
|
|
5
|
+
export declare const ALREADY_EXISTS = "already_exists";
|
|
6
|
+
export declare const FAILED_TO_FETCH = "Failed to fetch";
|
|
7
|
+
export declare const field: {
|
|
8
|
+
NEW_PASSWORD: string;
|
|
9
|
+
OLD_PASSWORD: string;
|
|
10
|
+
EMAIL: string;
|
|
11
|
+
LAST_NAME: string;
|
|
12
|
+
FIRST_NAME: string;
|
|
13
|
+
COMPANY: string;
|
|
14
|
+
PHONE: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.field = exports.FAILED_TO_FETCH = exports.ALREADY_EXISTS = exports.UNAUTHORIZED = exports.INVALID_REQUEST = exports.INVALID_DATA = exports.NOT_FOUND = void 0;
|
|
4
|
+
exports.NOT_FOUND = 'not_found';
|
|
5
|
+
exports.INVALID_DATA = 'invalid_data';
|
|
6
|
+
exports.INVALID_REQUEST = 'invalid_request';
|
|
7
|
+
exports.UNAUTHORIZED = 'unauthorized';
|
|
8
|
+
exports.ALREADY_EXISTS = 'already_exists';
|
|
9
|
+
exports.FAILED_TO_FETCH = 'Failed to fetch';
|
|
10
|
+
exports.field = {
|
|
11
|
+
NEW_PASSWORD: 'new_password',
|
|
12
|
+
OLD_PASSWORD: 'old_password',
|
|
13
|
+
EMAIL: 'email',
|
|
14
|
+
LAST_NAME: 'surname',
|
|
15
|
+
FIRST_NAME: 'name',
|
|
16
|
+
COMPANY: 'company_name',
|
|
17
|
+
PHONE: 'phone_number',
|
|
18
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.hooks = exports.utils = exports.error = exports.status = void 0;
|
|
27
|
+
var error = __importStar(require("./error"));
|
|
28
|
+
exports.error = error;
|
|
29
|
+
var hooks = __importStar(require("../hooks"));
|
|
30
|
+
exports.hooks = hooks;
|
|
31
|
+
var status = __importStar(require("./status"));
|
|
32
|
+
exports.status = status;
|
|
33
|
+
var utils = __importStar(require("./utils"));
|
|
34
|
+
exports.utils = utils;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ALREADY_LOGGED_IN = exports.INVALID_PASSWORD = exports.OK = void 0;
|
|
4
|
+
exports.OK = 'ok';
|
|
5
|
+
exports.INVALID_PASSWORD = 'invalid_password';
|
|
6
|
+
exports.ALREADY_LOGGED_IN = 'already_logged_in';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = getAlert;
|
|
4
|
+
var error_1 = require("../error");
|
|
5
|
+
var status_1 = require("../status");
|
|
6
|
+
var severity = {
|
|
7
|
+
SUCCESS: "success",
|
|
8
|
+
ERROR: "error",
|
|
9
|
+
WARNING: "warning",
|
|
10
|
+
INFO: "info",
|
|
11
|
+
};
|
|
12
|
+
var createAlert = function (severity, message) { return ({
|
|
13
|
+
severity: severity,
|
|
14
|
+
message: message,
|
|
15
|
+
}); };
|
|
16
|
+
function getAlert(status) {
|
|
17
|
+
try {
|
|
18
|
+
var error = JSON.parse(status);
|
|
19
|
+
switch (error.error) {
|
|
20
|
+
case error_1.INVALID_DATA:
|
|
21
|
+
switch (error.field) {
|
|
22
|
+
case error_1.field.EMAIL:
|
|
23
|
+
return createAlert(severity.ERROR, "Błędny email");
|
|
24
|
+
case error_1.field.FIRST_NAME:
|
|
25
|
+
return createAlert(severity.ERROR, "Błędne imię");
|
|
26
|
+
case error_1.field.LAST_NAME:
|
|
27
|
+
return createAlert(severity.ERROR, "Błędne nazwisko");
|
|
28
|
+
case error_1.field.PHONE:
|
|
29
|
+
return createAlert(severity.ERROR, "Błędny numer telefonu");
|
|
30
|
+
case error_1.field.COMPANY:
|
|
31
|
+
return createAlert(severity.ERROR, "Błędna nazwa firmy");
|
|
32
|
+
default:
|
|
33
|
+
return createAlert(severity.ERROR, error.error);
|
|
34
|
+
}
|
|
35
|
+
default:
|
|
36
|
+
return createAlert(severity.ERROR, error.error);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
switch (status) {
|
|
41
|
+
case status_1.OK:
|
|
42
|
+
return createAlert(severity.SUCCESS, "Sukces!");
|
|
43
|
+
case status_1.INVALID_PASSWORD:
|
|
44
|
+
return createAlert(severity.ERROR, "Błędne hasło lub email!");
|
|
45
|
+
case status_1.ALREADY_LOGGED_IN:
|
|
46
|
+
return createAlert(severity.ERROR, "Jesteś już zalogowany!");
|
|
47
|
+
case error_1.FAILED_TO_FETCH:
|
|
48
|
+
return createAlert(severity.ERROR, "Wystąpił błąd!");
|
|
49
|
+
case error_1.INVALID_REQUEST:
|
|
50
|
+
return createAlert(severity.ERROR, "Błąd zapytania!");
|
|
51
|
+
case error_1.UNAUTHORIZED:
|
|
52
|
+
return createAlert(severity.ERROR, "Błąd autoryzacji!");
|
|
53
|
+
case error_1.field.NEW_PASSWORD:
|
|
54
|
+
return createAlert(severity.ERROR, "Nowe hasło jest zbyt słabe!");
|
|
55
|
+
case error_1.field.OLD_PASSWORD:
|
|
56
|
+
return createAlert(severity.ERROR, "Stare hasło jest nieprawidłowe!");
|
|
57
|
+
case "name_empty":
|
|
58
|
+
return createAlert(severity.ERROR, "Nazwa jest pusta!");
|
|
59
|
+
case "name_taken":
|
|
60
|
+
return createAlert(severity.ERROR, "Nazwa jest zajęta!");
|
|
61
|
+
default:
|
|
62
|
+
return createAlert(severity.ERROR, status);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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.getAlert = void 0;
|
|
7
|
+
var getAlert_1 = require("./getAlert");
|
|
8
|
+
Object.defineProperty(exports, "getAlert", { enumerable: true, get: function () { return __importDefault(getAlert_1).default; } });
|