asv-hlps 1.2.22 → 1.2.25
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/lib/cjs/index.d.ts +5 -3
- package/lib/cjs/index.js +5 -3
- package/lib/cjs/models/entities/users/SteGrp.d.ts +4 -4
- package/lib/cjs/models/entities/users/UserAbs.d.ts +1 -1
- package/lib/cjs/{typeorm.d.ts → npms/typeorm.d.ts} +0 -0
- package/lib/cjs/{typeorm.js → npms/typeorm.js} +0 -0
- package/lib/cjs/npms/yup.d.ts +47 -0
- package/lib/cjs/npms/yup.js +158 -0
- package/lib/cjs/utils.d.ts +12 -0
- package/lib/cjs/utils.js +41 -1
- package/lib/esm/index.d.ts +5 -3
- package/lib/esm/index.js +5 -3
- package/lib/esm/models/entities/users/SteGrp.d.ts +4 -4
- package/lib/esm/models/entities/users/UserAbs.d.ts +1 -1
- package/lib/esm/{typeorm.d.ts → npms/typeorm.d.ts} +0 -0
- package/lib/esm/{typeorm.js → npms/typeorm.js} +0 -0
- package/lib/esm/npms/yup.d.ts +47 -0
- package/lib/esm/npms/yup.js +119 -0
- package/lib/esm/utils.d.ts +12 -0
- package/lib/esm/utils.js +34 -0
- package/package.json +3 -2
- package/lib/cjs/models/entities/estates/Estate.d.ts +0 -24
- package/lib/cjs/models/entities/estates/Estate.js +0 -2
- package/lib/cjs/models/entities/estates/EstateAsset.d.ts +0 -7
- package/lib/cjs/models/entities/estates/EstateAsset.js +0 -2
- package/lib/cjs/models/entities/estates/EstateCat.d.ts +0 -3
- package/lib/cjs/models/entities/estates/EstateCat.js +0 -2
- package/lib/cjs/models/entities/estates/EstateElt.d.ts +0 -3
- package/lib/cjs/models/entities/estates/EstateElt.js +0 -2
- package/lib/cjs/models/entities/estates/EstateLevel.d.ts +0 -3
- package/lib/cjs/models/entities/estates/EstateLevel.js +0 -2
- package/lib/cjs/models/entities/estates/EstatePor.d.ts +0 -3
- package/lib/cjs/models/entities/estates/EstatePor.js +0 -2
- package/lib/cjs/models/entities/estates/Housing.d.ts +0 -17
- package/lib/cjs/models/entities/estates/Housing.js +0 -2
- package/lib/cjs/models/entities/estates/HousingRented.d.ts +0 -15
- package/lib/cjs/models/entities/estates/HousingRented.js +0 -2
- package/lib/cjs/models/entities/estates/index.d.ts +0 -9
- package/lib/cjs/models/entities/estates/index.js +0 -2
- package/lib/esm/models/entities/estates/Estate.d.ts +0 -24
- package/lib/esm/models/entities/estates/Estate.js +0 -1
- package/lib/esm/models/entities/estates/EstateAsset.d.ts +0 -7
- package/lib/esm/models/entities/estates/EstateAsset.js +0 -1
- package/lib/esm/models/entities/estates/EstateCat.d.ts +0 -3
- package/lib/esm/models/entities/estates/EstateCat.js +0 -1
- package/lib/esm/models/entities/estates/EstateElt.d.ts +0 -3
- package/lib/esm/models/entities/estates/EstateElt.js +0 -1
- package/lib/esm/models/entities/estates/EstateLevel.d.ts +0 -3
- package/lib/esm/models/entities/estates/EstateLevel.js +0 -1
- package/lib/esm/models/entities/estates/EstatePor.d.ts +0 -3
- package/lib/esm/models/entities/estates/EstatePor.js +0 -1
- package/lib/esm/models/entities/estates/Housing.d.ts +0 -17
- package/lib/esm/models/entities/estates/Housing.js +0 -1
- package/lib/esm/models/entities/estates/HousingRented.d.ts +0 -15
- package/lib/esm/models/entities/estates/HousingRented.js +0 -1
- package/lib/esm/models/entities/estates/index.d.ts +0 -9
- package/lib/esm/models/entities/estates/index.js +0 -1
package/lib/cjs/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ import "./auth";
|
|
|
9
9
|
import "./bill";
|
|
10
10
|
import "./bootstrap";
|
|
11
11
|
import "./models/index";
|
|
12
|
+
import "./npms/typeorm";
|
|
13
|
+
import "./npms/yup";
|
|
12
14
|
import "./pdfs/invoices/amountInvoice";
|
|
13
15
|
import "./pdfs/invoices/infoInvoice";
|
|
14
16
|
import "./pdfs/tools/tools";
|
|
@@ -16,21 +18,21 @@ import "./product";
|
|
|
16
18
|
import "./react-utils";
|
|
17
19
|
import "./sale";
|
|
18
20
|
import "./services/authService";
|
|
19
|
-
import "./typeorm";
|
|
20
21
|
import "./user";
|
|
21
22
|
import "./utils";
|
|
22
23
|
export * from "./auth";
|
|
23
24
|
export * from "./bill";
|
|
24
25
|
export * from "./bootstrap";
|
|
26
|
+
export * from "./core/estates/index";
|
|
25
27
|
export * from "./models/index";
|
|
28
|
+
export * from "./npms/typeorm";
|
|
29
|
+
export * from "./npms/yup";
|
|
26
30
|
export * from "./pdfs/invoices/amountInvoice";
|
|
27
31
|
export * from "./pdfs/invoices/infoInvoice";
|
|
28
32
|
export * from "./pdfs/tools/tools";
|
|
29
33
|
export * from "./product";
|
|
30
34
|
export * from "./react-utils";
|
|
31
35
|
export * from "./sale";
|
|
32
|
-
export * from "./typeorm";
|
|
33
36
|
export * from "./user";
|
|
34
37
|
export * from "./utils";
|
|
35
|
-
export * from "./core/estates/index";
|
|
36
38
|
export { AuthService, StorageService, HlpProduct, HlpEntry, StockPipe, AmountOnListBillPipe, AmountOnBillPipe };
|
package/lib/cjs/index.js
CHANGED
|
@@ -39,6 +39,8 @@ require("./bootstrap");
|
|
|
39
39
|
// import "./models/entities/users";
|
|
40
40
|
// import "./models/entities/users/index";
|
|
41
41
|
require("./models/index");
|
|
42
|
+
require("./npms/typeorm");
|
|
43
|
+
require("./npms/yup");
|
|
42
44
|
require("./pdfs/invoices/amountInvoice");
|
|
43
45
|
require("./pdfs/invoices/infoInvoice");
|
|
44
46
|
require("./pdfs/tools/tools");
|
|
@@ -46,20 +48,20 @@ require("./product");
|
|
|
46
48
|
require("./react-utils");
|
|
47
49
|
require("./sale");
|
|
48
50
|
require("./services/authService");
|
|
49
|
-
require("./typeorm");
|
|
50
51
|
require("./user");
|
|
51
52
|
require("./utils");
|
|
52
53
|
__exportStar(require("./auth"), exports);
|
|
53
54
|
__exportStar(require("./bill"), exports);
|
|
54
55
|
__exportStar(require("./bootstrap"), exports);
|
|
56
|
+
__exportStar(require("./core/estates/index"), exports);
|
|
55
57
|
__exportStar(require("./models/index"), exports);
|
|
58
|
+
__exportStar(require("./npms/typeorm"), exports);
|
|
59
|
+
__exportStar(require("./npms/yup"), exports);
|
|
56
60
|
__exportStar(require("./pdfs/invoices/amountInvoice"), exports);
|
|
57
61
|
__exportStar(require("./pdfs/invoices/infoInvoice"), exports);
|
|
58
62
|
__exportStar(require("./pdfs/tools/tools"), exports);
|
|
59
63
|
__exportStar(require("./product"), exports);
|
|
60
64
|
__exportStar(require("./react-utils"), exports);
|
|
61
65
|
__exportStar(require("./sale"), exports);
|
|
62
|
-
__exportStar(require("./typeorm"), exports);
|
|
63
66
|
__exportStar(require("./user"), exports);
|
|
64
67
|
__exportStar(require("./utils"), exports);
|
|
65
|
-
__exportStar(require("./core/estates/index"), exports);
|
|
@@ -6,7 +6,7 @@ import { UserGrp } from "./UserGrp";
|
|
|
6
6
|
import { UserRole } from "./UserRole";
|
|
7
7
|
import { UserTitr } from "./UserTitr";
|
|
8
8
|
export interface UserAbs extends Address {
|
|
9
|
-
id
|
|
9
|
+
id?: number;
|
|
10
10
|
codeCompta?: string | number;
|
|
11
11
|
firstname?: string;
|
|
12
12
|
lastname?: string;
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as yup from "yup";
|
|
2
|
+
export declare const schemaNaCoSh: (url: string, tob: any, codeMaxLenth?: number) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
4
|
+
code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
5
|
+
shortname: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
6
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
7
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
8
|
+
code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
9
|
+
shortname: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
10
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
11
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
12
|
+
code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
13
|
+
shortname: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
14
|
+
}>>>;
|
|
15
|
+
export declare const schemaNaCo: (url: string, tob: any, codeMaxLenth?: number) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
16
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
17
|
+
code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
18
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
19
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
20
|
+
code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
21
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
22
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
23
|
+
code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
24
|
+
}>>>;
|
|
25
|
+
export declare const schemaNa: (url: string, tob: any) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
26
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
27
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
28
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
29
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
30
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
31
|
+
}>>>;
|
|
32
|
+
export declare const schemaLogin: () => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
33
|
+
username: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
34
|
+
password: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
35
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
36
|
+
username: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
37
|
+
password: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
38
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
39
|
+
username: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
40
|
+
password: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
41
|
+
}>>>;
|
|
42
|
+
export declare const yupValideUniqName: (url: string, tob: any) => import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
43
|
+
export declare const yupValideUniqEmail: (url: string, tob: any, isRequired?: boolean) => yup.StringSchema<string, import("yup/lib/types").AnyObject, string>;
|
|
44
|
+
export declare const yupValideUniqNumber: (url: string, tob: any, isRequired?: boolean) => yup.NumberSchema<number, import("yup/lib/types").AnyObject, number>;
|
|
45
|
+
export declare const yupValideUniqCode: (url: string, max: number, tob: any) => import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
46
|
+
export declare const yupValidateNoRequiredNumber: () => yup.StringSchema<string, import("yup/lib/types").AnyObject, string>;
|
|
47
|
+
export declare const formatSelectOptions: (objs: any[], propLabel?: string, propValue?: string) => any[];
|
|
@@ -0,0 +1,158 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.formatSelectOptions = exports.yupValidateNoRequiredNumber = exports.yupValideUniqCode = exports.yupValideUniqNumber = exports.yupValideUniqEmail = exports.yupValideUniqName = exports.schemaLogin = exports.schemaNa = exports.schemaNaCo = exports.schemaNaCoSh = void 0;
|
|
39
|
+
const axios_1 = __importDefault(require("axios"));
|
|
40
|
+
const yup = __importStar(require("yup"));
|
|
41
|
+
const schemaNaCoSh = (url, tob, codeMaxLenth = 4) => yup.object().shape({
|
|
42
|
+
name: (0, exports.yupValideUniqName)(url + "/checkUniqueName", tob),
|
|
43
|
+
code: (0, exports.yupValideUniqCode)(url + "/checkUniqueCode", codeMaxLenth, tob),
|
|
44
|
+
shortname: (0, exports.yupValideUniqName)(url + "/checkUniqueShortname", tob),
|
|
45
|
+
});
|
|
46
|
+
exports.schemaNaCoSh = schemaNaCoSh;
|
|
47
|
+
const schemaNaCo = (url, tob, codeMaxLenth = 4) => yup.object().shape({
|
|
48
|
+
name: (0, exports.yupValideUniqName)(url + "/checkUniqueName", tob),
|
|
49
|
+
code: (0, exports.yupValideUniqCode)(url + "/checkUniqueCode", codeMaxLenth, tob),
|
|
50
|
+
});
|
|
51
|
+
exports.schemaNaCo = schemaNaCo;
|
|
52
|
+
const schemaNa = (url, tob) => yup.object().shape({
|
|
53
|
+
name: (0, exports.yupValideUniqName)(url + "/checkUniqueName", tob),
|
|
54
|
+
});
|
|
55
|
+
exports.schemaNa = schemaNa;
|
|
56
|
+
const schemaLogin = () => yup.object().shape({
|
|
57
|
+
// email: yup.string().required(t("Please enter Email")),
|
|
58
|
+
username: yup.string().required("Please enter Email"),
|
|
59
|
+
password: yup.string().required("Please enter Password"),
|
|
60
|
+
// checkbox: yup.bool().oneOf([true]),
|
|
61
|
+
});
|
|
62
|
+
exports.schemaLogin = schemaLogin;
|
|
63
|
+
const yupValideUniqName = (url, tob) => {
|
|
64
|
+
return yup
|
|
65
|
+
.string()
|
|
66
|
+
.required()
|
|
67
|
+
.test("Check_name", "This name is already taken", (value) => {
|
|
68
|
+
return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
+
const { data: res } = yield axios_1.default.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
|
|
70
|
+
res ? resolve(true) : resolve(false);
|
|
71
|
+
}));
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
exports.yupValideUniqName = yupValideUniqName;
|
|
75
|
+
const yupValideUniqEmail = (url, tob, isRequired = true) => {
|
|
76
|
+
if (isRequired) {
|
|
77
|
+
return yup
|
|
78
|
+
.string()
|
|
79
|
+
.email("this value must be a valid email")
|
|
80
|
+
.required("this value is required")
|
|
81
|
+
.test("Check_name", "This name is already taken", (value) => {
|
|
82
|
+
return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
+
const { data: res } = yield axios_1.default.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
|
|
84
|
+
res ? resolve(true) : resolve(false);
|
|
85
|
+
}));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return yup.string().when((val) => {
|
|
89
|
+
if (val) {
|
|
90
|
+
return yup
|
|
91
|
+
.string()
|
|
92
|
+
.email()
|
|
93
|
+
.test("Check_name", "This name is already taken", (value) => {
|
|
94
|
+
return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
+
const { data: res } = yield axios_1.default.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
|
|
96
|
+
res ? resolve(true) : resolve(false);
|
|
97
|
+
}));
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
exports.yupValideUniqEmail = yupValideUniqEmail;
|
|
103
|
+
const yupValideUniqNumber = (url, tob, isRequired = true) => {
|
|
104
|
+
if (isRequired) {
|
|
105
|
+
return yup
|
|
106
|
+
.number()
|
|
107
|
+
.required()
|
|
108
|
+
.test("Check_name", "This name is already taken", (value) => {
|
|
109
|
+
return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
+
const { data: res } = yield axios_1.default.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
|
|
111
|
+
res ? resolve(true) : resolve(false);
|
|
112
|
+
}));
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return yup.number().test("Check_name", "This name is already taken", (value) => {
|
|
116
|
+
return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
|
+
const { data: res } = yield axios_1.default.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
|
|
118
|
+
res ? resolve(true) : resolve(false);
|
|
119
|
+
}));
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
exports.yupValideUniqNumber = yupValideUniqNumber;
|
|
123
|
+
const yupValideUniqCode = (url, max = 4, tob) => {
|
|
124
|
+
return yup
|
|
125
|
+
.string()
|
|
126
|
+
.required()
|
|
127
|
+
.min(2)
|
|
128
|
+
.max(max)
|
|
129
|
+
.test("Check_name", "This name is already taken", (value) => {
|
|
130
|
+
return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
|
|
131
|
+
const { data: res } = yield axios_1.default.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
|
|
132
|
+
res ? resolve(true) : resolve(false);
|
|
133
|
+
}));
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
exports.yupValideUniqCode = yupValideUniqCode;
|
|
137
|
+
const yupValidateNoRequiredNumber = () => {
|
|
138
|
+
return yup
|
|
139
|
+
.string()
|
|
140
|
+
.when((val) => {
|
|
141
|
+
if (val) {
|
|
142
|
+
return yup.number();
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
.typeError("must be number");
|
|
146
|
+
};
|
|
147
|
+
exports.yupValidateNoRequiredNumber = yupValidateNoRequiredNumber;
|
|
148
|
+
const formatSelectOptions = (objs, propLabel = "name", propValue = "id") => {
|
|
149
|
+
if (!objs.length) {
|
|
150
|
+
return objs;
|
|
151
|
+
}
|
|
152
|
+
let options = [];
|
|
153
|
+
for (const obj of objs) {
|
|
154
|
+
options.push({ value: obj[propValue], label: obj[propLabel] });
|
|
155
|
+
}
|
|
156
|
+
return options;
|
|
157
|
+
};
|
|
158
|
+
exports.formatSelectOptions = formatSelectOptions;
|
package/lib/cjs/utils.d.ts
CHANGED
|
@@ -64,6 +64,10 @@ export declare const packAndUnit: (qtity: number, qtityPerPackaging?: number) =>
|
|
|
64
64
|
export declare const convertToCfa: (price: number, currency?: string, dollarRate?: number) => number;
|
|
65
65
|
export declare const validEmail: (email: string) => boolean;
|
|
66
66
|
export declare const calculPercent: (nbr: number, percentage: number) => number;
|
|
67
|
+
export declare const formatMonthYearToLocaleString: (date: Date, prms?: {
|
|
68
|
+
localLanguage?: string;
|
|
69
|
+
minusOne?: boolean;
|
|
70
|
+
}) => string;
|
|
67
71
|
export declare const padStartWithZero: (num: any, targetLength: number) => any;
|
|
68
72
|
export declare const padEndWithZero: (num: any, targetLength: number) => any;
|
|
69
73
|
export declare const isBirthday: (birthDayDate: any) => boolean;
|
|
@@ -73,3 +77,11 @@ export declare const randomRgbColor: () => number[];
|
|
|
73
77
|
export declare const randomHexColor: () => string;
|
|
74
78
|
export declare const randomHslColor: () => number[];
|
|
75
79
|
export declare const getArrayOfRandomColor: (length: number, type?: "hex" | "rgb" | "hsl") => string[];
|
|
80
|
+
export declare const displayFrDatePeriode: (getFromDate?: any, getToDate?: any) => string;
|
|
81
|
+
export declare const returnDates: (fromDate: any, toDate: any) => {
|
|
82
|
+
fromDate: any;
|
|
83
|
+
toDate: any;
|
|
84
|
+
};
|
|
85
|
+
export declare const absFromSequence: (arr: number[]) => number[];
|
|
86
|
+
export declare const fillStartWithZero: (num: string | number, targetLength: number) => string;
|
|
87
|
+
export declare const fillEndWithZero: (num: string | number, targetLength: number) => string;
|
package/lib/cjs/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validEmail = exports.convertToCfa = exports.packAndUnit = exports.unCheckedAll = exports.inputChecked = exports.arrayMultiChecked = exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = exports.dateToString = exports.replaceSpacesWith = exports.replaceAllIn = exports.sesStorageGet = exports.sesStorageSet = exports.genSequenceRef = exports.removeBackSlashOccurences = exports.removeString = exports.deepClone = exports.findFirstSequenceMissing = exports.fillNumWithZero = exports.findSequencesMissing = exports.sequencesToNumbers = exports.notInSequence = exports.reformatDates = exports.formatToStringCfa = exports.formatToString = exports.wakeUp = exports.sleep = exports.limitTo = exports.titleCase = exports.toObjectDate = exports.removeDuplicatesByKey = exports.removeDuplicates = exports.getRandomColor = exports.getNbOfDaysBetweenTwoDates = exports.displayDateRangeFr = exports.calPercent = exports.percentOf = exports.genDateMinutesStep = exports.convertFrDateToEnDate = exports.convertEnDateToFr = exports.formatDateMd = exports.formatDateYm = exports.formatDateYmFirstDay = exports.formatDateYmd = exports.formatFromAndToDate = exports.formatDateYmHypen = exports.formatDateFirstDayFr = exports.formatDateYmdHypenFr = exports.formatDateYmdHypen = void 0;
|
|
4
|
-
exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.calculPercent = void 0;
|
|
4
|
+
exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = void 0;
|
|
5
5
|
const formatDateYmdHypen = (date) => {
|
|
6
6
|
return (0, exports.formatDateYmd)(date, "-");
|
|
7
7
|
};
|
|
@@ -379,6 +379,17 @@ const calculPercent = (nbr, percentage) => {
|
|
|
379
379
|
return (nbr * percentage) / 100;
|
|
380
380
|
};
|
|
381
381
|
exports.calculPercent = calculPercent;
|
|
382
|
+
const formatMonthYearToLocaleString = (date, prms) => {
|
|
383
|
+
if (prms === null || prms === void 0 ? void 0 : prms.minusOne) {
|
|
384
|
+
date.setMonth(date.getMonth() - 1);
|
|
385
|
+
}
|
|
386
|
+
const month = !(prms === null || prms === void 0 ? void 0 : prms.localLanguage)
|
|
387
|
+
? date.toLocaleDateString("FR-fr", { month: "long" })
|
|
388
|
+
: date.toLocaleDateString(prms === null || prms === void 0 ? void 0 : prms.localLanguage, { month: "long" }); // get month in french
|
|
389
|
+
const year = date.getFullYear();
|
|
390
|
+
return month.toUpperCase() + " " + year;
|
|
391
|
+
};
|
|
392
|
+
exports.formatMonthYearToLocaleString = formatMonthYearToLocaleString;
|
|
382
393
|
const padStartWithZero = (num, targetLength) => {
|
|
383
394
|
return num.toString().padStart(targetLength, 0);
|
|
384
395
|
};
|
|
@@ -450,3 +461,32 @@ const getArrayOfRandomColor = (length, type = "hex") => {
|
|
|
450
461
|
return colors;
|
|
451
462
|
};
|
|
452
463
|
exports.getArrayOfRandomColor = getArrayOfRandomColor;
|
|
464
|
+
const displayFrDatePeriode = (getFromDate, getToDate) => {
|
|
465
|
+
const fromDate = !getFromDate ? new Date() : getFromDate;
|
|
466
|
+
const toDate = !getToDate ? fromDate : getToDate;
|
|
467
|
+
return (0, exports.formatDateYmdHypenFr)(new Date(fromDate)) + " au " + (0, exports.formatDateYmdHypenFr)(new Date(toDate));
|
|
468
|
+
};
|
|
469
|
+
exports.displayFrDatePeriode = displayFrDatePeriode;
|
|
470
|
+
const returnDates = (fromDate, toDate) => {
|
|
471
|
+
if (fromDate === undefined || fromDate === null) {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
// toDate = toDate !== 'null' ? toDate : fromDate;
|
|
475
|
+
toDate = !toDate ? fromDate : toDate;
|
|
476
|
+
return { fromDate, toDate };
|
|
477
|
+
};
|
|
478
|
+
exports.returnDates = returnDates;
|
|
479
|
+
const absFromSequence = (arr) => {
|
|
480
|
+
let [min, max] = [Math.min(...arr), Math.max(...arr)];
|
|
481
|
+
// let out = Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
|
|
482
|
+
return Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
|
|
483
|
+
};
|
|
484
|
+
exports.absFromSequence = absFromSequence;
|
|
485
|
+
const fillStartWithZero = (num, targetLength) => {
|
|
486
|
+
return num.toString().padStart(targetLength, "0");
|
|
487
|
+
};
|
|
488
|
+
exports.fillStartWithZero = fillStartWithZero;
|
|
489
|
+
const fillEndWithZero = (num, targetLength) => {
|
|
490
|
+
return num.toString().padEnd(targetLength, "0");
|
|
491
|
+
};
|
|
492
|
+
exports.fillEndWithZero = fillEndWithZero;
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ import "./auth";
|
|
|
9
9
|
import "./bill";
|
|
10
10
|
import "./bootstrap";
|
|
11
11
|
import "./models/index";
|
|
12
|
+
import "./npms/typeorm";
|
|
13
|
+
import "./npms/yup";
|
|
12
14
|
import "./pdfs/invoices/amountInvoice";
|
|
13
15
|
import "./pdfs/invoices/infoInvoice";
|
|
14
16
|
import "./pdfs/tools/tools";
|
|
@@ -16,21 +18,21 @@ import "./product";
|
|
|
16
18
|
import "./react-utils";
|
|
17
19
|
import "./sale";
|
|
18
20
|
import "./services/authService";
|
|
19
|
-
import "./typeorm";
|
|
20
21
|
import "./user";
|
|
21
22
|
import "./utils";
|
|
22
23
|
export * from "./auth";
|
|
23
24
|
export * from "./bill";
|
|
24
25
|
export * from "./bootstrap";
|
|
26
|
+
export * from "./core/estates/index";
|
|
25
27
|
export * from "./models/index";
|
|
28
|
+
export * from "./npms/typeorm";
|
|
29
|
+
export * from "./npms/yup";
|
|
26
30
|
export * from "./pdfs/invoices/amountInvoice";
|
|
27
31
|
export * from "./pdfs/invoices/infoInvoice";
|
|
28
32
|
export * from "./pdfs/tools/tools";
|
|
29
33
|
export * from "./product";
|
|
30
34
|
export * from "./react-utils";
|
|
31
35
|
export * from "./sale";
|
|
32
|
-
export * from "./typeorm";
|
|
33
36
|
export * from "./user";
|
|
34
37
|
export * from "./utils";
|
|
35
|
-
export * from "./core/estates/index";
|
|
36
38
|
export { AuthService, StorageService, HlpProduct, HlpEntry, StockPipe, AmountOnListBillPipe, AmountOnBillPipe };
|
package/lib/esm/index.js
CHANGED
|
@@ -12,6 +12,8 @@ import "./bootstrap";
|
|
|
12
12
|
// import "./models/entities/users";
|
|
13
13
|
// import "./models/entities/users/index";
|
|
14
14
|
import "./models/index";
|
|
15
|
+
import "./npms/typeorm";
|
|
16
|
+
import "./npms/yup";
|
|
15
17
|
import "./pdfs/invoices/amountInvoice";
|
|
16
18
|
import "./pdfs/invoices/infoInvoice";
|
|
17
19
|
import "./pdfs/tools/tools";
|
|
@@ -19,22 +21,22 @@ import "./product";
|
|
|
19
21
|
import "./react-utils";
|
|
20
22
|
import "./sale";
|
|
21
23
|
import "./services/authService";
|
|
22
|
-
import "./typeorm";
|
|
23
24
|
import "./user";
|
|
24
25
|
import "./utils";
|
|
25
26
|
export * from "./auth";
|
|
26
27
|
export * from "./bill";
|
|
27
28
|
export * from "./bootstrap";
|
|
29
|
+
export * from "./core/estates/index";
|
|
28
30
|
export * from "./models/index";
|
|
31
|
+
export * from "./npms/typeorm";
|
|
32
|
+
export * from "./npms/yup";
|
|
29
33
|
export * from "./pdfs/invoices/amountInvoice";
|
|
30
34
|
export * from "./pdfs/invoices/infoInvoice";
|
|
31
35
|
export * from "./pdfs/tools/tools";
|
|
32
36
|
export * from "./product";
|
|
33
37
|
export * from "./react-utils";
|
|
34
38
|
export * from "./sale";
|
|
35
|
-
export * from "./typeorm";
|
|
36
39
|
export * from "./user";
|
|
37
40
|
export * from "./utils";
|
|
38
|
-
export * from "./core/estates/index";
|
|
39
41
|
// export * from "./helpers/hlpProduct";
|
|
40
42
|
export { AuthService, StorageService, HlpProduct, HlpEntry, StockPipe, AmountOnListBillPipe, AmountOnBillPipe };
|
|
@@ -6,7 +6,7 @@ import { UserGrp } from "./UserGrp";
|
|
|
6
6
|
import { UserRole } from "./UserRole";
|
|
7
7
|
import { UserTitr } from "./UserTitr";
|
|
8
8
|
export interface UserAbs extends Address {
|
|
9
|
-
id
|
|
9
|
+
id?: number;
|
|
10
10
|
codeCompta?: string | number;
|
|
11
11
|
firstname?: string;
|
|
12
12
|
lastname?: string;
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as yup from "yup";
|
|
2
|
+
export declare const schemaNaCoSh: (url: string, tob: any, codeMaxLenth?: number) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
4
|
+
code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
5
|
+
shortname: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
6
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
7
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
8
|
+
code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
9
|
+
shortname: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
10
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
11
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
12
|
+
code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
13
|
+
shortname: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
14
|
+
}>>>;
|
|
15
|
+
export declare const schemaNaCo: (url: string, tob: any, codeMaxLenth?: number) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
16
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
17
|
+
code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
18
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
19
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
20
|
+
code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
21
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
22
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
23
|
+
code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
24
|
+
}>>>;
|
|
25
|
+
export declare const schemaNa: (url: string, tob: any) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
26
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
27
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
28
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
29
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
30
|
+
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
31
|
+
}>>>;
|
|
32
|
+
export declare const schemaLogin: () => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
33
|
+
username: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
34
|
+
password: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
35
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
36
|
+
username: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
37
|
+
password: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
38
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
39
|
+
username: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
40
|
+
password: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
41
|
+
}>>>;
|
|
42
|
+
export declare const yupValideUniqName: (url: string, tob: any) => import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
43
|
+
export declare const yupValideUniqEmail: (url: string, tob: any, isRequired?: boolean) => yup.StringSchema<string, import("yup/lib/types").AnyObject, string>;
|
|
44
|
+
export declare const yupValideUniqNumber: (url: string, tob: any, isRequired?: boolean) => yup.NumberSchema<number, import("yup/lib/types").AnyObject, number>;
|
|
45
|
+
export declare const yupValideUniqCode: (url: string, max: number, tob: any) => import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
46
|
+
export declare const yupValidateNoRequiredNumber: () => yup.StringSchema<string, import("yup/lib/types").AnyObject, string>;
|
|
47
|
+
export declare const formatSelectOptions: (objs: any[], propLabel?: string, propValue?: string) => any[];
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import axios from "axios";
|
|
11
|
+
import * as yup from "yup";
|
|
12
|
+
export const schemaNaCoSh = (url, tob, codeMaxLenth = 4) => yup.object().shape({
|
|
13
|
+
name: yupValideUniqName(url + "/checkUniqueName", tob),
|
|
14
|
+
code: yupValideUniqCode(url + "/checkUniqueCode", codeMaxLenth, tob),
|
|
15
|
+
shortname: yupValideUniqName(url + "/checkUniqueShortname", tob),
|
|
16
|
+
});
|
|
17
|
+
export const schemaNaCo = (url, tob, codeMaxLenth = 4) => yup.object().shape({
|
|
18
|
+
name: yupValideUniqName(url + "/checkUniqueName", tob),
|
|
19
|
+
code: yupValideUniqCode(url + "/checkUniqueCode", codeMaxLenth, tob),
|
|
20
|
+
});
|
|
21
|
+
export const schemaNa = (url, tob) => yup.object().shape({
|
|
22
|
+
name: yupValideUniqName(url + "/checkUniqueName", tob),
|
|
23
|
+
});
|
|
24
|
+
export const schemaLogin = () => yup.object().shape({
|
|
25
|
+
// email: yup.string().required(t("Please enter Email")),
|
|
26
|
+
username: yup.string().required("Please enter Email"),
|
|
27
|
+
password: yup.string().required("Please enter Password"),
|
|
28
|
+
// checkbox: yup.bool().oneOf([true]),
|
|
29
|
+
});
|
|
30
|
+
export const yupValideUniqName = (url, tob) => {
|
|
31
|
+
return yup
|
|
32
|
+
.string()
|
|
33
|
+
.required()
|
|
34
|
+
.test("Check_name", "This name is already taken", (value) => {
|
|
35
|
+
return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
const { data: res } = yield axios.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
|
|
37
|
+
res ? resolve(true) : resolve(false);
|
|
38
|
+
}));
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
export const yupValideUniqEmail = (url, tob, isRequired = true) => {
|
|
42
|
+
if (isRequired) {
|
|
43
|
+
return yup
|
|
44
|
+
.string()
|
|
45
|
+
.email("this value must be a valid email")
|
|
46
|
+
.required("this value is required")
|
|
47
|
+
.test("Check_name", "This name is already taken", (value) => {
|
|
48
|
+
return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
const { data: res } = yield axios.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
|
|
50
|
+
res ? resolve(true) : resolve(false);
|
|
51
|
+
}));
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return yup.string().when((val) => {
|
|
55
|
+
if (val) {
|
|
56
|
+
return yup
|
|
57
|
+
.string()
|
|
58
|
+
.email()
|
|
59
|
+
.test("Check_name", "This name is already taken", (value) => {
|
|
60
|
+
return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
const { data: res } = yield axios.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
|
|
62
|
+
res ? resolve(true) : resolve(false);
|
|
63
|
+
}));
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
export const yupValideUniqNumber = (url, tob, isRequired = true) => {
|
|
69
|
+
if (isRequired) {
|
|
70
|
+
return yup
|
|
71
|
+
.number()
|
|
72
|
+
.required()
|
|
73
|
+
.test("Check_name", "This name is already taken", (value) => {
|
|
74
|
+
return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
+
const { data: res } = yield axios.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
|
|
76
|
+
res ? resolve(true) : resolve(false);
|
|
77
|
+
}));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return yup.number().test("Check_name", "This name is already taken", (value) => {
|
|
81
|
+
return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
|
+
const { data: res } = yield axios.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
|
|
83
|
+
res ? resolve(true) : resolve(false);
|
|
84
|
+
}));
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
export const yupValideUniqCode = (url, max = 4, tob) => {
|
|
88
|
+
return yup
|
|
89
|
+
.string()
|
|
90
|
+
.required()
|
|
91
|
+
.min(2)
|
|
92
|
+
.max(max)
|
|
93
|
+
.test("Check_name", "This name is already taken", (value) => {
|
|
94
|
+
return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
+
const { data: res } = yield axios.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
|
|
96
|
+
res ? resolve(true) : resolve(false);
|
|
97
|
+
}));
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
export const yupValidateNoRequiredNumber = () => {
|
|
101
|
+
return yup
|
|
102
|
+
.string()
|
|
103
|
+
.when((val) => {
|
|
104
|
+
if (val) {
|
|
105
|
+
return yup.number();
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
.typeError("must be number");
|
|
109
|
+
};
|
|
110
|
+
export const formatSelectOptions = (objs, propLabel = "name", propValue = "id") => {
|
|
111
|
+
if (!objs.length) {
|
|
112
|
+
return objs;
|
|
113
|
+
}
|
|
114
|
+
let options = [];
|
|
115
|
+
for (const obj of objs) {
|
|
116
|
+
options.push({ value: obj[propValue], label: obj[propLabel] });
|
|
117
|
+
}
|
|
118
|
+
return options;
|
|
119
|
+
};
|
package/lib/esm/utils.d.ts
CHANGED
|
@@ -64,6 +64,10 @@ export declare const packAndUnit: (qtity: number, qtityPerPackaging?: number) =>
|
|
|
64
64
|
export declare const convertToCfa: (price: number, currency?: string, dollarRate?: number) => number;
|
|
65
65
|
export declare const validEmail: (email: string) => boolean;
|
|
66
66
|
export declare const calculPercent: (nbr: number, percentage: number) => number;
|
|
67
|
+
export declare const formatMonthYearToLocaleString: (date: Date, prms?: {
|
|
68
|
+
localLanguage?: string;
|
|
69
|
+
minusOne?: boolean;
|
|
70
|
+
}) => string;
|
|
67
71
|
export declare const padStartWithZero: (num: any, targetLength: number) => any;
|
|
68
72
|
export declare const padEndWithZero: (num: any, targetLength: number) => any;
|
|
69
73
|
export declare const isBirthday: (birthDayDate: any) => boolean;
|
|
@@ -73,3 +77,11 @@ export declare const randomRgbColor: () => number[];
|
|
|
73
77
|
export declare const randomHexColor: () => string;
|
|
74
78
|
export declare const randomHslColor: () => number[];
|
|
75
79
|
export declare const getArrayOfRandomColor: (length: number, type?: "hex" | "rgb" | "hsl") => string[];
|
|
80
|
+
export declare const displayFrDatePeriode: (getFromDate?: any, getToDate?: any) => string;
|
|
81
|
+
export declare const returnDates: (fromDate: any, toDate: any) => {
|
|
82
|
+
fromDate: any;
|
|
83
|
+
toDate: any;
|
|
84
|
+
};
|
|
85
|
+
export declare const absFromSequence: (arr: number[]) => number[];
|
|
86
|
+
export declare const fillStartWithZero: (num: string | number, targetLength: number) => string;
|
|
87
|
+
export declare const fillEndWithZero: (num: string | number, targetLength: number) => string;
|
package/lib/esm/utils.js
CHANGED
|
@@ -324,6 +324,16 @@ export const validEmail = (email) => {
|
|
|
324
324
|
export const calculPercent = (nbr, percentage) => {
|
|
325
325
|
return (nbr * percentage) / 100;
|
|
326
326
|
};
|
|
327
|
+
export const formatMonthYearToLocaleString = (date, prms) => {
|
|
328
|
+
if (prms === null || prms === void 0 ? void 0 : prms.minusOne) {
|
|
329
|
+
date.setMonth(date.getMonth() - 1);
|
|
330
|
+
}
|
|
331
|
+
const month = !(prms === null || prms === void 0 ? void 0 : prms.localLanguage)
|
|
332
|
+
? date.toLocaleDateString("FR-fr", { month: "long" })
|
|
333
|
+
: date.toLocaleDateString(prms === null || prms === void 0 ? void 0 : prms.localLanguage, { month: "long" }); // get month in french
|
|
334
|
+
const year = date.getFullYear();
|
|
335
|
+
return month.toUpperCase() + " " + year;
|
|
336
|
+
};
|
|
327
337
|
export const padStartWithZero = (num, targetLength) => {
|
|
328
338
|
return num.toString().padStart(targetLength, 0);
|
|
329
339
|
};
|
|
@@ -386,3 +396,27 @@ export const getArrayOfRandomColor = (length, type = "hex") => {
|
|
|
386
396
|
}
|
|
387
397
|
return colors;
|
|
388
398
|
};
|
|
399
|
+
export const displayFrDatePeriode = (getFromDate, getToDate) => {
|
|
400
|
+
const fromDate = !getFromDate ? new Date() : getFromDate;
|
|
401
|
+
const toDate = !getToDate ? fromDate : getToDate;
|
|
402
|
+
return formatDateYmdHypenFr(new Date(fromDate)) + " au " + formatDateYmdHypenFr(new Date(toDate));
|
|
403
|
+
};
|
|
404
|
+
export const returnDates = (fromDate, toDate) => {
|
|
405
|
+
if (fromDate === undefined || fromDate === null) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
// toDate = toDate !== 'null' ? toDate : fromDate;
|
|
409
|
+
toDate = !toDate ? fromDate : toDate;
|
|
410
|
+
return { fromDate, toDate };
|
|
411
|
+
};
|
|
412
|
+
export const absFromSequence = (arr) => {
|
|
413
|
+
let [min, max] = [Math.min(...arr), Math.max(...arr)];
|
|
414
|
+
// let out = Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
|
|
415
|
+
return Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
|
|
416
|
+
};
|
|
417
|
+
export const fillStartWithZero = (num, targetLength) => {
|
|
418
|
+
return num.toString().padStart(targetLength, "0");
|
|
419
|
+
};
|
|
420
|
+
export const fillEndWithZero = (num, targetLength) => {
|
|
421
|
+
return num.toString().padEnd(targetLength, "0");
|
|
422
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "asv-hlps",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.25",
|
|
4
4
|
"description": "helpers",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"axios": "^0.27.2",
|
|
25
25
|
"bcryptjs": "^2.4.3",
|
|
26
26
|
"jwt-decode": "^3.1.2",
|
|
27
|
-
"randomatic": "^3.1.1"
|
|
27
|
+
"randomatic": "^3.1.1",
|
|
28
|
+
"yup": "^0.32.11"
|
|
28
29
|
}
|
|
29
30
|
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { User } from "../users/User";
|
|
2
|
-
import { City } from "../world/City";
|
|
3
|
-
import { Quarter } from "../world/Quarter";
|
|
4
|
-
import { Region } from "../world/Region";
|
|
5
|
-
import { EstateAsset } from "./EstateAsset";
|
|
6
|
-
import { EstateCat } from "./EstateCat";
|
|
7
|
-
import { EstatePor } from "./EstatePor";
|
|
8
|
-
import { Housing } from "./Housing";
|
|
9
|
-
export interface Estate {
|
|
10
|
-
id: number;
|
|
11
|
-
ref: string;
|
|
12
|
-
createdAt: Date;
|
|
13
|
-
description: string;
|
|
14
|
-
salePrice: number;
|
|
15
|
-
cat: EstateCat;
|
|
16
|
-
por: EstatePor;
|
|
17
|
-
region?: Region;
|
|
18
|
-
city?: City;
|
|
19
|
-
quarter?: Quarter;
|
|
20
|
-
prop?: User;
|
|
21
|
-
isActive?: boolean;
|
|
22
|
-
housings?: Housing[];
|
|
23
|
-
assets?: EstateAsset[];
|
|
24
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { User } from "../users/User";
|
|
2
|
-
import { Estate } from "./Estate";
|
|
3
|
-
import { HousingRented } from "./HousingRented";
|
|
4
|
-
export interface Housing {
|
|
5
|
-
id: number;
|
|
6
|
-
createdAt: Date;
|
|
7
|
-
description: string;
|
|
8
|
-
ref: string;
|
|
9
|
-
price: number;
|
|
10
|
-
deposit: number;
|
|
11
|
-
chargesPrice: number;
|
|
12
|
-
isActive: boolean;
|
|
13
|
-
estate: Estate;
|
|
14
|
-
lodger: User;
|
|
15
|
-
encoder: User;
|
|
16
|
-
rented: HousingRented;
|
|
17
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { User } from "../users/User";
|
|
2
|
-
import { Housing } from "./Housing";
|
|
3
|
-
export interface HousingRented {
|
|
4
|
-
id: number;
|
|
5
|
-
dateIn: Date;
|
|
6
|
-
dateOut: Date;
|
|
7
|
-
price: number;
|
|
8
|
-
deposit: number;
|
|
9
|
-
prepaid: number;
|
|
10
|
-
lodger?: User;
|
|
11
|
-
lodgerId?: number;
|
|
12
|
-
housingId?: number;
|
|
13
|
-
housing?: Housing;
|
|
14
|
-
encoder?: User;
|
|
15
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Estate } from "./Estate";
|
|
2
|
-
import { EstateAsset } from "./EstateAsset";
|
|
3
|
-
import { EstateCat } from "./EstateCat";
|
|
4
|
-
import { EstateElt } from "./EstateElt";
|
|
5
|
-
import { EstateLevel } from "./EstateLevel";
|
|
6
|
-
import { EstatePor } from "./EstatePor";
|
|
7
|
-
import { Housing } from "./Housing";
|
|
8
|
-
import { HousingRented } from "./HousingRented";
|
|
9
|
-
export { Estate, EstateAsset, EstateCat, EstateElt, EstateLevel, EstatePor, Housing, HousingRented };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { User } from "../users/User";
|
|
2
|
-
import { City } from "../world/City";
|
|
3
|
-
import { Quarter } from "../world/Quarter";
|
|
4
|
-
import { Region } from "../world/Region";
|
|
5
|
-
import { EstateAsset } from "./EstateAsset";
|
|
6
|
-
import { EstateCat } from "./EstateCat";
|
|
7
|
-
import { EstatePor } from "./EstatePor";
|
|
8
|
-
import { Housing } from "./Housing";
|
|
9
|
-
export interface Estate {
|
|
10
|
-
id: number;
|
|
11
|
-
ref: string;
|
|
12
|
-
createdAt: Date;
|
|
13
|
-
description: string;
|
|
14
|
-
salePrice: number;
|
|
15
|
-
cat: EstateCat;
|
|
16
|
-
por: EstatePor;
|
|
17
|
-
region?: Region;
|
|
18
|
-
city?: City;
|
|
19
|
-
quarter?: Quarter;
|
|
20
|
-
prop?: User;
|
|
21
|
-
isActive?: boolean;
|
|
22
|
-
housings?: Housing[];
|
|
23
|
-
assets?: EstateAsset[];
|
|
24
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { User } from "../users/User";
|
|
2
|
-
import { Estate } from "./Estate";
|
|
3
|
-
import { HousingRented } from "./HousingRented";
|
|
4
|
-
export interface Housing {
|
|
5
|
-
id: number;
|
|
6
|
-
createdAt: Date;
|
|
7
|
-
description: string;
|
|
8
|
-
ref: string;
|
|
9
|
-
price: number;
|
|
10
|
-
deposit: number;
|
|
11
|
-
chargesPrice: number;
|
|
12
|
-
isActive: boolean;
|
|
13
|
-
estate: Estate;
|
|
14
|
-
lodger: User;
|
|
15
|
-
encoder: User;
|
|
16
|
-
rented: HousingRented;
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { User } from "../users/User";
|
|
2
|
-
import { Housing } from "./Housing";
|
|
3
|
-
export interface HousingRented {
|
|
4
|
-
id: number;
|
|
5
|
-
dateIn: Date;
|
|
6
|
-
dateOut: Date;
|
|
7
|
-
price: number;
|
|
8
|
-
deposit: number;
|
|
9
|
-
prepaid: number;
|
|
10
|
-
lodger?: User;
|
|
11
|
-
lodgerId?: number;
|
|
12
|
-
housingId?: number;
|
|
13
|
-
housing?: Housing;
|
|
14
|
-
encoder?: User;
|
|
15
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Estate } from "./Estate";
|
|
2
|
-
import { EstateAsset } from "./EstateAsset";
|
|
3
|
-
import { EstateCat } from "./EstateCat";
|
|
4
|
-
import { EstateElt } from "./EstateElt";
|
|
5
|
-
import { EstateLevel } from "./EstateLevel";
|
|
6
|
-
import { EstatePor } from "./EstatePor";
|
|
7
|
-
import { Housing } from "./Housing";
|
|
8
|
-
import { HousingRented } from "./HousingRented";
|
|
9
|
-
export { Estate, EstateAsset, EstateCat, EstateElt, EstateLevel, EstatePor, Housing, HousingRented };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|