Added address to Vendor
This commit is contained in:
parent
f4681e917b
commit
9f2341c613
@ -15,14 +15,14 @@ import {
|
|||||||
// list of vendors
|
// list of vendors
|
||||||
router.get('/', isAuthenticated, (req, res) => {
|
router.get('/', isAuthenticated, (req, res) => {
|
||||||
const { page, limit, property, search, sort, order } = req.query;
|
const { page, limit, property, search, sort, order } = req.query;
|
||||||
const allowedFilters = ['country'];
|
const allowedFilters = ['country', 'active', 'createdAt', 'updatedAt'];
|
||||||
const filter = getFilter(req.query, allowedFilters);
|
const filter = getFilter(req.query, allowedFilters);
|
||||||
listVendorsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
listVendorsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/properties', isAuthenticated, (req, res) => {
|
router.get('/properties', isAuthenticated, (req, res) => {
|
||||||
let properties = convertPropertiesString(req.query.properties);
|
let properties = convertPropertiesString(req.query.properties);
|
||||||
const allowedFilters = ['country'];
|
const allowedFilters = ['country', 'active', 'createdAt', 'updatedAt'];
|
||||||
const filter = getFilter(req.query, allowedFilters, false);
|
const filter = getFilter(req.query, allowedFilters, false);
|
||||||
listVendorsByPropertiesRouteHandler(req, res, properties, filter);
|
listVendorsByPropertiesRouteHandler(req, res, properties, filter);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,16 @@
|
|||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import { generateId } from '../../utils.js';
|
import { generateId } from '../../utils.js';
|
||||||
|
|
||||||
|
const addressSchema = new mongoose.Schema({
|
||||||
|
building: { required: false, type: String },
|
||||||
|
addressLine1: { required: false, type: String },
|
||||||
|
addressLine2: { required: false, type: String },
|
||||||
|
city: { required: false, type: String },
|
||||||
|
state: { required: false, type: String },
|
||||||
|
postcode: { required: false, type: String },
|
||||||
|
country: { required: false, type: String },
|
||||||
|
});
|
||||||
|
|
||||||
const vendorSchema = new mongoose.Schema(
|
const vendorSchema = new mongoose.Schema(
|
||||||
{
|
{
|
||||||
_reference: { type: String, default: () => generateId()() },
|
_reference: { type: String, default: () => generateId()() },
|
||||||
@ -10,6 +20,8 @@ const vendorSchema = new mongoose.Schema(
|
|||||||
phone: { required: false, type: String },
|
phone: { required: false, type: String },
|
||||||
contact: { required: false, type: String },
|
contact: { required: false, type: String },
|
||||||
country: { required: false, type: String },
|
country: { required: false, type: String },
|
||||||
|
active: { required: true, type: Boolean, default: true },
|
||||||
|
address: { required: false, type: addressSchema },
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@ -97,6 +97,8 @@ export const editVendorRouteHandler = async (req, res) => {
|
|||||||
website: req.body.website,
|
website: req.body.website,
|
||||||
phone: req.body.phone,
|
phone: req.body.phone,
|
||||||
email: req.body.email,
|
email: req.body.email,
|
||||||
|
address: req.body.address,
|
||||||
|
active: req.body.active,
|
||||||
};
|
};
|
||||||
// Create audit log before updating
|
// Create audit log before updating
|
||||||
const result = await editObject({
|
const result = await editObject({
|
||||||
@ -126,6 +128,8 @@ export const newVendorRouteHandler = async (req, res) => {
|
|||||||
website: req.body.website,
|
website: req.body.website,
|
||||||
phone: req.body.phone,
|
phone: req.body.phone,
|
||||||
email: req.body.email,
|
email: req.body.email,
|
||||||
|
address: req.body.address,
|
||||||
|
active: req.body.active,
|
||||||
};
|
};
|
||||||
const result = await newObject({
|
const result = await newObject({
|
||||||
model: vendorModel,
|
model: vendorModel,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user