mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
BC-5 fix: general tab of preferences form submitting.
This commit is contained in:
41
server/src/api/controllers/Miscellaneous/index.ts
Normal file
41
server/src/api/controllers/Miscellaneous/index.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { Router, Request, Response, NextFunction } from 'express';
|
||||
import BaseController from 'api/controllers/BaseController';
|
||||
import MiscService from 'services/Miscellaneous/MiscService';
|
||||
import DateFormatsService from 'services/Miscellaneous/DateFormats';
|
||||
|
||||
@Service()
|
||||
export default class MiscController extends BaseController {
|
||||
@Inject()
|
||||
dateFormatsService: DateFormatsService;
|
||||
|
||||
/**
|
||||
* Express router.
|
||||
*/
|
||||
router() {
|
||||
const router = Router();
|
||||
|
||||
router.get(
|
||||
'/date_formats',
|
||||
this.validationResult,
|
||||
this.asyncMiddleware(this.dateFormats.bind(this))
|
||||
);
|
||||
return router;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve date formats options.
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {NextFunction} next
|
||||
*/
|
||||
dateFormats(req: Request, res: Response, next: NextFunction) {
|
||||
try {
|
||||
const dateFormats = this.dateFormatsService.getDateFormats();
|
||||
|
||||
return res.status(200).send({ data: dateFormats });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,8 @@ import {
|
||||
ACCEPTED_CURRENCIES,
|
||||
MONTHS,
|
||||
ACCEPTED_LOCALES,
|
||||
DATE_FORMATS,
|
||||
} from 'services/Organization/constants';
|
||||
import { DATE_FORMATS } from 'services/Miscellaneous/DateFormats/constants';
|
||||
|
||||
import { ServiceError } from 'exceptions';
|
||||
import BaseController from 'api/controllers/BaseController';
|
||||
@@ -64,7 +64,7 @@ export default class OrganizationController extends BaseController {
|
||||
*/
|
||||
private get buildValidationSchema(): ValidationChain[] {
|
||||
return [
|
||||
check('organization_name').exists().trim(),
|
||||
check('name').exists().trim(),
|
||||
check('base_currency').exists().isIn(ACCEPTED_CURRENCIES),
|
||||
check('timezone').exists().isIn(moment.tz.names()),
|
||||
check('fiscal_year').exists().isIn(MONTHS),
|
||||
|
||||
@@ -42,6 +42,7 @@ import Licenses from 'api/controllers/Subscription/Licenses';
|
||||
import InventoryAdjustments from 'api/controllers/Inventory/InventoryAdjustments';
|
||||
import asyncRenderMiddleware from './middleware/AsyncRenderMiddleware';
|
||||
import Jobs from './controllers/Jobs';
|
||||
import Miscellaneous from 'api/controllers/Miscellaneous';
|
||||
|
||||
export default () => {
|
||||
const app = Router();
|
||||
@@ -95,6 +96,8 @@ export default () => {
|
||||
dashboard.use('/media', Container.get(Media).router());
|
||||
dashboard.use('/inventory_adjustments', Container.get(InventoryAdjustments).router());
|
||||
|
||||
dashboard.use('/', Container.get(Miscellaneous).router());
|
||||
|
||||
app.use('/', dashboard);
|
||||
|
||||
return app;
|
||||
|
||||
Reference in New Issue
Block a user