Updated via schema editor on 2025-09-24 18:08
This commit is contained in:
parent
e5c4e5a9e2
commit
d5f32d622a
File diff suppressed because one or more lines are too long
@ -18,6 +18,8 @@ module.exports = class OrdersDBApi {
|
|||||||
requested_date: data.requested_date || null,
|
requested_date: data.requested_date || null,
|
||||||
status: data.status || null,
|
status: data.status || null,
|
||||||
fee: data.fee || null,
|
fee: data.fee || null,
|
||||||
|
street_address: data.street_address || null,
|
||||||
|
Municipality: data.Municipality || null,
|
||||||
importHash: data.importHash || null,
|
importHash: data.importHash || null,
|
||||||
createdById: currentUser.id,
|
createdById: currentUser.id,
|
||||||
updatedById: currentUser.id,
|
updatedById: currentUser.id,
|
||||||
@ -51,6 +53,8 @@ module.exports = class OrdersDBApi {
|
|||||||
requested_date: item.requested_date || null,
|
requested_date: item.requested_date || null,
|
||||||
status: item.status || null,
|
status: item.status || null,
|
||||||
fee: item.fee || null,
|
fee: item.fee || null,
|
||||||
|
street_address: item.street_address || null,
|
||||||
|
Municipality: item.Municipality || null,
|
||||||
importHash: item.importHash || null,
|
importHash: item.importHash || null,
|
||||||
createdById: currentUser.id,
|
createdById: currentUser.id,
|
||||||
updatedById: currentUser.id,
|
updatedById: currentUser.id,
|
||||||
@ -81,6 +85,12 @@ module.exports = class OrdersDBApi {
|
|||||||
|
|
||||||
if (data.fee !== undefined) updatePayload.fee = data.fee;
|
if (data.fee !== undefined) updatePayload.fee = data.fee;
|
||||||
|
|
||||||
|
if (data.street_address !== undefined)
|
||||||
|
updatePayload.street_address = data.street_address;
|
||||||
|
|
||||||
|
if (data.Municipality !== undefined)
|
||||||
|
updatePayload.Municipality = data.Municipality;
|
||||||
|
|
||||||
updatePayload.updatedById = currentUser.id;
|
updatePayload.updatedById = currentUser.id;
|
||||||
|
|
||||||
await orders.update(updatePayload, { transaction });
|
await orders.update(updatePayload, { transaction });
|
||||||
@ -273,6 +283,24 @@ module.exports = class OrdersDBApi {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filter.street_address) {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
[Op.and]: Utils.ilike(
|
||||||
|
'orders',
|
||||||
|
'street_address',
|
||||||
|
filter.street_address,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.Municipality) {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
[Op.and]: Utils.ilike('orders', 'Municipality', filter.Municipality),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (filter.requested_dateRange) {
|
if (filter.requested_dateRange) {
|
||||||
const [start, end] = filter.requested_dateRange;
|
const [start, end] = filter.requested_dateRange;
|
||||||
|
|
||||||
|
|||||||
62
backend/src/db/migrations/1758737321520.js
Normal file
62
backend/src/db/migrations/1758737321520.js
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
module.exports = {
|
||||||
|
/**
|
||||||
|
* @param {QueryInterface} queryInterface
|
||||||
|
* @param {Sequelize} Sequelize
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async up(queryInterface, Sequelize) {
|
||||||
|
/**
|
||||||
|
* @type {Transaction}
|
||||||
|
*/
|
||||||
|
const transaction = await queryInterface.sequelize.transaction();
|
||||||
|
try {
|
||||||
|
await queryInterface.addColumn(
|
||||||
|
'orders',
|
||||||
|
'street_address',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.TEXT,
|
||||||
|
},
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryInterface.addColumn(
|
||||||
|
'orders',
|
||||||
|
'Municipality',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.TEXT,
|
||||||
|
},
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @param {QueryInterface} queryInterface
|
||||||
|
* @param {Sequelize} Sequelize
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async down(queryInterface, Sequelize) {
|
||||||
|
/**
|
||||||
|
* @type {Transaction}
|
||||||
|
*/
|
||||||
|
const transaction = await queryInterface.sequelize.transaction();
|
||||||
|
try {
|
||||||
|
await queryInterface.removeColumn('orders', 'Municipality', {
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await queryInterface.removeColumn('orders', 'street_address', {
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
@ -42,6 +42,14 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
type: DataTypes.DECIMAL,
|
type: DataTypes.DECIMAL,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
street_address: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
|
},
|
||||||
|
|
||||||
|
Municipality: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
|
},
|
||||||
|
|
||||||
importHash: {
|
importHash: {
|
||||||
type: DataTypes.STRING(255),
|
type: DataTypes.STRING(255),
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
|
|||||||
@ -49,6 +49,16 @@ const ActivitiesData = [
|
|||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
action: 'Approved order for Metro Valuations.',
|
||||||
|
|
||||||
|
timestamp: new Date('2023-10-04T12:00:00Z'),
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const AppraisalsData = [
|
const AppraisalsData = [
|
||||||
@ -61,7 +71,7 @@ const AppraisalsData = [
|
|||||||
|
|
||||||
delivery_date: new Date('2023-10-05T17:00:00Z'),
|
delivery_date: new Date('2023-10-05T17:00:00Z'),
|
||||||
|
|
||||||
status: 'assigned',
|
status: 'scheduled',
|
||||||
|
|
||||||
fee: 1500,
|
fee: 1500,
|
||||||
|
|
||||||
@ -77,7 +87,7 @@ const AppraisalsData = [
|
|||||||
|
|
||||||
delivery_date: new Date('2023-10-06T16:00:00Z'),
|
delivery_date: new Date('2023-10-06T16:00:00Z'),
|
||||||
|
|
||||||
status: 'assigned',
|
status: 'in_progress',
|
||||||
|
|
||||||
fee: 2000,
|
fee: 2000,
|
||||||
|
|
||||||
@ -93,12 +103,28 @@ const AppraisalsData = [
|
|||||||
|
|
||||||
delivery_date: new Date('2023-10-07T15:00:00Z'),
|
delivery_date: new Date('2023-10-07T15:00:00Z'),
|
||||||
|
|
||||||
status: 'delivered',
|
status: 'in_progress',
|
||||||
|
|
||||||
fee: 2500,
|
fee: 2500,
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
accepted_date: new Date('2023-10-04T12:00:00Z'),
|
||||||
|
|
||||||
|
delivery_date: new Date('2023-10-08T14:00:00Z'),
|
||||||
|
|
||||||
|
status: 'delivered',
|
||||||
|
|
||||||
|
fee: 1800,
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const ClientsData = [
|
const ClientsData = [
|
||||||
@ -131,6 +157,16 @@ const ClientsData = [
|
|||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'Suburban Assessments',
|
||||||
|
|
||||||
|
contact_email: 'contact@suburbanassessments.com',
|
||||||
|
|
||||||
|
// type code here for "relation_many" field
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const InvoicesData = [
|
const InvoicesData = [
|
||||||
@ -169,6 +205,18 @@ const InvoicesData = [
|
|||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
total_amount: 1800,
|
||||||
|
|
||||||
|
issue_date: new Date('2023-10-04T12:00:00Z'),
|
||||||
|
|
||||||
|
due_date: new Date('2023-10-18T17:00:00Z'),
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const MessagesData = [
|
const MessagesData = [
|
||||||
@ -207,6 +255,18 @@ const MessagesData = [
|
|||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
content: 'Please confirm the inspection date.',
|
||||||
|
|
||||||
|
sent_date: new Date('2023-10-04T12:00:00Z'),
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const NotificationsData = [
|
const NotificationsData = [
|
||||||
@ -239,6 +299,16 @@ const NotificationsData = [
|
|||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
message: 'Order approved by Org Admin.',
|
||||||
|
|
||||||
|
date: new Date('2023-10-04T12:00:00Z'),
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const OrdersData = [
|
const OrdersData = [
|
||||||
@ -249,11 +319,15 @@ const OrdersData = [
|
|||||||
|
|
||||||
requested_date: new Date('2023-10-01T09:00:00Z'),
|
requested_date: new Date('2023-10-01T09:00:00Z'),
|
||||||
|
|
||||||
status: 'scheduled',
|
status: 'delivered',
|
||||||
|
|
||||||
fee: 1500,
|
fee: 1500,
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
street_address: 'Claude Bernard',
|
||||||
|
|
||||||
|
Municipality: 'Dmitri Mendeleev',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -263,11 +337,15 @@ const OrdersData = [
|
|||||||
|
|
||||||
requested_date: new Date('2023-10-02T10:00:00Z'),
|
requested_date: new Date('2023-10-02T10:00:00Z'),
|
||||||
|
|
||||||
status: 'delivered',
|
status: 'in_progress',
|
||||||
|
|
||||||
fee: 2000,
|
fee: 2000,
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
street_address: 'Johannes Kepler',
|
||||||
|
|
||||||
|
Municipality: 'Hans Selye',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -277,11 +355,33 @@ const OrdersData = [
|
|||||||
|
|
||||||
requested_date: new Date('2023-10-03T11:00:00Z'),
|
requested_date: new Date('2023-10-03T11:00:00Z'),
|
||||||
|
|
||||||
status: 'delivered',
|
status: 'scheduled',
|
||||||
|
|
||||||
fee: 2500,
|
fee: 2500,
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
street_address: 'Hans Bethe',
|
||||||
|
|
||||||
|
Municipality: 'Emil Kraepelin',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
requested_date: new Date('2023-10-04T12:00:00Z'),
|
||||||
|
|
||||||
|
status: 'declined',
|
||||||
|
|
||||||
|
fee: 1800,
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
street_address: 'Alfred Kinsey',
|
||||||
|
|
||||||
|
Municipality: 'Louis Pasteur',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -315,6 +415,16 @@ const PropertiesData = [
|
|||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
address: '101 Elm St, Metropolis, USA',
|
||||||
|
|
||||||
|
property_type: 'Residential',
|
||||||
|
|
||||||
|
// type code here for "relation_many" field
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const OrganizationsData = [
|
const OrganizationsData = [
|
||||||
@ -329,6 +439,10 @@ const OrganizationsData = [
|
|||||||
{
|
{
|
||||||
name: 'Urban Appraisals',
|
name: 'Urban Appraisals',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'Metro Valuations',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
// Similar logic for "relation_many"
|
// Similar logic for "relation_many"
|
||||||
@ -366,6 +480,17 @@ async function associateUserWithOrganization() {
|
|||||||
if (User2?.setOrganization) {
|
if (User2?.setOrganization) {
|
||||||
await User2.setOrganization(relatedOrganization2);
|
await User2.setOrganization(relatedOrganization2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrganization3 = await Organizations.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
||||||
|
});
|
||||||
|
const User3 = await Users.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (User3?.setOrganization) {
|
||||||
|
await User3.setOrganization(relatedOrganization3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateActivityWithUser() {
|
async function associateActivityWithUser() {
|
||||||
@ -401,6 +526,17 @@ async function associateActivityWithUser() {
|
|||||||
if (Activity2?.setUser) {
|
if (Activity2?.setUser) {
|
||||||
await Activity2.setUser(relatedUser2);
|
await Activity2.setUser(relatedUser2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedUser3 = await Users.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Users.count())),
|
||||||
|
});
|
||||||
|
const Activity3 = await Activities.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Activity3?.setUser) {
|
||||||
|
await Activity3.setUser(relatedUser3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateActivityWithOrganization() {
|
async function associateActivityWithOrganization() {
|
||||||
@ -436,6 +572,17 @@ async function associateActivityWithOrganization() {
|
|||||||
if (Activity2?.setOrganization) {
|
if (Activity2?.setOrganization) {
|
||||||
await Activity2.setOrganization(relatedOrganization2);
|
await Activity2.setOrganization(relatedOrganization2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrganization3 = await Organizations.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
||||||
|
});
|
||||||
|
const Activity3 = await Activities.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Activity3?.setOrganization) {
|
||||||
|
await Activity3.setOrganization(relatedOrganization3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateAppraisalWithProperty() {
|
async function associateAppraisalWithProperty() {
|
||||||
@ -471,6 +618,17 @@ async function associateAppraisalWithProperty() {
|
|||||||
if (Appraisal2?.setProperty) {
|
if (Appraisal2?.setProperty) {
|
||||||
await Appraisal2.setProperty(relatedProperty2);
|
await Appraisal2.setProperty(relatedProperty2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedProperty3 = await Properties.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Properties.count())),
|
||||||
|
});
|
||||||
|
const Appraisal3 = await Appraisals.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Appraisal3?.setProperty) {
|
||||||
|
await Appraisal3.setProperty(relatedProperty3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateAppraisalWithAppraiser() {
|
async function associateAppraisalWithAppraiser() {
|
||||||
@ -506,6 +664,17 @@ async function associateAppraisalWithAppraiser() {
|
|||||||
if (Appraisal2?.setAppraiser) {
|
if (Appraisal2?.setAppraiser) {
|
||||||
await Appraisal2.setAppraiser(relatedAppraiser2);
|
await Appraisal2.setAppraiser(relatedAppraiser2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedAppraiser3 = await Users.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Users.count())),
|
||||||
|
});
|
||||||
|
const Appraisal3 = await Appraisals.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Appraisal3?.setAppraiser) {
|
||||||
|
await Appraisal3.setAppraiser(relatedAppraiser3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateAppraisalWithOrganization() {
|
async function associateAppraisalWithOrganization() {
|
||||||
@ -541,6 +710,17 @@ async function associateAppraisalWithOrganization() {
|
|||||||
if (Appraisal2?.setOrganization) {
|
if (Appraisal2?.setOrganization) {
|
||||||
await Appraisal2.setOrganization(relatedOrganization2);
|
await Appraisal2.setOrganization(relatedOrganization2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrganization3 = await Organizations.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
||||||
|
});
|
||||||
|
const Appraisal3 = await Appraisals.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Appraisal3?.setOrganization) {
|
||||||
|
await Appraisal3.setOrganization(relatedOrganization3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Similar logic for "relation_many"
|
// Similar logic for "relation_many"
|
||||||
@ -578,6 +758,17 @@ async function associateClientWithOrganization() {
|
|||||||
if (Client2?.setOrganization) {
|
if (Client2?.setOrganization) {
|
||||||
await Client2.setOrganization(relatedOrganization2);
|
await Client2.setOrganization(relatedOrganization2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrganization3 = await Organizations.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
||||||
|
});
|
||||||
|
const Client3 = await Clients.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Client3?.setOrganization) {
|
||||||
|
await Client3.setOrganization(relatedOrganization3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateInvoiceWithClient() {
|
async function associateInvoiceWithClient() {
|
||||||
@ -613,6 +804,17 @@ async function associateInvoiceWithClient() {
|
|||||||
if (Invoice2?.setClient) {
|
if (Invoice2?.setClient) {
|
||||||
await Invoice2.setClient(relatedClient2);
|
await Invoice2.setClient(relatedClient2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedClient3 = await Clients.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Clients.count())),
|
||||||
|
});
|
||||||
|
const Invoice3 = await Invoices.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Invoice3?.setClient) {
|
||||||
|
await Invoice3.setClient(relatedClient3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateInvoiceWithOrganization() {
|
async function associateInvoiceWithOrganization() {
|
||||||
@ -648,6 +850,17 @@ async function associateInvoiceWithOrganization() {
|
|||||||
if (Invoice2?.setOrganization) {
|
if (Invoice2?.setOrganization) {
|
||||||
await Invoice2.setOrganization(relatedOrganization2);
|
await Invoice2.setOrganization(relatedOrganization2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrganization3 = await Organizations.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
||||||
|
});
|
||||||
|
const Invoice3 = await Invoices.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Invoice3?.setOrganization) {
|
||||||
|
await Invoice3.setOrganization(relatedOrganization3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateMessageWithSender() {
|
async function associateMessageWithSender() {
|
||||||
@ -683,6 +896,17 @@ async function associateMessageWithSender() {
|
|||||||
if (Message2?.setSender) {
|
if (Message2?.setSender) {
|
||||||
await Message2.setSender(relatedSender2);
|
await Message2.setSender(relatedSender2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedSender3 = await Users.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Users.count())),
|
||||||
|
});
|
||||||
|
const Message3 = await Messages.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Message3?.setSender) {
|
||||||
|
await Message3.setSender(relatedSender3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateMessageWithRecipient() {
|
async function associateMessageWithRecipient() {
|
||||||
@ -718,6 +942,17 @@ async function associateMessageWithRecipient() {
|
|||||||
if (Message2?.setRecipient) {
|
if (Message2?.setRecipient) {
|
||||||
await Message2.setRecipient(relatedRecipient2);
|
await Message2.setRecipient(relatedRecipient2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedRecipient3 = await Users.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Users.count())),
|
||||||
|
});
|
||||||
|
const Message3 = await Messages.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Message3?.setRecipient) {
|
||||||
|
await Message3.setRecipient(relatedRecipient3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateMessageWithOrganization() {
|
async function associateMessageWithOrganization() {
|
||||||
@ -753,6 +988,17 @@ async function associateMessageWithOrganization() {
|
|||||||
if (Message2?.setOrganization) {
|
if (Message2?.setOrganization) {
|
||||||
await Message2.setOrganization(relatedOrganization2);
|
await Message2.setOrganization(relatedOrganization2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrganization3 = await Organizations.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
||||||
|
});
|
||||||
|
const Message3 = await Messages.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Message3?.setOrganization) {
|
||||||
|
await Message3.setOrganization(relatedOrganization3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateNotificationWithUser() {
|
async function associateNotificationWithUser() {
|
||||||
@ -788,6 +1034,17 @@ async function associateNotificationWithUser() {
|
|||||||
if (Notification2?.setUser) {
|
if (Notification2?.setUser) {
|
||||||
await Notification2.setUser(relatedUser2);
|
await Notification2.setUser(relatedUser2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedUser3 = await Users.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Users.count())),
|
||||||
|
});
|
||||||
|
const Notification3 = await Notifications.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Notification3?.setUser) {
|
||||||
|
await Notification3.setUser(relatedUser3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateNotificationWithOrganization() {
|
async function associateNotificationWithOrganization() {
|
||||||
@ -823,6 +1080,17 @@ async function associateNotificationWithOrganization() {
|
|||||||
if (Notification2?.setOrganization) {
|
if (Notification2?.setOrganization) {
|
||||||
await Notification2.setOrganization(relatedOrganization2);
|
await Notification2.setOrganization(relatedOrganization2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrganization3 = await Organizations.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
||||||
|
});
|
||||||
|
const Notification3 = await Notifications.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Notification3?.setOrganization) {
|
||||||
|
await Notification3.setOrganization(relatedOrganization3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateOrderWithClient() {
|
async function associateOrderWithClient() {
|
||||||
@ -858,6 +1126,17 @@ async function associateOrderWithClient() {
|
|||||||
if (Order2?.setClient) {
|
if (Order2?.setClient) {
|
||||||
await Order2.setClient(relatedClient2);
|
await Order2.setClient(relatedClient2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedClient3 = await Clients.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Clients.count())),
|
||||||
|
});
|
||||||
|
const Order3 = await Orders.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Order3?.setClient) {
|
||||||
|
await Order3.setClient(relatedClient3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateOrderWithProperty() {
|
async function associateOrderWithProperty() {
|
||||||
@ -893,6 +1172,17 @@ async function associateOrderWithProperty() {
|
|||||||
if (Order2?.setProperty) {
|
if (Order2?.setProperty) {
|
||||||
await Order2.setProperty(relatedProperty2);
|
await Order2.setProperty(relatedProperty2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedProperty3 = await Properties.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Properties.count())),
|
||||||
|
});
|
||||||
|
const Order3 = await Orders.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Order3?.setProperty) {
|
||||||
|
await Order3.setProperty(relatedProperty3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateOrderWithOrganization() {
|
async function associateOrderWithOrganization() {
|
||||||
@ -928,6 +1218,17 @@ async function associateOrderWithOrganization() {
|
|||||||
if (Order2?.setOrganization) {
|
if (Order2?.setOrganization) {
|
||||||
await Order2.setOrganization(relatedOrganization2);
|
await Order2.setOrganization(relatedOrganization2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrganization3 = await Organizations.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
||||||
|
});
|
||||||
|
const Order3 = await Orders.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Order3?.setOrganization) {
|
||||||
|
await Order3.setOrganization(relatedOrganization3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Similar logic for "relation_many"
|
// Similar logic for "relation_many"
|
||||||
@ -965,6 +1266,17 @@ async function associatePropertyWithOrganization() {
|
|||||||
if (Property2?.setOrganization) {
|
if (Property2?.setOrganization) {
|
||||||
await Property2.setOrganization(relatedOrganization2);
|
await Property2.setOrganization(relatedOrganization2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrganization3 = await Organizations.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
||||||
|
});
|
||||||
|
const Property3 = await Properties.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Property3?.setOrganization) {
|
||||||
|
await Property3.setOrganization(relatedOrganization3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@ -22,6 +22,13 @@ router.use(checkCrudPermissions('orders'));
|
|||||||
* type: object
|
* type: object
|
||||||
* properties:
|
* properties:
|
||||||
|
|
||||||
|
* street_address:
|
||||||
|
* type: string
|
||||||
|
* default: street_address
|
||||||
|
* Municipality:
|
||||||
|
* type: string
|
||||||
|
* default: Municipality
|
||||||
|
|
||||||
* fee:
|
* fee:
|
||||||
* type: integer
|
* type: integer
|
||||||
* format: int64
|
* format: int64
|
||||||
@ -306,7 +313,14 @@ router.get(
|
|||||||
currentUser,
|
currentUser,
|
||||||
});
|
});
|
||||||
if (filetype && filetype === 'csv') {
|
if (filetype && filetype === 'csv') {
|
||||||
const fields = ['id', 'fee', 'requested_date'];
|
const fields = [
|
||||||
|
'id',
|
||||||
|
'street_address',
|
||||||
|
'Municipality',
|
||||||
|
|
||||||
|
'fee',
|
||||||
|
'requested_date',
|
||||||
|
];
|
||||||
const opts = { fields };
|
const opts = { fields };
|
||||||
try {
|
try {
|
||||||
const csv = parse(payload.rows, opts);
|
const csv = parse(payload.rows, opts);
|
||||||
|
|||||||
@ -51,6 +51,8 @@ module.exports = class SearchService {
|
|||||||
|
|
||||||
notifications: ['message'],
|
notifications: ['message'],
|
||||||
|
|
||||||
|
orders: ['street_address', 'Municipality'],
|
||||||
|
|
||||||
properties: ['address', 'property_type'],
|
properties: ['address', 'property_type'],
|
||||||
|
|
||||||
organizations: ['name'],
|
organizations: ['name'],
|
||||||
|
|||||||
@ -126,6 +126,28 @@ const CardOrders = ({
|
|||||||
<div className='font-medium line-clamp-4'>{item.fee}</div>
|
<div className='font-medium line-clamp-4'>{item.fee}</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Street Address
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{item.street_address}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Municipality
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{item.Municipality}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -87,6 +87,18 @@ const ListOrders = ({
|
|||||||
<p className={'text-xs text-gray-500 '}>Fee</p>
|
<p className={'text-xs text-gray-500 '}>Fee</p>
|
||||||
<p className={'line-clamp-2'}>{item.fee}</p>
|
<p className={'line-clamp-2'}>{item.fee}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>
|
||||||
|
Street Address
|
||||||
|
</p>
|
||||||
|
<p className={'line-clamp-2'}>{item.street_address}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>Municipality</p>
|
||||||
|
<p className={'line-clamp-2'}>{item.Municipality}</p>
|
||||||
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
|
|||||||
@ -20,21 +20,9 @@ import _ from 'lodash';
|
|||||||
import dataFormatter from '../../helpers/dataFormatter';
|
import dataFormatter from '../../helpers/dataFormatter';
|
||||||
import { dataGridStyles } from '../../styles';
|
import { dataGridStyles } from '../../styles';
|
||||||
|
|
||||||
import ListOrders from './ListOrders';
|
|
||||||
|
|
||||||
const perPage = 10;
|
const perPage = 10;
|
||||||
|
|
||||||
/**
|
const TableSampleOrders = ({
|
||||||
* TableOrders component
|
|
||||||
* @param {Object} props
|
|
||||||
* @param {string} [props.filterStatus] - If set, will filter orders by status (e.g., "open")
|
|
||||||
* @param {Array} [props.filterItems]
|
|
||||||
* @param {Function} [props.setFilterItems]
|
|
||||||
* @param {Array} [props.filters]
|
|
||||||
* @param {boolean} [props.showGrid]
|
|
||||||
*/
|
|
||||||
const TableOrders = ({
|
|
||||||
filterStatus,
|
|
||||||
filterItems,
|
filterItems,
|
||||||
setFilterItems,
|
setFilterItems,
|
||||||
filters,
|
filters,
|
||||||
@ -75,18 +63,12 @@ const TableOrders = ({
|
|||||||
pagesList.push(i);
|
pagesList.push(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- NEW: Add filterStatus support ---
|
|
||||||
// Compose filter request for status if filterStatus is passed
|
|
||||||
const statusRequest = filterStatus ? `&status=${filterStatus}` : '';
|
|
||||||
// Use this for the initial load and when filterStatus changes
|
|
||||||
|
|
||||||
const loadData = async (page = currentPage, request = filterRequest) => {
|
const loadData = async (page = currentPage, request = filterRequest) => {
|
||||||
if (page !== currentPage) setCurrentPage(page);
|
if (page !== currentPage) setCurrentPage(page);
|
||||||
if (request !== filterRequest) setFilterRequest(request);
|
if (request !== filterRequest) setFilterRequest(request);
|
||||||
const { sort, field } = sortModel[0];
|
const { sort, field } = sortModel[0];
|
||||||
|
|
||||||
// Always apply statusRequest if filterStatus provided
|
const query = `?page=${page}&limit=${perPage}${request}&sort=${sort}&field=${field}`;
|
||||||
const query = `?page=${page}&limit=${perPage}${request}${statusRequest}&sort=${sort}&field=${field}`;
|
|
||||||
dispatch(fetch({ limit: perPage, page, query }));
|
dispatch(fetch({ limit: perPage, page, query }));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -129,8 +111,7 @@ const TableOrders = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const generateFilterRequests = useMemo(() => {
|
const generateFilterRequests = useMemo(() => {
|
||||||
let request = '&';
|
let request = '&';
|
||||||
if (Array.isArray(filterItems) && Array.isArray(filters)) {
|
|
||||||
filterItems.forEach((item) => {
|
filterItems.forEach((item) => {
|
||||||
const isRangeFilter = filters.find(
|
const isRangeFilter = filters.find(
|
||||||
(filter) =>
|
(filter) =>
|
||||||
@ -154,9 +135,8 @@ const TableOrders = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
return request;
|
||||||
return request;
|
}, [filterItems, filters]);
|
||||||
}, [filterItems, filters]);
|
|
||||||
|
|
||||||
const deleteFilter = (value) => {
|
const deleteFilter = (value) => {
|
||||||
const newItems = filterItems.filter((item) => item.id !== value);
|
const newItems = filterItems.filter((item) => item.id !== value);
|
||||||
@ -484,16 +464,7 @@ const TableOrders = ({
|
|||||||
<p>Are you sure you want to delete this item?</p>
|
<p>Are you sure you want to delete this item?</p>
|
||||||
</CardBoxModal>
|
</CardBoxModal>
|
||||||
|
|
||||||
{orders && Array.isArray(orders) && !showGrid && (
|
{dataGrid}
|
||||||
<ListOrders
|
|
||||||
orders={orders}
|
|
||||||
loading={loading}
|
|
||||||
onDelete={handleDeleteModalAction}
|
|
||||||
currentPage={currentPage}
|
|
||||||
numPages={numPages}
|
|
||||||
onPageChange={onPageChange}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{showGrid && dataGrid}
|
{showGrid && dataGrid}
|
||||||
|
|
||||||
@ -512,4 +483,4 @@ const TableOrders = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default TableOrders;
|
export default TableSampleOrders;
|
||||||
|
|||||||
@ -117,16 +117,31 @@ export const loadColumns = async (
|
|||||||
|
|
||||||
editable: hasUpdatePermission,
|
editable: hasUpdatePermission,
|
||||||
|
|
||||||
type: 'string',
|
type: 'number',
|
||||||
valueFormatter: ({ value }) =>
|
},
|
||||||
value != null
|
|
||||||
? Number(value).toLocaleString('en-US', {
|
{
|
||||||
style: 'currency',
|
field: 'street_address',
|
||||||
currency: 'CAD',
|
headerName: 'Street Address',
|
||||||
minimumFractionDigits: 2,
|
flex: 1,
|
||||||
maximumFractionDigits: 2,
|
minWidth: 120,
|
||||||
})
|
filterable: false,
|
||||||
: '',
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'Municipality',
|
||||||
|
headerName: 'Municipality',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,8 +9,6 @@ i18n
|
|||||||
.use(initReactI18next)
|
.use(initReactI18next)
|
||||||
.init({
|
.init({
|
||||||
fallbackLng: 'en',
|
fallbackLng: 'en',
|
||||||
defaultNS: 'common',
|
|
||||||
ns: ['common'],
|
|
||||||
detection: {
|
detection: {
|
||||||
order: ['localStorage', 'navigator'],
|
order: ['localStorage', 'navigator'],
|
||||||
lookupLocalStorage: 'app_lang_33651',
|
lookupLocalStorage: 'app_lang_33651',
|
||||||
|
|||||||
@ -83,6 +83,10 @@ const ClientsView = () => {
|
|||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
|
|
||||||
<th>Fee</th>
|
<th>Fee</th>
|
||||||
|
|
||||||
|
<th>Street Address</th>
|
||||||
|
|
||||||
|
<th>Municipality</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -104,6 +108,12 @@ const ClientsView = () => {
|
|||||||
<td data-label='status'>{item.status}</td>
|
<td data-label='status'>{item.status}</td>
|
||||||
|
|
||||||
<td data-label='fee'>{item.fee}</td>
|
<td data-label='fee'>{item.fee}</td>
|
||||||
|
|
||||||
|
<td data-label='street_address'>
|
||||||
|
{item.street_address}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td data-label='Municipality'>{item.Municipality}</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -185,6 +195,10 @@ const ClientsView = () => {
|
|||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
|
|
||||||
<th>Fee</th>
|
<th>Fee</th>
|
||||||
|
|
||||||
|
<th>Street Address</th>
|
||||||
|
|
||||||
|
<th>Municipality</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -206,6 +220,12 @@ const ClientsView = () => {
|
|||||||
<td data-label='status'>{item.status}</td>
|
<td data-label='status'>{item.status}</td>
|
||||||
|
|
||||||
<td data-label='fee'>{item.fee}</td>
|
<td data-label='fee'>{item.fee}</td>
|
||||||
|
|
||||||
|
<td data-label='street_address'>
|
||||||
|
{item.street_address}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td data-label='Municipality'>{item.Municipality}</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@ -49,6 +49,10 @@ const EditOrders = () => {
|
|||||||
fee: '',
|
fee: '',
|
||||||
|
|
||||||
organizations: null,
|
organizations: null,
|
||||||
|
|
||||||
|
street_address: '',
|
||||||
|
|
||||||
|
Municipality: '',
|
||||||
};
|
};
|
||||||
const [initialValues, setInitialValues] = useState(initVals);
|
const [initialValues, setInitialValues] = useState(initVals);
|
||||||
|
|
||||||
@ -177,6 +181,14 @@ const EditOrders = () => {
|
|||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Street Address'>
|
||||||
|
<Field name='street_address' placeholder='Street Address' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Municipality'>
|
||||||
|
<Field name='Municipality' placeholder='Municipality' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -49,6 +49,10 @@ const EditOrdersPage = () => {
|
|||||||
fee: '',
|
fee: '',
|
||||||
|
|
||||||
organizations: null,
|
organizations: null,
|
||||||
|
|
||||||
|
street_address: '',
|
||||||
|
|
||||||
|
Municipality: '',
|
||||||
};
|
};
|
||||||
const [initialValues, setInitialValues] = useState(initVals);
|
const [initialValues, setInitialValues] = useState(initVals);
|
||||||
|
|
||||||
@ -175,6 +179,14 @@ const EditOrdersPage = () => {
|
|||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Street Address'>
|
||||||
|
<Field name='street_address' placeholder='Street Address' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Municipality'>
|
||||||
|
<Field name='Municipality' placeholder='Municipality' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -29,6 +29,9 @@ const OrdersTablesPage = () => {
|
|||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const [filters] = useState([
|
const [filters] = useState([
|
||||||
|
{ label: 'Street Address', title: 'street_address' },
|
||||||
|
{ label: 'Municipality', title: 'Municipality' },
|
||||||
|
|
||||||
{ label: 'Fee', title: 'fee', number: 'true' },
|
{ label: 'Fee', title: 'fee', number: 'true' },
|
||||||
{ label: 'RequestedDate', title: 'requested_date', date: 'true' },
|
{ label: 'RequestedDate', title: 'requested_date', date: 'true' },
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import {
|
|||||||
} from '@mdi/js';
|
} from '@mdi/js';
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
import React, { ReactElement } from 'react';
|
import React, { ReactElement } from 'react';
|
||||||
import { useState, useEffect } from 'react';
|
|
||||||
import CardBox from '../../components/CardBox';
|
import CardBox from '../../components/CardBox';
|
||||||
import LayoutAuthenticated from '../../layouts/Authenticated';
|
import LayoutAuthenticated from '../../layouts/Authenticated';
|
||||||
import SectionMain from '../../components/SectionMain';
|
import SectionMain from '../../components/SectionMain';
|
||||||
@ -45,28 +44,16 @@ const initialValues = {
|
|||||||
fee: '',
|
fee: '',
|
||||||
|
|
||||||
organizations: '',
|
organizations: '',
|
||||||
|
|
||||||
|
street_address: '',
|
||||||
|
|
||||||
|
Municipality: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
const OrdersNew = () => {
|
const OrdersNew = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
// State for property options
|
|
||||||
const [propertyOptions, setPropertyOptions] = useState([]);
|
|
||||||
|
|
||||||
// Fetch property options from your backend API
|
|
||||||
useEffect(() => {
|
|
||||||
fetch('https://vres.flatlogic.app/api/properties') // <-- uses deployed api
|
|
||||||
.then(res => res.json())
|
|
||||||
.then(data => {
|
|
||||||
const options = data.map(property => ({
|
|
||||||
value: property.id,
|
|
||||||
label: property.name,
|
|
||||||
}));
|
|
||||||
setPropertyOptions(options);
|
|
||||||
});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
await dispatch(create(data));
|
await dispatch(create(data));
|
||||||
await router.push('/orders/orders-list');
|
await router.push('/orders/orders-list');
|
||||||
@ -105,9 +92,9 @@ const OrdersNew = () => {
|
|||||||
name='property'
|
name='property'
|
||||||
id='property'
|
id='property'
|
||||||
component={SelectField}
|
component={SelectField}
|
||||||
options={propertyOptions}
|
options={[]}
|
||||||
itemRef={'properties'}
|
itemRef={'properties'}
|
||||||
/>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
<FormField label='RequestedDate'>
|
<FormField label='RequestedDate'>
|
||||||
@ -150,6 +137,14 @@ const OrdersNew = () => {
|
|||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Street Address'>
|
||||||
|
<Field name='street_address' placeholder='Street Address' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Municipality'>
|
||||||
|
<Field name='Municipality' placeholder='Municipality' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -29,6 +29,9 @@ const OrdersTablesPage = () => {
|
|||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const [filters] = useState([
|
const [filters] = useState([
|
||||||
|
{ label: 'Street Address', title: 'street_address' },
|
||||||
|
{ label: 'Municipality', title: 'Municipality' },
|
||||||
|
|
||||||
{ label: 'Fee', title: 'fee', number: 'true' },
|
{ label: 'Fee', title: 'fee', number: 'true' },
|
||||||
{ label: 'RequestedDate', title: 'requested_date', date: 'true' },
|
{ label: 'RequestedDate', title: 'requested_date', date: 'true' },
|
||||||
|
|
||||||
@ -144,7 +147,7 @@ const OrdersTablesPage = () => {
|
|||||||
<div id='delete-rows-button'></div>
|
<div id='delete-rows-button'></div>
|
||||||
|
|
||||||
<Link href={'/orders/orders-list'}>
|
<Link href={'/orders/orders-list'}>
|
||||||
Back to <span className='capitalize'>list</span>
|
Back to <span className='capitalize'></span>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</CardBox>
|
</CardBox>
|
||||||
|
|||||||
@ -105,6 +105,16 @@ const OrdersView = () => {
|
|||||||
<p>{orders?.organizations?.name ?? 'No data'}</p>
|
<p>{orders?.organizations?.name ?? 'No data'}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Street Address</p>
|
||||||
|
<p>{orders?.street_address}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Municipality</p>
|
||||||
|
<p>{orders?.Municipality}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
|
|
||||||
<BaseButton
|
<BaseButton
|
||||||
|
|||||||
@ -417,6 +417,10 @@ const OrganizationsView = () => {
|
|||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
|
|
||||||
<th>Fee</th>
|
<th>Fee</th>
|
||||||
|
|
||||||
|
<th>Street Address</th>
|
||||||
|
|
||||||
|
<th>Municipality</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -438,6 +442,12 @@ const OrganizationsView = () => {
|
|||||||
<td data-label='status'>{item.status}</td>
|
<td data-label='status'>{item.status}</td>
|
||||||
|
|
||||||
<td data-label='fee'>{item.fee}</td>
|
<td data-label='fee'>{item.fee}</td>
|
||||||
|
|
||||||
|
<td data-label='street_address'>
|
||||||
|
{item.street_address}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td data-label='Municipality'>{item.Municipality}</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@ -203,6 +203,10 @@ const PropertiesView = () => {
|
|||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
|
|
||||||
<th>Fee</th>
|
<th>Fee</th>
|
||||||
|
|
||||||
|
<th>Street Address</th>
|
||||||
|
|
||||||
|
<th>Municipality</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -224,6 +228,12 @@ const PropertiesView = () => {
|
|||||||
<td data-label='status'>{item.status}</td>
|
<td data-label='status'>{item.status}</td>
|
||||||
|
|
||||||
<td data-label='fee'>{item.fee}</td>
|
<td data-label='fee'>{item.fee}</td>
|
||||||
|
|
||||||
|
<td data-label='street_address'>
|
||||||
|
{item.street_address}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td data-label='Municipality'>{item.Municipality}</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user