mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
fix: gmail email addresses dots gets removed
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
import { check, param, query, body, ValidationChain } from 'express-validator';
|
import { check, param, query, body, ValidationChain } from "express-validator";
|
||||||
import { Router, Request, Response, NextFunction } from 'express';
|
import { Router, Request, Response, NextFunction } from "express";
|
||||||
import { Inject, Service } from 'typedi';
|
import { Inject, Service } from "typedi";
|
||||||
import { ServiceError } from '@/exceptions';
|
import { ServiceError } from "@/exceptions";
|
||||||
import BaseController from '@/api/controllers/BaseController';
|
import BaseController from "@/api/controllers/BaseController";
|
||||||
import ContactsService from '@/services/Contacts/ContactsService';
|
import ContactsService from "@/services/Contacts/ContactsService";
|
||||||
import DynamicListingService from '@/services/DynamicListing/DynamicListService';
|
import DynamicListingService from "@/services/DynamicListing/DynamicListService";
|
||||||
import { DATATYPES_LENGTH } from '@/data/DataTypes';
|
import { DATATYPES_LENGTH } from "@/data/DataTypes";
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export default class ContactsController extends BaseController {
|
export default class ContactsController extends BaseController {
|
||||||
@@ -22,28 +22,28 @@ export default class ContactsController extends BaseController {
|
|||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
'/auto-complete',
|
"/auto-complete",
|
||||||
[...this.autocompleteQuerySchema],
|
[...this.autocompleteQuerySchema],
|
||||||
this.validationResult,
|
this.validationResult,
|
||||||
this.asyncMiddleware(this.autocompleteContacts.bind(this)),
|
this.asyncMiddleware(this.autocompleteContacts.bind(this)),
|
||||||
this.dynamicListService.handlerErrorsToResponse
|
this.dynamicListService.handlerErrorsToResponse
|
||||||
);
|
);
|
||||||
router.get(
|
router.get(
|
||||||
'/:id',
|
"/:id",
|
||||||
[param('id').exists().isNumeric().toInt()],
|
[param("id").exists().isNumeric().toInt()],
|
||||||
this.validationResult,
|
this.validationResult,
|
||||||
this.asyncMiddleware(this.getContact.bind(this))
|
this.asyncMiddleware(this.getContact.bind(this))
|
||||||
);
|
);
|
||||||
router.post(
|
router.post(
|
||||||
'/:id/inactivate',
|
"/:id/inactivate",
|
||||||
[param('id').exists().isNumeric().toInt()],
|
[param("id").exists().isNumeric().toInt()],
|
||||||
this.validationResult,
|
this.validationResult,
|
||||||
this.asyncMiddleware(this.inactivateContact.bind(this)),
|
this.asyncMiddleware(this.inactivateContact.bind(this)),
|
||||||
this.handlerServiceErrors
|
this.handlerServiceErrors
|
||||||
);
|
);
|
||||||
router.post(
|
router.post(
|
||||||
'/:id/activate',
|
"/:id/activate",
|
||||||
[param('id').exists().isNumeric().toInt()],
|
[param("id").exists().isNumeric().toInt()],
|
||||||
this.validationResult,
|
this.validationResult,
|
||||||
this.asyncMiddleware(this.activateContact.bind(this)),
|
this.asyncMiddleware(this.activateContact.bind(this)),
|
||||||
this.handlerServiceErrors
|
this.handlerServiceErrors
|
||||||
@@ -56,11 +56,11 @@ export default class ContactsController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
get autocompleteQuerySchema() {
|
get autocompleteQuerySchema() {
|
||||||
return [
|
return [
|
||||||
query('column_sort_by').optional().trim().escape(),
|
query("column_sort_by").optional().trim().escape(),
|
||||||
query('sort_order').optional().isIn(['desc', 'asc']),
|
query("sort_order").optional().isIn(["desc", "asc"]),
|
||||||
|
|
||||||
query('stringified_filter_roles').optional().isJSON(),
|
query("stringified_filter_roles").optional().isJSON(),
|
||||||
query('limit').optional().isNumeric().toInt(),
|
query("limit").optional().isNumeric().toInt(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,8 +97,8 @@ export default class ContactsController extends BaseController {
|
|||||||
const { tenantId } = req;
|
const { tenantId } = req;
|
||||||
const filter = {
|
const filter = {
|
||||||
filterRoles: [],
|
filterRoles: [],
|
||||||
sortOrder: 'asc',
|
sortOrder: "asc",
|
||||||
columnSortBy: 'display_name',
|
columnSortBy: "display_name",
|
||||||
limit: 10,
|
limit: 10,
|
||||||
...this.matchedQueryData(req),
|
...this.matchedQueryData(req),
|
||||||
};
|
};
|
||||||
@@ -118,170 +118,170 @@ export default class ContactsController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
get contactDTOSchema(): ValidationChain[] {
|
get contactDTOSchema(): ValidationChain[] {
|
||||||
return [
|
return [
|
||||||
check('salutation')
|
check("salutation")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('first_name')
|
check("first_name")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('last_name')
|
check("last_name")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('company_name')
|
check("company_name")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
|
|
||||||
check('display_name')
|
check("display_name")
|
||||||
.exists()
|
.exists()
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
|
|
||||||
check('email')
|
check("email")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.normalizeEmail()
|
.normalizeEmail({ gmail_remove_dots: false })
|
||||||
.isEmail()
|
.isEmail()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('website')
|
check("website")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.isURL()
|
.isURL()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('work_phone')
|
check("work_phone")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('personal_phone')
|
check("personal_phone")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
|
|
||||||
check('billing_address_1')
|
check("billing_address_1")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('billing_address_2')
|
check("billing_address_2")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('billing_address_city')
|
check("billing_address_city")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('billing_address_country')
|
check("billing_address_country")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('billing_address_email')
|
check("billing_address_email")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.isEmail()
|
.isEmail()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('billing_address_postcode')
|
check("billing_address_postcode")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('billing_address_phone')
|
check("billing_address_phone")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('billing_address_state')
|
check("billing_address_state")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
|
|
||||||
check('shipping_address_1')
|
check("shipping_address_1")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('shipping_address_2')
|
check("shipping_address_2")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('shipping_address_city')
|
check("shipping_address_city")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('shipping_address_country')
|
check("shipping_address_country")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('shipping_address_email')
|
check("shipping_address_email")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.isEmail()
|
.isEmail()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('shipping_address_postcode')
|
check("shipping_address_postcode")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('shipping_address_phone')
|
check("shipping_address_phone")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
check('shipping_address_state')
|
check("shipping_address_state")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
.isLength({ max: DATATYPES_LENGTH.STRING }),
|
||||||
|
|
||||||
check('note')
|
check("note")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isString()
|
.isString()
|
||||||
.trim()
|
.trim()
|
||||||
.escape()
|
.escape()
|
||||||
.isLength({ max: DATATYPES_LENGTH.TEXT }),
|
.isLength({ max: DATATYPES_LENGTH.TEXT }),
|
||||||
check('active').optional().isBoolean().toBoolean(),
|
check("active").optional().isBoolean().toBoolean(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,19 +291,19 @@ export default class ContactsController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
get contactNewDTOSchema(): ValidationChain[] {
|
get contactNewDTOSchema(): ValidationChain[] {
|
||||||
return [
|
return [
|
||||||
check('opening_balance')
|
check("opening_balance")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isInt({ min: 0, max: DATATYPES_LENGTH.DECIMAL_13_3 })
|
.isInt({ min: 0, max: DATATYPES_LENGTH.DECIMAL_13_3 })
|
||||||
.toInt(),
|
.toInt(),
|
||||||
check('opening_balance_exchange_rate')
|
check("opening_balance_exchange_rate")
|
||||||
.default(1)
|
.default(1)
|
||||||
.isFloat({ gt: 0 })
|
.isFloat({ gt: 0 })
|
||||||
.toFloat(),
|
.toFloat(),
|
||||||
body('opening_balance_at')
|
body("opening_balance_at")
|
||||||
.if(body('opening_balance').exists())
|
.if(body("opening_balance").exists())
|
||||||
.exists()
|
.exists()
|
||||||
.isISO8601(),
|
.isISO8601(),
|
||||||
check('opening_balance_branch_id')
|
check("opening_balance_branch_id")
|
||||||
.optional({ nullable: true })
|
.optional({ nullable: true })
|
||||||
.isNumeric()
|
.isNumeric()
|
||||||
.toInt(),
|
.toInt(),
|
||||||
@@ -322,7 +322,7 @@ export default class ContactsController extends BaseController {
|
|||||||
* @returns {ValidationChain[]}
|
* @returns {ValidationChain[]}
|
||||||
*/
|
*/
|
||||||
get specificContactSchema(): ValidationChain[] {
|
get specificContactSchema(): ValidationChain[] {
|
||||||
return [param('id').exists().isNumeric().toInt()];
|
return [param("id").exists().isNumeric().toInt()];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -340,7 +340,7 @@ export default class ContactsController extends BaseController {
|
|||||||
|
|
||||||
return res.status(200).send({
|
return res.status(200).send({
|
||||||
id: contactId,
|
id: contactId,
|
||||||
message: 'The given contact activated successfully.',
|
message: "The given contact activated successfully.",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(error);
|
next(error);
|
||||||
@@ -362,7 +362,7 @@ export default class ContactsController extends BaseController {
|
|||||||
|
|
||||||
return res.status(200).send({
|
return res.status(200).send({
|
||||||
id: contactId,
|
id: contactId,
|
||||||
message: 'The given contact inactivated successfully.',
|
message: "The given contact inactivated successfully.",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(error);
|
next(error);
|
||||||
@@ -383,19 +383,19 @@ export default class ContactsController extends BaseController {
|
|||||||
next: NextFunction
|
next: NextFunction
|
||||||
) {
|
) {
|
||||||
if (error instanceof ServiceError) {
|
if (error instanceof ServiceError) {
|
||||||
if (error.errorType === 'contact_not_found') {
|
if (error.errorType === "contact_not_found") {
|
||||||
return res.boom.badRequest(null, {
|
return res.boom.badRequest(null, {
|
||||||
errors: [{ type: 'CONTACT.NOT.FOUND', code: 100 }],
|
errors: [{ type: "CONTACT.NOT.FOUND", code: 100 }],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (error.errorType === 'CONTACT_ALREADY_ACTIVE') {
|
if (error.errorType === "CONTACT_ALREADY_ACTIVE") {
|
||||||
return res.boom.badRequest(null, {
|
return res.boom.badRequest(null, {
|
||||||
errors: [{ type: 'CONTACT_ALREADY_ACTIVE', code: 700 }],
|
errors: [{ type: "CONTACT_ALREADY_ACTIVE", code: 700 }],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (error.errorType === 'CONTACT_ALREADY_INACTIVE') {
|
if (error.errorType === "CONTACT_ALREADY_INACTIVE") {
|
||||||
return res.boom.badRequest(null, {
|
return res.boom.badRequest(null, {
|
||||||
errors: [{ type: 'CONTACT_ALREADY_INACTIVE', code: 800 }],
|
errors: [{ type: "CONTACT_ALREADY_INACTIVE", code: 800 }],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export function DetailItem({ label, children, name, align, className }) {
|
|||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
</div>
|
</div>
|
||||||
<div class="detail-item__content">{children}</div>
|
<div>{children}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user