Updated via schema editor on 2025-09-24 18:08

This commit is contained in:
Flatlogic Bot 2025-09-24 18:09:35 +00:00
parent e5c4e5a9e2
commit d5f32d622a
21 changed files with 596 additions and 76 deletions

File diff suppressed because one or more lines are too long

View File

@ -18,6 +18,8 @@ module.exports = class OrdersDBApi {
requested_date: data.requested_date || null,
status: data.status || null,
fee: data.fee || null,
street_address: data.street_address || null,
Municipality: data.Municipality || null,
importHash: data.importHash || null,
createdById: currentUser.id,
updatedById: currentUser.id,
@ -51,6 +53,8 @@ module.exports = class OrdersDBApi {
requested_date: item.requested_date || null,
status: item.status || null,
fee: item.fee || null,
street_address: item.street_address || null,
Municipality: item.Municipality || null,
importHash: item.importHash || null,
createdById: currentUser.id,
updatedById: currentUser.id,
@ -81,6 +85,12 @@ module.exports = class OrdersDBApi {
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;
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) {
const [start, end] = filter.requested_dateRange;

View 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;
}
},
};

View File

@ -42,6 +42,14 @@ module.exports = function (sequelize, DataTypes) {
type: DataTypes.DECIMAL,
},
street_address: {
type: DataTypes.TEXT,
},
Municipality: {
type: DataTypes.TEXT,
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,

View File

@ -49,6 +49,16 @@ const ActivitiesData = [
// 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 = [
@ -61,7 +71,7 @@ const AppraisalsData = [
delivery_date: new Date('2023-10-05T17:00:00Z'),
status: 'assigned',
status: 'scheduled',
fee: 1500,
@ -77,7 +87,7 @@ const AppraisalsData = [
delivery_date: new Date('2023-10-06T16:00:00Z'),
status: 'assigned',
status: 'in_progress',
fee: 2000,
@ -93,12 +103,28 @@ const AppraisalsData = [
delivery_date: new Date('2023-10-07T15:00:00Z'),
status: 'delivered',
status: 'in_progress',
fee: 2500,
// 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 = [
@ -131,6 +157,16 @@ const ClientsData = [
// 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 = [
@ -169,6 +205,18 @@ const InvoicesData = [
// 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 = [
@ -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
content: 'Please confirm the inspection date.',
sent_date: new Date('2023-10-04T12:00:00Z'),
// type code here for "relation_one" field
},
];
const NotificationsData = [
@ -239,6 +299,16 @@ const NotificationsData = [
// 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 = [
@ -249,11 +319,15 @@ const OrdersData = [
requested_date: new Date('2023-10-01T09:00:00Z'),
status: 'scheduled',
status: 'delivered',
fee: 1500,
// 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'),
status: 'delivered',
status: 'in_progress',
fee: 2000,
// 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'),
status: 'delivered',
status: 'scheduled',
fee: 2500,
// 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
},
{
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 = [
@ -329,6 +439,10 @@ const OrganizationsData = [
{
name: 'Urban Appraisals',
},
{
name: 'Metro Valuations',
},
];
// Similar logic for "relation_many"
@ -366,6 +480,17 @@ async function associateUserWithOrganization() {
if (User2?.setOrganization) {
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() {
@ -401,6 +526,17 @@ async function associateActivityWithUser() {
if (Activity2?.setUser) {
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() {
@ -436,6 +572,17 @@ async function associateActivityWithOrganization() {
if (Activity2?.setOrganization) {
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() {
@ -471,6 +618,17 @@ async function associateAppraisalWithProperty() {
if (Appraisal2?.setProperty) {
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() {
@ -506,6 +664,17 @@ async function associateAppraisalWithAppraiser() {
if (Appraisal2?.setAppraiser) {
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() {
@ -541,6 +710,17 @@ async function associateAppraisalWithOrganization() {
if (Appraisal2?.setOrganization) {
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"
@ -578,6 +758,17 @@ async function associateClientWithOrganization() {
if (Client2?.setOrganization) {
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() {
@ -613,6 +804,17 @@ async function associateInvoiceWithClient() {
if (Invoice2?.setClient) {
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() {
@ -648,6 +850,17 @@ async function associateInvoiceWithOrganization() {
if (Invoice2?.setOrganization) {
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() {
@ -683,6 +896,17 @@ async function associateMessageWithSender() {
if (Message2?.setSender) {
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() {
@ -718,6 +942,17 @@ async function associateMessageWithRecipient() {
if (Message2?.setRecipient) {
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() {
@ -753,6 +988,17 @@ async function associateMessageWithOrganization() {
if (Message2?.setOrganization) {
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() {
@ -788,6 +1034,17 @@ async function associateNotificationWithUser() {
if (Notification2?.setUser) {
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() {
@ -823,6 +1080,17 @@ async function associateNotificationWithOrganization() {
if (Notification2?.setOrganization) {
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() {
@ -858,6 +1126,17 @@ async function associateOrderWithClient() {
if (Order2?.setClient) {
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() {
@ -893,6 +1172,17 @@ async function associateOrderWithProperty() {
if (Order2?.setProperty) {
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() {
@ -928,6 +1218,17 @@ async function associateOrderWithOrganization() {
if (Order2?.setOrganization) {
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"
@ -965,6 +1266,17 @@ async function associatePropertyWithOrganization() {
if (Property2?.setOrganization) {
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 = {

View File

@ -22,6 +22,13 @@ router.use(checkCrudPermissions('orders'));
* type: object
* properties:
* street_address:
* type: string
* default: street_address
* Municipality:
* type: string
* default: Municipality
* fee:
* type: integer
* format: int64
@ -306,7 +313,14 @@ router.get(
currentUser,
});
if (filetype && filetype === 'csv') {
const fields = ['id', 'fee', 'requested_date'];
const fields = [
'id',
'street_address',
'Municipality',
'fee',
'requested_date',
];
const opts = { fields };
try {
const csv = parse(payload.rows, opts);

View File

@ -51,6 +51,8 @@ module.exports = class SearchService {
notifications: ['message'],
orders: ['street_address', 'Municipality'],
properties: ['address', 'property_type'],
organizations: ['name'],

View File

@ -126,6 +126,28 @@ const CardOrders = ({
<div className='font-medium line-clamp-4'>{item.fee}</div>
</dd>
</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>
</li>
))}

View File

@ -87,6 +87,18 @@ const ListOrders = ({
<p className={'text-xs text-gray-500 '}>Fee</p>
<p className={'line-clamp-2'}>{item.fee}</p>
</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>
<ListActionsPopover
onDelete={onDelete}

View File

@ -20,21 +20,9 @@ import _ from 'lodash';
import dataFormatter from '../../helpers/dataFormatter';
import { dataGridStyles } from '../../styles';
import ListOrders from './ListOrders';
const perPage = 10;
/**
* 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,
const TableSampleOrders = ({
filterItems,
setFilterItems,
filters,
@ -75,18 +63,12 @@ const TableOrders = ({
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) => {
if (page !== currentPage) setCurrentPage(page);
if (request !== filterRequest) setFilterRequest(request);
const { sort, field } = sortModel[0];
// Always apply statusRequest if filterStatus provided
const query = `?page=${page}&limit=${perPage}${request}${statusRequest}&sort=${sort}&field=${field}`;
const query = `?page=${page}&limit=${perPage}${request}&sort=${sort}&field=${field}`;
dispatch(fetch({ limit: perPage, page, query }));
};
@ -129,8 +111,7 @@ const TableOrders = ({
};
const generateFilterRequests = useMemo(() => {
let request = '&';
if (Array.isArray(filterItems) && Array.isArray(filters)) {
let request = '&';
filterItems.forEach((item) => {
const isRangeFilter = filters.find(
(filter) =>
@ -154,9 +135,8 @@ const TableOrders = ({
}
}
});
}
return request;
}, [filterItems, filters]);
return request;
}, [filterItems, filters]);
const deleteFilter = (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>
</CardBoxModal>
{orders && Array.isArray(orders) && !showGrid && (
<ListOrders
orders={orders}
loading={loading}
onDelete={handleDeleteModalAction}
currentPage={currentPage}
numPages={numPages}
onPageChange={onPageChange}
/>
)}
{dataGrid}
{showGrid && dataGrid}
@ -512,4 +483,4 @@ const TableOrders = ({
);
};
export default TableOrders;
export default TableSampleOrders;

View File

@ -117,16 +117,31 @@ export const loadColumns = async (
editable: hasUpdatePermission,
type: 'string',
valueFormatter: ({ value }) =>
value != null
? Number(value).toLocaleString('en-US', {
style: 'currency',
currency: 'CAD',
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})
: '',
type: 'number',
},
{
field: 'street_address',
headerName: 'Street Address',
flex: 1,
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,
},
{

View File

@ -9,8 +9,6 @@ i18n
.use(initReactI18next)
.init({
fallbackLng: 'en',
defaultNS: 'common',
ns: ['common'],
detection: {
order: ['localStorage', 'navigator'],
lookupLocalStorage: 'app_lang_33651',

View File

@ -83,6 +83,10 @@ const ClientsView = () => {
<th>Status</th>
<th>Fee</th>
<th>Street Address</th>
<th>Municipality</th>
</tr>
</thead>
<tbody>
@ -104,6 +108,12 @@ const ClientsView = () => {
<td data-label='status'>{item.status}</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>
))}
</tbody>
@ -185,6 +195,10 @@ const ClientsView = () => {
<th>Status</th>
<th>Fee</th>
<th>Street Address</th>
<th>Municipality</th>
</tr>
</thead>
<tbody>
@ -206,6 +220,12 @@ const ClientsView = () => {
<td data-label='status'>{item.status}</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>
))}
</tbody>

View File

@ -49,6 +49,10 @@ const EditOrders = () => {
fee: '',
organizations: null,
street_address: '',
Municipality: '',
};
const [initialValues, setInitialValues] = useState(initVals);
@ -177,6 +181,14 @@ const EditOrders = () => {
></Field>
</FormField>
<FormField label='Street Address'>
<Field name='street_address' placeholder='Street Address' />
</FormField>
<FormField label='Municipality'>
<Field name='Municipality' placeholder='Municipality' />
</FormField>
<BaseDivider />
<BaseButtons>
<BaseButton type='submit' color='info' label='Submit' />

View File

@ -49,6 +49,10 @@ const EditOrdersPage = () => {
fee: '',
organizations: null,
street_address: '',
Municipality: '',
};
const [initialValues, setInitialValues] = useState(initVals);
@ -175,6 +179,14 @@ const EditOrdersPage = () => {
></Field>
</FormField>
<FormField label='Street Address'>
<Field name='street_address' placeholder='Street Address' />
</FormField>
<FormField label='Municipality'>
<Field name='Municipality' placeholder='Municipality' />
</FormField>
<BaseDivider />
<BaseButtons>
<BaseButton type='submit' color='info' label='Submit' />

View File

@ -29,6 +29,9 @@ const OrdersTablesPage = () => {
const dispatch = useAppDispatch();
const [filters] = useState([
{ label: 'Street Address', title: 'street_address' },
{ label: 'Municipality', title: 'Municipality' },
{ label: 'Fee', title: 'fee', number: 'true' },
{ label: 'RequestedDate', title: 'requested_date', date: 'true' },

View File

@ -6,7 +6,6 @@ import {
} from '@mdi/js';
import Head from 'next/head';
import React, { ReactElement } from 'react';
import { useState, useEffect } from 'react';
import CardBox from '../../components/CardBox';
import LayoutAuthenticated from '../../layouts/Authenticated';
import SectionMain from '../../components/SectionMain';
@ -45,28 +44,16 @@ const initialValues = {
fee: '',
organizations: '',
street_address: '',
Municipality: '',
};
const OrdersNew = () => {
const router = useRouter();
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) => {
await dispatch(create(data));
await router.push('/orders/orders-list');
@ -105,9 +92,9 @@ const OrdersNew = () => {
name='property'
id='property'
component={SelectField}
options={propertyOptions}
options={[]}
itemRef={'properties'}
/>
></Field>
</FormField>
<FormField label='RequestedDate'>
@ -150,6 +137,14 @@ const OrdersNew = () => {
></Field>
</FormField>
<FormField label='Street Address'>
<Field name='street_address' placeholder='Street Address' />
</FormField>
<FormField label='Municipality'>
<Field name='Municipality' placeholder='Municipality' />
</FormField>
<BaseDivider />
<BaseButtons>
<BaseButton type='submit' color='info' label='Submit' />

View File

@ -29,6 +29,9 @@ const OrdersTablesPage = () => {
const dispatch = useAppDispatch();
const [filters] = useState([
{ label: 'Street Address', title: 'street_address' },
{ label: 'Municipality', title: 'Municipality' },
{ label: 'Fee', title: 'fee', number: 'true' },
{ label: 'RequestedDate', title: 'requested_date', date: 'true' },
@ -144,7 +147,7 @@ const OrdersTablesPage = () => {
<div id='delete-rows-button'></div>
<Link href={'/orders/orders-list'}>
Back to <span className='capitalize'>list</span>
Back to <span className='capitalize'></span>
</Link>
</div>
</CardBox>

View File

@ -105,6 +105,16 @@ const OrdersView = () => {
<p>{orders?.organizations?.name ?? 'No data'}</p>
</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 />
<BaseButton

View File

@ -417,6 +417,10 @@ const OrganizationsView = () => {
<th>Status</th>
<th>Fee</th>
<th>Street Address</th>
<th>Municipality</th>
</tr>
</thead>
<tbody>
@ -438,6 +442,12 @@ const OrganizationsView = () => {
<td data-label='status'>{item.status}</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>
))}
</tbody>

View File

@ -203,6 +203,10 @@ const PropertiesView = () => {
<th>Status</th>
<th>Fee</th>
<th>Street Address</th>
<th>Municipality</th>
</tr>
</thead>
<tbody>
@ -224,6 +228,12 @@ const PropertiesView = () => {
<td data-label='status'>{item.status}</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>
))}
</tbody>