1.1
This commit is contained in:
parent
533bfc6767
commit
01c30269c2
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,3 +1,8 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
*/node_modules/
|
*/node_modules/
|
||||||
*/build/
|
*/build/
|
||||||
|
|
||||||
|
**/node_modules/
|
||||||
|
**/build/
|
||||||
|
.DS_Store
|
||||||
|
.env
|
||||||
2
502.html
2
502.html
@ -129,7 +129,7 @@
|
|||||||
<p class="tip">The application is currently launching. The page will automatically refresh once site is
|
<p class="tip">The application is currently launching. The page will automatically refresh once site is
|
||||||
available.</p>
|
available.</p>
|
||||||
<div class="project-info">
|
<div class="project-info">
|
||||||
<h2>Etherra</h2>
|
<h2>Powersport Rentals</h2>
|
||||||
<p>A multitenant P2P RV rental marketplace with booking and search features.</p>
|
<p>A multitenant P2P RV rental marketplace with booking and search features.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="loader-container">
|
<div class="loader-container">
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
# Etherra
|
# Powersport Rentals
|
||||||
|
|
||||||
## This project was generated by [Flatlogic Platform](https://flatlogic.com).
|
## This project was generated by [Flatlogic Platform](https://flatlogic.com).
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
|||||||
#Etherra - template backend,
|
#Powersport Rentals - template backend,
|
||||||
|
|
||||||
#### Run App on local machine:
|
#### Run App on local machine:
|
||||||
|
|
||||||
@ -38,10 +38,10 @@
|
|||||||
|
|
||||||
- Type this command to creating a new database.
|
- Type this command to creating a new database.
|
||||||
|
|
||||||
- `postgres=> CREATE DATABASE db_etherra;`
|
- `postgres=> CREATE DATABASE db_powersport_rentals;`
|
||||||
|
|
||||||
- Then give that new user privileges to the new database then quit the `psql`.
|
- Then give that new user privileges to the new database then quit the `psql`.
|
||||||
- `postgres=> GRANT ALL PRIVILEGES ON DATABASE db_etherra TO admin;`
|
- `postgres=> GRANT ALL PRIVILEGES ON DATABASE db_powersport_rentals TO admin;`
|
||||||
- `postgres=> \q`
|
- `postgres=> \q`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "etherra",
|
"name": "powersportrentals",
|
||||||
"description": "Etherra - template backend",
|
"description": "Powersport Rentals - template backend",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "npm run db:migrate && npm run db:seed && npm run watch",
|
"start": "npm run db:migrate && npm run db:seed && npm run watch",
|
||||||
"db:migrate": "sequelize-cli db:migrate",
|
"db:migrate": "sequelize-cli db:migrate",
|
||||||
|
|||||||
@ -3,7 +3,7 @@ const os = require('os');
|
|||||||
const config = {
|
const config = {
|
||||||
gcloud: {
|
gcloud: {
|
||||||
bucket: 'fldemo-files',
|
bucket: 'fldemo-files',
|
||||||
hash: '7b2b237a7ca2d27371edcb8650f737ac',
|
hash: 'afeefb9d49f5b7977577876b99532ac7',
|
||||||
},
|
},
|
||||||
bcrypt: {
|
bcrypt: {
|
||||||
saltRounds: 12,
|
saltRounds: 12,
|
||||||
@ -36,7 +36,7 @@ const config = {
|
|||||||
},
|
},
|
||||||
uploadDir: os.tmpdir(),
|
uploadDir: os.tmpdir(),
|
||||||
email: {
|
email: {
|
||||||
from: 'Etherra <app@flatlogic.app>',
|
from: 'Powersport Rentals <app@flatlogic.app>',
|
||||||
host: 'email-smtp.us-east-1.amazonaws.com',
|
host: 'email-smtp.us-east-1.amazonaws.com',
|
||||||
port: 587,
|
port: 587,
|
||||||
auth: {
|
auth: {
|
||||||
|
|||||||
@ -38,6 +38,10 @@ module.exports = class BookingsDBApi {
|
|||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await bookings.setPowersportvehicle(data.powersportvehicle || null, {
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
return bookings;
|
return bookings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,6 +120,14 @@ module.exports = class BookingsDBApi {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.powersportvehicle !== undefined) {
|
||||||
|
await bookings.setPowersportvehicle(
|
||||||
|
data.powersportvehicle,
|
||||||
|
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return bookings;
|
return bookings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,6 +201,10 @@ module.exports = class BookingsDBApi {
|
|||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
output.powersportvehicle = await bookings.getPowersportvehicle({
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,6 +286,32 @@ module.exports = class BookingsDBApi {
|
|||||||
model: db.clients,
|
model: db.clients,
|
||||||
as: 'clients',
|
as: 'clients',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
model: db.powersportvehicles,
|
||||||
|
as: 'powersportvehicle',
|
||||||
|
|
||||||
|
where: filter.powersportvehicle
|
||||||
|
? {
|
||||||
|
[Op.or]: [
|
||||||
|
{
|
||||||
|
id: {
|
||||||
|
[Op.in]: filter.powersportvehicle
|
||||||
|
.split('|')
|
||||||
|
.map((term) => Utils.uuid(term)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: {
|
||||||
|
[Op.or]: filter.powersportvehicle
|
||||||
|
.split('|')
|
||||||
|
.map((term) => ({ [Op.iLike]: `%${term}%` })),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
: {},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
if (filter) {
|
if (filter) {
|
||||||
|
|||||||
@ -137,6 +137,11 @@ module.exports = class ClientsDBApi {
|
|||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
output.powersportvehicles_clients =
|
||||||
|
await clients.getPowersportvehicles_clients({
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
609
backend/src/db/api/powersportvehicles.js
Normal file
609
backend/src/db/api/powersportvehicles.js
Normal file
@ -0,0 +1,609 @@
|
|||||||
|
const db = require('../models');
|
||||||
|
const FileDBApi = require('./file');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const Utils = require('../utils');
|
||||||
|
|
||||||
|
const Sequelize = db.Sequelize;
|
||||||
|
const Op = Sequelize.Op;
|
||||||
|
|
||||||
|
module.exports = class PowersportvehiclesDBApi {
|
||||||
|
static async create(data, options) {
|
||||||
|
const currentUser = (options && options.currentUser) || { id: null };
|
||||||
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
|
const powersportvehicles = await db.powersportvehicles.create(
|
||||||
|
{
|
||||||
|
id: data.id || undefined,
|
||||||
|
|
||||||
|
name: data.name || null,
|
||||||
|
description: data.description || null,
|
||||||
|
location: data.location || null,
|
||||||
|
pricehourly: data.pricehourly || null,
|
||||||
|
pricedaily: data.pricedaily || null,
|
||||||
|
securitydeposit: data.securitydeposit || null,
|
||||||
|
availabilitystart: data.availabilitystart || null,
|
||||||
|
availabilityend: data.availabilityend || null,
|
||||||
|
vehicletype: data.vehicletype || null,
|
||||||
|
preptimebefore: data.preptimebefore || null,
|
||||||
|
preptimebetween: data.preptimebetween || null,
|
||||||
|
importHash: data.importHash || null,
|
||||||
|
createdById: currentUser.id,
|
||||||
|
updatedById: currentUser.id,
|
||||||
|
},
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
|
||||||
|
await powersportvehicles.setClients(data.clients || null, {
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await FileDBApi.replaceRelationFiles(
|
||||||
|
{
|
||||||
|
belongsTo: db.powersportvehicles.getTableName(),
|
||||||
|
belongsToColumn: 'photos',
|
||||||
|
belongsToId: powersportvehicles.id,
|
||||||
|
},
|
||||||
|
data.photos,
|
||||||
|
options,
|
||||||
|
);
|
||||||
|
|
||||||
|
return powersportvehicles;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async bulkImport(data, options) {
|
||||||
|
const currentUser = (options && options.currentUser) || { id: null };
|
||||||
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
|
// Prepare data - wrapping individual data transformations in a map() method
|
||||||
|
const powersportvehiclesData = data.map((item, index) => ({
|
||||||
|
id: item.id || undefined,
|
||||||
|
|
||||||
|
name: item.name || null,
|
||||||
|
description: item.description || null,
|
||||||
|
location: item.location || null,
|
||||||
|
pricehourly: item.pricehourly || null,
|
||||||
|
pricedaily: item.pricedaily || null,
|
||||||
|
securitydeposit: item.securitydeposit || null,
|
||||||
|
availabilitystart: item.availabilitystart || null,
|
||||||
|
availabilityend: item.availabilityend || null,
|
||||||
|
vehicletype: item.vehicletype || null,
|
||||||
|
preptimebefore: item.preptimebefore || null,
|
||||||
|
preptimebetween: item.preptimebetween || null,
|
||||||
|
importHash: item.importHash || null,
|
||||||
|
createdById: currentUser.id,
|
||||||
|
updatedById: currentUser.id,
|
||||||
|
createdAt: new Date(Date.now() + index * 1000),
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Bulk create items
|
||||||
|
const powersportvehicles = await db.powersportvehicles.bulkCreate(
|
||||||
|
powersportvehiclesData,
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
|
||||||
|
// For each item created, replace relation files
|
||||||
|
|
||||||
|
for (let i = 0; i < powersportvehicles.length; i++) {
|
||||||
|
await FileDBApi.replaceRelationFiles(
|
||||||
|
{
|
||||||
|
belongsTo: db.powersportvehicles.getTableName(),
|
||||||
|
belongsToColumn: 'photos',
|
||||||
|
belongsToId: powersportvehicles[i].id,
|
||||||
|
},
|
||||||
|
data[i].photos,
|
||||||
|
options,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return powersportvehicles;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async update(id, data, options) {
|
||||||
|
const currentUser = (options && options.currentUser) || { id: null };
|
||||||
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
const globalAccess = currentUser.app_role?.globalAccess;
|
||||||
|
|
||||||
|
const powersportvehicles = await db.powersportvehicles.findByPk(
|
||||||
|
id,
|
||||||
|
{},
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
|
||||||
|
const updatePayload = {};
|
||||||
|
|
||||||
|
if (data.name !== undefined) updatePayload.name = data.name;
|
||||||
|
|
||||||
|
if (data.description !== undefined)
|
||||||
|
updatePayload.description = data.description;
|
||||||
|
|
||||||
|
if (data.location !== undefined) updatePayload.location = data.location;
|
||||||
|
|
||||||
|
if (data.pricehourly !== undefined)
|
||||||
|
updatePayload.pricehourly = data.pricehourly;
|
||||||
|
|
||||||
|
if (data.pricedaily !== undefined)
|
||||||
|
updatePayload.pricedaily = data.pricedaily;
|
||||||
|
|
||||||
|
if (data.securitydeposit !== undefined)
|
||||||
|
updatePayload.securitydeposit = data.securitydeposit;
|
||||||
|
|
||||||
|
if (data.availabilitystart !== undefined)
|
||||||
|
updatePayload.availabilitystart = data.availabilitystart;
|
||||||
|
|
||||||
|
if (data.availabilityend !== undefined)
|
||||||
|
updatePayload.availabilityend = data.availabilityend;
|
||||||
|
|
||||||
|
if (data.vehicletype !== undefined)
|
||||||
|
updatePayload.vehicletype = data.vehicletype;
|
||||||
|
|
||||||
|
if (data.preptimebefore !== undefined)
|
||||||
|
updatePayload.preptimebefore = data.preptimebefore;
|
||||||
|
|
||||||
|
if (data.preptimebetween !== undefined)
|
||||||
|
updatePayload.preptimebetween = data.preptimebetween;
|
||||||
|
|
||||||
|
updatePayload.updatedById = currentUser.id;
|
||||||
|
|
||||||
|
await powersportvehicles.update(updatePayload, { transaction });
|
||||||
|
|
||||||
|
if (data.clients !== undefined) {
|
||||||
|
await powersportvehicles.setClients(
|
||||||
|
data.clients,
|
||||||
|
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await FileDBApi.replaceRelationFiles(
|
||||||
|
{
|
||||||
|
belongsTo: db.powersportvehicles.getTableName(),
|
||||||
|
belongsToColumn: 'photos',
|
||||||
|
belongsToId: powersportvehicles.id,
|
||||||
|
},
|
||||||
|
data.photos,
|
||||||
|
options,
|
||||||
|
);
|
||||||
|
|
||||||
|
return powersportvehicles;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async deleteByIds(ids, options) {
|
||||||
|
const currentUser = (options && options.currentUser) || { id: null };
|
||||||
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
|
const powersportvehicles = await db.powersportvehicles.findAll({
|
||||||
|
where: {
|
||||||
|
id: {
|
||||||
|
[Op.in]: ids,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await db.sequelize.transaction(async (transaction) => {
|
||||||
|
for (const record of powersportvehicles) {
|
||||||
|
await record.update({ deletedBy: currentUser.id }, { transaction });
|
||||||
|
}
|
||||||
|
for (const record of powersportvehicles) {
|
||||||
|
await record.destroy({ transaction });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return powersportvehicles;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async remove(id, options) {
|
||||||
|
const currentUser = (options && options.currentUser) || { id: null };
|
||||||
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
|
const powersportvehicles = await db.powersportvehicles.findByPk(
|
||||||
|
id,
|
||||||
|
options,
|
||||||
|
);
|
||||||
|
|
||||||
|
await powersportvehicles.update(
|
||||||
|
{
|
||||||
|
deletedBy: currentUser.id,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
transaction,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
await powersportvehicles.destroy({
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
return powersportvehicles;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async findBy(where, options) {
|
||||||
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
|
const powersportvehicles = await db.powersportvehicles.findOne(
|
||||||
|
{ where },
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!powersportvehicles) {
|
||||||
|
return powersportvehicles;
|
||||||
|
}
|
||||||
|
|
||||||
|
const output = powersportvehicles.get({ plain: true });
|
||||||
|
|
||||||
|
output.bookings_powersportvehicle =
|
||||||
|
await powersportvehicles.getBookings_powersportvehicle({
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
output.clients = await powersportvehicles.getClients({
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
output.photos = await powersportvehicles.getPhotos({
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async findAll(filter, globalAccess, options) {
|
||||||
|
const limit = filter.limit || 0;
|
||||||
|
let offset = 0;
|
||||||
|
let where = {};
|
||||||
|
const currentPage = +filter.page;
|
||||||
|
|
||||||
|
const user = (options && options.currentUser) || null;
|
||||||
|
const userClients = (user && user.clients?.id) || null;
|
||||||
|
|
||||||
|
if (userClients) {
|
||||||
|
if (options?.currentUser?.clientsId) {
|
||||||
|
where.clientsId = options.currentUser.clientsId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
offset = currentPage * limit;
|
||||||
|
|
||||||
|
const orderBy = null;
|
||||||
|
|
||||||
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
|
let include = [
|
||||||
|
{
|
||||||
|
model: db.clients,
|
||||||
|
as: 'clients',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
model: db.file,
|
||||||
|
as: 'photos',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
if (filter) {
|
||||||
|
if (filter.id) {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
['id']: Utils.uuid(filter.id),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.name) {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
[Op.and]: Utils.ilike('powersportvehicles', 'name', filter.name),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.description) {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
[Op.and]: Utils.ilike(
|
||||||
|
'powersportvehicles',
|
||||||
|
'description',
|
||||||
|
filter.description,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.location) {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
[Op.and]: Utils.ilike(
|
||||||
|
'powersportvehicles',
|
||||||
|
'location',
|
||||||
|
filter.location,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.pricehourlyRange) {
|
||||||
|
const [start, end] = filter.pricehourlyRange;
|
||||||
|
|
||||||
|
if (start !== undefined && start !== null && start !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
pricehourly: {
|
||||||
|
...where.pricehourly,
|
||||||
|
[Op.gte]: start,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end !== undefined && end !== null && end !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
pricehourly: {
|
||||||
|
...where.pricehourly,
|
||||||
|
[Op.lte]: end,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.pricedailyRange) {
|
||||||
|
const [start, end] = filter.pricedailyRange;
|
||||||
|
|
||||||
|
if (start !== undefined && start !== null && start !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
pricedaily: {
|
||||||
|
...where.pricedaily,
|
||||||
|
[Op.gte]: start,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end !== undefined && end !== null && end !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
pricedaily: {
|
||||||
|
...where.pricedaily,
|
||||||
|
[Op.lte]: end,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.securitydepositRange) {
|
||||||
|
const [start, end] = filter.securitydepositRange;
|
||||||
|
|
||||||
|
if (start !== undefined && start !== null && start !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
securitydeposit: {
|
||||||
|
...where.securitydeposit,
|
||||||
|
[Op.gte]: start,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end !== undefined && end !== null && end !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
securitydeposit: {
|
||||||
|
...where.securitydeposit,
|
||||||
|
[Op.lte]: end,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.availabilitystartRange) {
|
||||||
|
const [start, end] = filter.availabilitystartRange;
|
||||||
|
|
||||||
|
if (start !== undefined && start !== null && start !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
availabilitystart: {
|
||||||
|
...where.availabilitystart,
|
||||||
|
[Op.gte]: start,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end !== undefined && end !== null && end !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
availabilitystart: {
|
||||||
|
...where.availabilitystart,
|
||||||
|
[Op.lte]: end,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.availabilityendRange) {
|
||||||
|
const [start, end] = filter.availabilityendRange;
|
||||||
|
|
||||||
|
if (start !== undefined && start !== null && start !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
availabilityend: {
|
||||||
|
...where.availabilityend,
|
||||||
|
[Op.gte]: start,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end !== undefined && end !== null && end !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
availabilityend: {
|
||||||
|
...where.availabilityend,
|
||||||
|
[Op.lte]: end,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.preptimebeforeRange) {
|
||||||
|
const [start, end] = filter.preptimebeforeRange;
|
||||||
|
|
||||||
|
if (start !== undefined && start !== null && start !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
preptimebefore: {
|
||||||
|
...where.preptimebefore,
|
||||||
|
[Op.gte]: start,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end !== undefined && end !== null && end !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
preptimebefore: {
|
||||||
|
...where.preptimebefore,
|
||||||
|
[Op.lte]: end,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.preptimebetweenRange) {
|
||||||
|
const [start, end] = filter.preptimebetweenRange;
|
||||||
|
|
||||||
|
if (start !== undefined && start !== null && start !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
preptimebetween: {
|
||||||
|
...where.preptimebetween,
|
||||||
|
[Op.gte]: start,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end !== undefined && end !== null && end !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
preptimebetween: {
|
||||||
|
...where.preptimebetween,
|
||||||
|
[Op.lte]: end,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.active !== undefined) {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
active: filter.active === true || filter.active === 'true',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.vehicletype) {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
vehicletype: filter.vehicletype,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.clients) {
|
||||||
|
const listItems = filter.clients.split('|').map((item) => {
|
||||||
|
return Utils.uuid(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
clientsId: { [Op.or]: listItems },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.createdAtRange) {
|
||||||
|
const [start, end] = filter.createdAtRange;
|
||||||
|
|
||||||
|
if (start !== undefined && start !== null && start !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
['createdAt']: {
|
||||||
|
...where.createdAt,
|
||||||
|
[Op.gte]: start,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end !== undefined && end !== null && end !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
['createdAt']: {
|
||||||
|
...where.createdAt,
|
||||||
|
[Op.lte]: end,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (globalAccess) {
|
||||||
|
delete where.clientsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryOptions = {
|
||||||
|
where,
|
||||||
|
include,
|
||||||
|
distinct: true,
|
||||||
|
order:
|
||||||
|
filter.field && filter.sort
|
||||||
|
? [[filter.field, filter.sort]]
|
||||||
|
: [['createdAt', 'desc']],
|
||||||
|
transaction: options?.transaction,
|
||||||
|
logging: console.log,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!options?.countOnly) {
|
||||||
|
queryOptions.limit = limit ? Number(limit) : undefined;
|
||||||
|
queryOptions.offset = offset ? Number(offset) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { rows, count } = await db.powersportvehicles.findAndCountAll(
|
||||||
|
queryOptions,
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
rows: options?.countOnly ? [] : rows,
|
||||||
|
count: count,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error executing query:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async findAllAutocomplete(
|
||||||
|
query,
|
||||||
|
limit,
|
||||||
|
offset,
|
||||||
|
globalAccess,
|
||||||
|
organizationId,
|
||||||
|
) {
|
||||||
|
let where = {};
|
||||||
|
|
||||||
|
if (!globalAccess && organizationId) {
|
||||||
|
where.organizationId = organizationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query) {
|
||||||
|
where = {
|
||||||
|
[Op.or]: [
|
||||||
|
{ ['id']: Utils.uuid(query) },
|
||||||
|
Utils.ilike('powersportvehicles', 'name', query),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const records = await db.powersportvehicles.findAll({
|
||||||
|
attributes: ['id', 'name'],
|
||||||
|
where,
|
||||||
|
limit: limit ? Number(limit) : undefined,
|
||||||
|
offset: offset ? Number(offset) : undefined,
|
||||||
|
orderBy: [['name', 'ASC']],
|
||||||
|
});
|
||||||
|
|
||||||
|
return records.map((record) => ({
|
||||||
|
id: record.id,
|
||||||
|
label: record.name,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -21,6 +21,7 @@ module.exports = class VehiclesDBApi {
|
|||||||
price_hourly: data.price_hourly || null,
|
price_hourly: data.price_hourly || null,
|
||||||
price_daily: data.price_daily || null,
|
price_daily: data.price_daily || null,
|
||||||
security_deposit: data.security_deposit || null,
|
security_deposit: data.security_deposit || null,
|
||||||
|
vehicletype: data.vehicletype || null,
|
||||||
importHash: data.importHash || null,
|
importHash: data.importHash || null,
|
||||||
createdById: currentUser.id,
|
createdById: currentUser.id,
|
||||||
updatedById: currentUser.id,
|
updatedById: currentUser.id,
|
||||||
@ -67,6 +68,7 @@ module.exports = class VehiclesDBApi {
|
|||||||
price_hourly: item.price_hourly || null,
|
price_hourly: item.price_hourly || null,
|
||||||
price_daily: item.price_daily || null,
|
price_daily: item.price_daily || null,
|
||||||
security_deposit: item.security_deposit || null,
|
security_deposit: item.security_deposit || null,
|
||||||
|
vehicletype: item.vehicletype || null,
|
||||||
importHash: item.importHash || null,
|
importHash: item.importHash || null,
|
||||||
createdById: currentUser.id,
|
createdById: currentUser.id,
|
||||||
updatedById: currentUser.id,
|
updatedById: currentUser.id,
|
||||||
@ -120,6 +122,9 @@ module.exports = class VehiclesDBApi {
|
|||||||
if (data.security_deposit !== undefined)
|
if (data.security_deposit !== undefined)
|
||||||
updatePayload.security_deposit = data.security_deposit;
|
updatePayload.security_deposit = data.security_deposit;
|
||||||
|
|
||||||
|
if (data.vehicletype !== undefined)
|
||||||
|
updatePayload.vehicletype = data.vehicletype;
|
||||||
|
|
||||||
updatePayload.updatedById = currentUser.id;
|
updatePayload.updatedById = currentUser.id;
|
||||||
|
|
||||||
await vehicles.update(updatePayload, { transaction });
|
await vehicles.update(updatePayload, { transaction });
|
||||||
@ -411,6 +416,13 @@ module.exports = class VehiclesDBApi {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filter.vehicletype) {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
vehicletype: filter.vehicletype,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (filter.clients) {
|
if (filter.clients) {
|
||||||
const listItems = filter.clients.split('|').map((item) => {
|
const listItems = filter.clients.split('|').map((item) => {
|
||||||
return Utils.uuid(item);
|
return Utils.uuid(item);
|
||||||
|
|||||||
@ -13,7 +13,7 @@ module.exports = {
|
|||||||
username: 'postgres',
|
username: 'postgres',
|
||||||
dialect: 'postgres',
|
dialect: 'postgres',
|
||||||
password: '',
|
password: '',
|
||||||
database: 'db_etherra',
|
database: 'db_powersport_rentals',
|
||||||
host: process.env.DB_HOST || 'localhost',
|
host: process.env.DB_HOST || 'localhost',
|
||||||
logging: console.log,
|
logging: console.log,
|
||||||
seederStorage: 'sequelize',
|
seederStorage: 'sequelize',
|
||||||
|
|||||||
51
backend/src/db/migrations/1757449078196.js
Normal file
51
backend/src/db/migrations/1757449078196.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
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(
|
||||||
|
'vehicles',
|
||||||
|
'vehicletype',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.ENUM,
|
||||||
|
|
||||||
|
values: ['value'],
|
||||||
|
},
|
||||||
|
{ 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('vehicles', 'vehicletype', {
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
90
backend/src/db/migrations/1757450562030.js
Normal file
90
backend/src/db/migrations/1757450562030.js
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
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.createTable(
|
||||||
|
'powersportvehicles',
|
||||||
|
{
|
||||||
|
id: {
|
||||||
|
type: Sequelize.DataTypes.UUID,
|
||||||
|
defaultValue: Sequelize.DataTypes.UUIDV4,
|
||||||
|
primaryKey: true,
|
||||||
|
},
|
||||||
|
createdById: {
|
||||||
|
type: Sequelize.DataTypes.UUID,
|
||||||
|
references: {
|
||||||
|
key: 'id',
|
||||||
|
model: 'users',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
updatedById: {
|
||||||
|
type: Sequelize.DataTypes.UUID,
|
||||||
|
references: {
|
||||||
|
key: 'id',
|
||||||
|
model: 'users',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
createdAt: { type: Sequelize.DataTypes.DATE },
|
||||||
|
updatedAt: { type: Sequelize.DataTypes.DATE },
|
||||||
|
deletedAt: { type: Sequelize.DataTypes.DATE },
|
||||||
|
importHash: {
|
||||||
|
type: Sequelize.DataTypes.STRING(255),
|
||||||
|
allowNull: true,
|
||||||
|
unique: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryInterface.addColumn(
|
||||||
|
'powersportvehicles',
|
||||||
|
'clientsId',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.UUID,
|
||||||
|
|
||||||
|
references: {
|
||||||
|
model: 'clients',
|
||||||
|
key: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ 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('powersportvehicles', 'clientsId', {
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await queryInterface.dropTable('powersportvehicles', { transaction });
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
49
backend/src/db/migrations/1757450589992.js
Normal file
49
backend/src/db/migrations/1757450589992.js
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
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(
|
||||||
|
'powersportvehicles',
|
||||||
|
'name',
|
||||||
|
{
|
||||||
|
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('powersportvehicles', 'name', {
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
49
backend/src/db/migrations/1757450623285.js
Normal file
49
backend/src/db/migrations/1757450623285.js
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
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(
|
||||||
|
'powersportvehicles',
|
||||||
|
'description',
|
||||||
|
{
|
||||||
|
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('powersportvehicles', 'description', {
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
36
backend/src/db/migrations/1757450719241.js
Normal file
36
backend/src/db/migrations/1757450719241.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
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 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 transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
49
backend/src/db/migrations/1757450790548.js
Normal file
49
backend/src/db/migrations/1757450790548.js
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
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(
|
||||||
|
'powersportvehicles',
|
||||||
|
'location',
|
||||||
|
{
|
||||||
|
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('powersportvehicles', 'location', {
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
49
backend/src/db/migrations/1757450827833.js
Normal file
49
backend/src/db/migrations/1757450827833.js
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
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(
|
||||||
|
'powersportvehicles',
|
||||||
|
'pricehourly',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.DECIMAL,
|
||||||
|
},
|
||||||
|
{ 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('powersportvehicles', 'pricehourly', {
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
49
backend/src/db/migrations/1757450860278.js
Normal file
49
backend/src/db/migrations/1757450860278.js
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
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(
|
||||||
|
'powersportvehicles',
|
||||||
|
'pricedaily',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.DECIMAL,
|
||||||
|
},
|
||||||
|
{ 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('powersportvehicles', 'pricedaily', {
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
51
backend/src/db/migrations/1757450889961.js
Normal file
51
backend/src/db/migrations/1757450889961.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
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(
|
||||||
|
'powersportvehicles',
|
||||||
|
'securitydeposit',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.DECIMAL,
|
||||||
|
},
|
||||||
|
{ 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(
|
||||||
|
'powersportvehicles',
|
||||||
|
'securitydeposit',
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
51
backend/src/db/migrations/1757450927629.js
Normal file
51
backend/src/db/migrations/1757450927629.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
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(
|
||||||
|
'powersportvehicles',
|
||||||
|
'availabilitystart',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{ 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(
|
||||||
|
'powersportvehicles',
|
||||||
|
'availabilitystart',
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
51
backend/src/db/migrations/1757450953122.js
Normal file
51
backend/src/db/migrations/1757450953122.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
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(
|
||||||
|
'powersportvehicles',
|
||||||
|
'availabilityend',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{ 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(
|
||||||
|
'powersportvehicles',
|
||||||
|
'availabilityend',
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
54
backend/src/db/migrations/1757450984490.js
Normal file
54
backend/src/db/migrations/1757450984490.js
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
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(
|
||||||
|
'bookings',
|
||||||
|
'powersportvehicleId',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.UUID,
|
||||||
|
|
||||||
|
references: {
|
||||||
|
model: 'powersportvehicles',
|
||||||
|
key: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ 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('bookings', 'powersportvehicleId', {
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
51
backend/src/db/migrations/1757451017415.js
Normal file
51
backend/src/db/migrations/1757451017415.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
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(
|
||||||
|
'powersportvehicles',
|
||||||
|
'vehicletype',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.ENUM,
|
||||||
|
|
||||||
|
values: ['value'],
|
||||||
|
},
|
||||||
|
{ 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('powersportvehicles', 'vehicletype', {
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
51
backend/src/db/migrations/1757451046441.js
Normal file
51
backend/src/db/migrations/1757451046441.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
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(
|
||||||
|
'powersportvehicles',
|
||||||
|
'preptimebefore',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.INTEGER,
|
||||||
|
},
|
||||||
|
{ 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(
|
||||||
|
'powersportvehicles',
|
||||||
|
'preptimebefore',
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
51
backend/src/db/migrations/1757451083313.js
Normal file
51
backend/src/db/migrations/1757451083313.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
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(
|
||||||
|
'powersportvehicles',
|
||||||
|
'preptimebetween',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.INTEGER,
|
||||||
|
},
|
||||||
|
{ 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(
|
||||||
|
'powersportvehicles',
|
||||||
|
'preptimebetween',
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
@ -74,6 +74,14 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
constraints: false,
|
constraints: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
db.bookings.belongsTo(db.powersportvehicles, {
|
||||||
|
as: 'powersportvehicle',
|
||||||
|
foreignKey: {
|
||||||
|
name: 'powersportvehicleId',
|
||||||
|
},
|
||||||
|
constraints: false,
|
||||||
|
});
|
||||||
|
|
||||||
db.bookings.belongsTo(db.users, {
|
db.bookings.belongsTo(db.users, {
|
||||||
as: 'createdBy',
|
as: 'createdBy',
|
||||||
});
|
});
|
||||||
|
|||||||
@ -58,6 +58,14 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
constraints: false,
|
constraints: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
db.clients.hasMany(db.powersportvehicles, {
|
||||||
|
as: 'powersportvehicles_clients',
|
||||||
|
foreignKey: {
|
||||||
|
name: 'clientsId',
|
||||||
|
},
|
||||||
|
constraints: false,
|
||||||
|
});
|
||||||
|
|
||||||
//end loop
|
//end loop
|
||||||
|
|
||||||
db.clients.belongsTo(db.users, {
|
db.clients.belongsTo(db.users, {
|
||||||
|
|||||||
117
backend/src/db/models/powersportvehicles.js
Normal file
117
backend/src/db/models/powersportvehicles.js
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
const config = require('../../config');
|
||||||
|
const providers = config.providers;
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const bcrypt = require('bcrypt');
|
||||||
|
const moment = require('moment');
|
||||||
|
|
||||||
|
module.exports = function (sequelize, DataTypes) {
|
||||||
|
const powersportvehicles = sequelize.define(
|
||||||
|
'powersportvehicles',
|
||||||
|
{
|
||||||
|
id: {
|
||||||
|
type: DataTypes.UUID,
|
||||||
|
defaultValue: DataTypes.UUIDV4,
|
||||||
|
primaryKey: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
name: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
|
},
|
||||||
|
|
||||||
|
description: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
|
},
|
||||||
|
|
||||||
|
location: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
|
},
|
||||||
|
|
||||||
|
pricehourly: {
|
||||||
|
type: DataTypes.DECIMAL,
|
||||||
|
},
|
||||||
|
|
||||||
|
pricedaily: {
|
||||||
|
type: DataTypes.DECIMAL,
|
||||||
|
},
|
||||||
|
|
||||||
|
securitydeposit: {
|
||||||
|
type: DataTypes.DECIMAL,
|
||||||
|
},
|
||||||
|
|
||||||
|
availabilitystart: {
|
||||||
|
type: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
|
||||||
|
availabilityend: {
|
||||||
|
type: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
|
||||||
|
vehicletype: {
|
||||||
|
type: DataTypes.ENUM,
|
||||||
|
|
||||||
|
values: ['value'],
|
||||||
|
},
|
||||||
|
|
||||||
|
preptimebefore: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
},
|
||||||
|
|
||||||
|
preptimebetween: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
},
|
||||||
|
|
||||||
|
importHash: {
|
||||||
|
type: DataTypes.STRING(255),
|
||||||
|
allowNull: true,
|
||||||
|
unique: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
paranoid: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
powersportvehicles.associate = (db) => {
|
||||||
|
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
||||||
|
|
||||||
|
db.powersportvehicles.hasMany(db.bookings, {
|
||||||
|
as: 'bookings_powersportvehicle',
|
||||||
|
foreignKey: {
|
||||||
|
name: 'powersportvehicleId',
|
||||||
|
},
|
||||||
|
constraints: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
//end loop
|
||||||
|
|
||||||
|
db.powersportvehicles.belongsTo(db.clients, {
|
||||||
|
as: 'clients',
|
||||||
|
foreignKey: {
|
||||||
|
name: 'clientsId',
|
||||||
|
},
|
||||||
|
constraints: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
db.powersportvehicles.hasMany(db.file, {
|
||||||
|
as: 'photos',
|
||||||
|
foreignKey: 'belongsToId',
|
||||||
|
constraints: false,
|
||||||
|
scope: {
|
||||||
|
belongsTo: db.powersportvehicles.getTableName(),
|
||||||
|
belongsToColumn: 'photos',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
db.powersportvehicles.belongsTo(db.users, {
|
||||||
|
as: 'createdBy',
|
||||||
|
});
|
||||||
|
|
||||||
|
db.powersportvehicles.belongsTo(db.users, {
|
||||||
|
as: 'updatedBy',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return powersportvehicles;
|
||||||
|
};
|
||||||
@ -38,6 +38,12 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
type: DataTypes.DECIMAL,
|
type: DataTypes.DECIMAL,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
vehicletype: {
|
||||||
|
type: DataTypes.ENUM,
|
||||||
|
|
||||||
|
values: ['value'],
|
||||||
|
},
|
||||||
|
|
||||||
importHash: {
|
importHash: {
|
||||||
type: DataTypes.STRING(255),
|
type: DataTypes.STRING(255),
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
|
|||||||
@ -107,6 +107,7 @@ module.exports = {
|
|||||||
'roles',
|
'roles',
|
||||||
'permissions',
|
'permissions',
|
||||||
'clients',
|
'clients',
|
||||||
|
'powersportvehicles',
|
||||||
,
|
,
|
||||||
];
|
];
|
||||||
await queryInterface.bulkInsert(
|
await queryInterface.bulkInsert(
|
||||||
@ -537,6 +538,31 @@ primary key ("roles_permissionsId", "permissionId")
|
|||||||
permissionId: getId('DELETE_VEHICLES'),
|
permissionId: getId('DELETE_VEHICLES'),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
createdAt,
|
||||||
|
updatedAt,
|
||||||
|
roles_permissionsId: getId('Administrator'),
|
||||||
|
permissionId: getId('CREATE_POWERSPORTVEHICLES'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
createdAt,
|
||||||
|
updatedAt,
|
||||||
|
roles_permissionsId: getId('Administrator'),
|
||||||
|
permissionId: getId('READ_POWERSPORTVEHICLES'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
createdAt,
|
||||||
|
updatedAt,
|
||||||
|
roles_permissionsId: getId('Administrator'),
|
||||||
|
permissionId: getId('UPDATE_POWERSPORTVEHICLES'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
createdAt,
|
||||||
|
updatedAt,
|
||||||
|
roles_permissionsId: getId('Administrator'),
|
||||||
|
permissionId: getId('DELETE_POWERSPORTVEHICLES'),
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
createdAt,
|
createdAt,
|
||||||
updatedAt,
|
updatedAt,
|
||||||
@ -687,6 +713,31 @@ primary key ("roles_permissionsId", "permissionId")
|
|||||||
permissionId: getId('DELETE_CLIENTS'),
|
permissionId: getId('DELETE_CLIENTS'),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
createdAt,
|
||||||
|
updatedAt,
|
||||||
|
roles_permissionsId: getId('SuperAdmin'),
|
||||||
|
permissionId: getId('CREATE_POWERSPORTVEHICLES'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
createdAt,
|
||||||
|
updatedAt,
|
||||||
|
roles_permissionsId: getId('SuperAdmin'),
|
||||||
|
permissionId: getId('READ_POWERSPORTVEHICLES'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
createdAt,
|
||||||
|
updatedAt,
|
||||||
|
roles_permissionsId: getId('SuperAdmin'),
|
||||||
|
permissionId: getId('UPDATE_POWERSPORTVEHICLES'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
createdAt,
|
||||||
|
updatedAt,
|
||||||
|
roles_permissionsId: getId('SuperAdmin'),
|
||||||
|
permissionId: getId('DELETE_POWERSPORTVEHICLES'),
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
createdAt,
|
createdAt,
|
||||||
updatedAt,
|
updatedAt,
|
||||||
|
|||||||
@ -7,6 +7,8 @@ const Vehicles = db.vehicles;
|
|||||||
|
|
||||||
const Clients = db.clients;
|
const Clients = db.clients;
|
||||||
|
|
||||||
|
const Powersportvehicles = db.powersportvehicles;
|
||||||
|
|
||||||
const BookingsData = [
|
const BookingsData = [
|
||||||
{
|
{
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
@ -22,6 +24,8 @@ const BookingsData = [
|
|||||||
total_price: 1200,
|
total_price: 1200,
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -33,11 +37,13 @@ const BookingsData = [
|
|||||||
|
|
||||||
end_date: new Date('2023-11-12T09:00:00Z'),
|
end_date: new Date('2023-11-12T09:00:00Z'),
|
||||||
|
|
||||||
status: 'completed',
|
status: 'cancelled',
|
||||||
|
|
||||||
total_price: 360,
|
total_price: 360,
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -49,41 +55,11 @@ const BookingsData = [
|
|||||||
|
|
||||||
end_date: new Date('2023-11-20T08:00:00Z'),
|
end_date: new Date('2023-11-20T08:00:00Z'),
|
||||||
|
|
||||||
status: 'denied',
|
status: 'approved',
|
||||||
|
|
||||||
total_price: 1200,
|
total_price: 1200,
|
||||||
|
|
||||||
// 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
|
|
||||||
|
|
||||||
start_date: new Date('2023-11-25T07:00:00Z'),
|
|
||||||
|
|
||||||
end_date: new Date('2023-11-30T07:00:00Z'),
|
|
||||||
|
|
||||||
status: 'completed',
|
|
||||||
|
|
||||||
total_price: 1350,
|
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
// type code here for "relation_one" field
|
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
|
||||||
|
|
||||||
start_date: new Date('2023-12-01T06:00:00Z'),
|
|
||||||
|
|
||||||
end_date: new Date('2023-12-05T06:00:00Z'),
|
|
||||||
|
|
||||||
status: 'cancelled',
|
|
||||||
|
|
||||||
total_price: 840,
|
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
},
|
},
|
||||||
@ -110,6 +86,8 @@ const VehiclesData = [
|
|||||||
// type code here for "relation_many" field
|
// type code here for "relation_many" field
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
vehicletype: 'value',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -132,6 +110,8 @@ const VehiclesData = [
|
|||||||
// type code here for "relation_many" field
|
// type code here for "relation_many" field
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
vehicletype: 'value',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -154,50 +134,8 @@ const VehiclesData = [
|
|||||||
// type code here for "relation_many" field
|
// type code here for "relation_many" field
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
},
|
|
||||||
|
|
||||||
{
|
vehicletype: 'value',
|
||||||
title: 'Adventure Van',
|
|
||||||
|
|
||||||
description: 'A rugged van equipped for off-road adventures.',
|
|
||||||
|
|
||||||
// type code here for "images" field
|
|
||||||
|
|
||||||
location: 'Denver, CO',
|
|
||||||
|
|
||||||
price_hourly: 45,
|
|
||||||
|
|
||||||
price_daily: 270,
|
|
||||||
|
|
||||||
security_deposit: 450,
|
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
|
||||||
|
|
||||||
// type code here for "relation_many" field
|
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
title: 'Classic Trailer',
|
|
||||||
|
|
||||||
description: 'A vintage trailer with a charming retro feel.',
|
|
||||||
|
|
||||||
// type code here for "images" field
|
|
||||||
|
|
||||||
location: 'Portland, OR',
|
|
||||||
|
|
||||||
price_hourly: 35,
|
|
||||||
|
|
||||||
price_daily: 210,
|
|
||||||
|
|
||||||
security_deposit: 350,
|
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
|
||||||
|
|
||||||
// type code here for "relation_many" field
|
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -213,13 +151,91 @@ const ClientsData = [
|
|||||||
{
|
{
|
||||||
name: 'Luxury Escapes',
|
name: 'Luxury Escapes',
|
||||||
},
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const PowersportvehiclesData = [
|
||||||
{
|
{
|
||||||
name: 'Budget Travels',
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
name: 'Carl Linnaeus',
|
||||||
|
|
||||||
|
description: 'Albrecht von Haller',
|
||||||
|
|
||||||
|
// type code here for "images" field
|
||||||
|
|
||||||
|
location: 'Edwin Hubble',
|
||||||
|
|
||||||
|
pricehourly: 35.85,
|
||||||
|
|
||||||
|
pricedaily: 86.25,
|
||||||
|
|
||||||
|
securitydeposit: 32.01,
|
||||||
|
|
||||||
|
availabilitystart: new Date(Date.now()),
|
||||||
|
|
||||||
|
availabilityend: new Date(Date.now()),
|
||||||
|
|
||||||
|
vehicletype: 'value',
|
||||||
|
|
||||||
|
preptimebefore: 7,
|
||||||
|
|
||||||
|
preptimebetween: 4,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'Eco-Friendly Tours',
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
name: 'Christiaan Huygens',
|
||||||
|
|
||||||
|
description: 'Lucretius',
|
||||||
|
|
||||||
|
// type code here for "images" field
|
||||||
|
|
||||||
|
location: 'Richard Feynman',
|
||||||
|
|
||||||
|
pricehourly: 73.21,
|
||||||
|
|
||||||
|
pricedaily: 91.22,
|
||||||
|
|
||||||
|
securitydeposit: 75.97,
|
||||||
|
|
||||||
|
availabilitystart: new Date(Date.now()),
|
||||||
|
|
||||||
|
availabilityend: new Date(Date.now()),
|
||||||
|
|
||||||
|
vehicletype: 'value',
|
||||||
|
|
||||||
|
preptimebefore: 3,
|
||||||
|
|
||||||
|
preptimebetween: 9,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
name: 'J. Robert Oppenheimer',
|
||||||
|
|
||||||
|
description: 'Richard Feynman',
|
||||||
|
|
||||||
|
// type code here for "images" field
|
||||||
|
|
||||||
|
location: 'Charles Lyell',
|
||||||
|
|
||||||
|
pricehourly: 89.83,
|
||||||
|
|
||||||
|
pricedaily: 34.17,
|
||||||
|
|
||||||
|
securitydeposit: 94.42,
|
||||||
|
|
||||||
|
availabilitystart: new Date(Date.now()),
|
||||||
|
|
||||||
|
availabilityend: new Date(Date.now()),
|
||||||
|
|
||||||
|
vehicletype: 'value',
|
||||||
|
|
||||||
|
preptimebefore: 8,
|
||||||
|
|
||||||
|
preptimebetween: 9,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -258,28 +274,6 @@ async function associateUserWithClient() {
|
|||||||
if (User2?.setClient) {
|
if (User2?.setClient) {
|
||||||
await User2.setClient(relatedClient2);
|
await User2.setClient(relatedClient2);
|
||||||
}
|
}
|
||||||
|
|
||||||
const relatedClient3 = await Clients.findOne({
|
|
||||||
offset: Math.floor(Math.random() * (await Clients.count())),
|
|
||||||
});
|
|
||||||
const User3 = await Users.findOne({
|
|
||||||
order: [['id', 'ASC']],
|
|
||||||
offset: 3,
|
|
||||||
});
|
|
||||||
if (User3?.setClient) {
|
|
||||||
await User3.setClient(relatedClient3);
|
|
||||||
}
|
|
||||||
|
|
||||||
const relatedClient4 = await Clients.findOne({
|
|
||||||
offset: Math.floor(Math.random() * (await Clients.count())),
|
|
||||||
});
|
|
||||||
const User4 = await Users.findOne({
|
|
||||||
order: [['id', 'ASC']],
|
|
||||||
offset: 4,
|
|
||||||
});
|
|
||||||
if (User4?.setClient) {
|
|
||||||
await User4.setClient(relatedClient4);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateBookingWithVehicle() {
|
async function associateBookingWithVehicle() {
|
||||||
@ -315,28 +309,6 @@ async function associateBookingWithVehicle() {
|
|||||||
if (Booking2?.setVehicle) {
|
if (Booking2?.setVehicle) {
|
||||||
await Booking2.setVehicle(relatedVehicle2);
|
await Booking2.setVehicle(relatedVehicle2);
|
||||||
}
|
}
|
||||||
|
|
||||||
const relatedVehicle3 = await Vehicles.findOne({
|
|
||||||
offset: Math.floor(Math.random() * (await Vehicles.count())),
|
|
||||||
});
|
|
||||||
const Booking3 = await Bookings.findOne({
|
|
||||||
order: [['id', 'ASC']],
|
|
||||||
offset: 3,
|
|
||||||
});
|
|
||||||
if (Booking3?.setVehicle) {
|
|
||||||
await Booking3.setVehicle(relatedVehicle3);
|
|
||||||
}
|
|
||||||
|
|
||||||
const relatedVehicle4 = await Vehicles.findOne({
|
|
||||||
offset: Math.floor(Math.random() * (await Vehicles.count())),
|
|
||||||
});
|
|
||||||
const Booking4 = await Bookings.findOne({
|
|
||||||
order: [['id', 'ASC']],
|
|
||||||
offset: 4,
|
|
||||||
});
|
|
||||||
if (Booking4?.setVehicle) {
|
|
||||||
await Booking4.setVehicle(relatedVehicle4);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateBookingWithRentee() {
|
async function associateBookingWithRentee() {
|
||||||
@ -372,28 +344,6 @@ async function associateBookingWithRentee() {
|
|||||||
if (Booking2?.setRentee) {
|
if (Booking2?.setRentee) {
|
||||||
await Booking2.setRentee(relatedRentee2);
|
await Booking2.setRentee(relatedRentee2);
|
||||||
}
|
}
|
||||||
|
|
||||||
const relatedRentee3 = await Users.findOne({
|
|
||||||
offset: Math.floor(Math.random() * (await Users.count())),
|
|
||||||
});
|
|
||||||
const Booking3 = await Bookings.findOne({
|
|
||||||
order: [['id', 'ASC']],
|
|
||||||
offset: 3,
|
|
||||||
});
|
|
||||||
if (Booking3?.setRentee) {
|
|
||||||
await Booking3.setRentee(relatedRentee3);
|
|
||||||
}
|
|
||||||
|
|
||||||
const relatedRentee4 = await Users.findOne({
|
|
||||||
offset: Math.floor(Math.random() * (await Users.count())),
|
|
||||||
});
|
|
||||||
const Booking4 = await Bookings.findOne({
|
|
||||||
order: [['id', 'ASC']],
|
|
||||||
offset: 4,
|
|
||||||
});
|
|
||||||
if (Booking4?.setRentee) {
|
|
||||||
await Booking4.setRentee(relatedRentee4);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateBookingWithClient() {
|
async function associateBookingWithClient() {
|
||||||
@ -429,27 +379,40 @@ async function associateBookingWithClient() {
|
|||||||
if (Booking2?.setClient) {
|
if (Booking2?.setClient) {
|
||||||
await Booking2.setClient(relatedClient2);
|
await Booking2.setClient(relatedClient2);
|
||||||
}
|
}
|
||||||
|
|
||||||
const relatedClient3 = await Clients.findOne({
|
|
||||||
offset: Math.floor(Math.random() * (await Clients.count())),
|
|
||||||
});
|
|
||||||
const Booking3 = await Bookings.findOne({
|
|
||||||
order: [['id', 'ASC']],
|
|
||||||
offset: 3,
|
|
||||||
});
|
|
||||||
if (Booking3?.setClient) {
|
|
||||||
await Booking3.setClient(relatedClient3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const relatedClient4 = await Clients.findOne({
|
async function associateBookingWithPowersportvehicle() {
|
||||||
offset: Math.floor(Math.random() * (await Clients.count())),
|
const relatedPowersportvehicle0 = await Powersportvehicles.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Powersportvehicles.count())),
|
||||||
});
|
});
|
||||||
const Booking4 = await Bookings.findOne({
|
const Booking0 = await Bookings.findOne({
|
||||||
order: [['id', 'ASC']],
|
order: [['id', 'ASC']],
|
||||||
offset: 4,
|
offset: 0,
|
||||||
});
|
});
|
||||||
if (Booking4?.setClient) {
|
if (Booking0?.setPowersportvehicle) {
|
||||||
await Booking4.setClient(relatedClient4);
|
await Booking0.setPowersportvehicle(relatedPowersportvehicle0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const relatedPowersportvehicle1 = await Powersportvehicles.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Powersportvehicles.count())),
|
||||||
|
});
|
||||||
|
const Booking1 = await Bookings.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 1,
|
||||||
|
});
|
||||||
|
if (Booking1?.setPowersportvehicle) {
|
||||||
|
await Booking1.setPowersportvehicle(relatedPowersportvehicle1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const relatedPowersportvehicle2 = await Powersportvehicles.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Powersportvehicles.count())),
|
||||||
|
});
|
||||||
|
const Booking2 = await Bookings.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 2,
|
||||||
|
});
|
||||||
|
if (Booking2?.setPowersportvehicle) {
|
||||||
|
await Booking2.setPowersportvehicle(relatedPowersportvehicle2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,28 +449,6 @@ async function associateVehicleWithOwner() {
|
|||||||
if (Vehicle2?.setOwner) {
|
if (Vehicle2?.setOwner) {
|
||||||
await Vehicle2.setOwner(relatedOwner2);
|
await Vehicle2.setOwner(relatedOwner2);
|
||||||
}
|
}
|
||||||
|
|
||||||
const relatedOwner3 = await Users.findOne({
|
|
||||||
offset: Math.floor(Math.random() * (await Users.count())),
|
|
||||||
});
|
|
||||||
const Vehicle3 = await Vehicles.findOne({
|
|
||||||
order: [['id', 'ASC']],
|
|
||||||
offset: 3,
|
|
||||||
});
|
|
||||||
if (Vehicle3?.setOwner) {
|
|
||||||
await Vehicle3.setOwner(relatedOwner3);
|
|
||||||
}
|
|
||||||
|
|
||||||
const relatedOwner4 = await Users.findOne({
|
|
||||||
offset: Math.floor(Math.random() * (await Users.count())),
|
|
||||||
});
|
|
||||||
const Vehicle4 = await Vehicles.findOne({
|
|
||||||
order: [['id', 'ASC']],
|
|
||||||
offset: 4,
|
|
||||||
});
|
|
||||||
if (Vehicle4?.setOwner) {
|
|
||||||
await Vehicle4.setOwner(relatedOwner4);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Similar logic for "relation_many"
|
// Similar logic for "relation_many"
|
||||||
@ -545,27 +486,40 @@ async function associateVehicleWithClient() {
|
|||||||
if (Vehicle2?.setClient) {
|
if (Vehicle2?.setClient) {
|
||||||
await Vehicle2.setClient(relatedClient2);
|
await Vehicle2.setClient(relatedClient2);
|
||||||
}
|
}
|
||||||
|
|
||||||
const relatedClient3 = await Clients.findOne({
|
|
||||||
offset: Math.floor(Math.random() * (await Clients.count())),
|
|
||||||
});
|
|
||||||
const Vehicle3 = await Vehicles.findOne({
|
|
||||||
order: [['id', 'ASC']],
|
|
||||||
offset: 3,
|
|
||||||
});
|
|
||||||
if (Vehicle3?.setClient) {
|
|
||||||
await Vehicle3.setClient(relatedClient3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const relatedClient4 = await Clients.findOne({
|
async function associatePowersportvehicleWithClient() {
|
||||||
|
const relatedClient0 = await Clients.findOne({
|
||||||
offset: Math.floor(Math.random() * (await Clients.count())),
|
offset: Math.floor(Math.random() * (await Clients.count())),
|
||||||
});
|
});
|
||||||
const Vehicle4 = await Vehicles.findOne({
|
const Powersportvehicle0 = await Powersportvehicles.findOne({
|
||||||
order: [['id', 'ASC']],
|
order: [['id', 'ASC']],
|
||||||
offset: 4,
|
offset: 0,
|
||||||
});
|
});
|
||||||
if (Vehicle4?.setClient) {
|
if (Powersportvehicle0?.setClient) {
|
||||||
await Vehicle4.setClient(relatedClient4);
|
await Powersportvehicle0.setClient(relatedClient0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const relatedClient1 = await Clients.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Clients.count())),
|
||||||
|
});
|
||||||
|
const Powersportvehicle1 = await Powersportvehicles.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 1,
|
||||||
|
});
|
||||||
|
if (Powersportvehicle1?.setClient) {
|
||||||
|
await Powersportvehicle1.setClient(relatedClient1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const relatedClient2 = await Clients.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Clients.count())),
|
||||||
|
});
|
||||||
|
const Powersportvehicle2 = await Powersportvehicles.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 2,
|
||||||
|
});
|
||||||
|
if (Powersportvehicle2?.setClient) {
|
||||||
|
await Powersportvehicle2.setClient(relatedClient2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -577,6 +531,8 @@ module.exports = {
|
|||||||
|
|
||||||
await Clients.bulkCreate(ClientsData);
|
await Clients.bulkCreate(ClientsData);
|
||||||
|
|
||||||
|
await Powersportvehicles.bulkCreate(PowersportvehiclesData);
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
// Similar logic for "relation_many"
|
// Similar logic for "relation_many"
|
||||||
|
|
||||||
@ -588,11 +544,15 @@ module.exports = {
|
|||||||
|
|
||||||
await associateBookingWithClient(),
|
await associateBookingWithClient(),
|
||||||
|
|
||||||
|
await associateBookingWithPowersportvehicle(),
|
||||||
|
|
||||||
await associateVehicleWithOwner(),
|
await associateVehicleWithOwner(),
|
||||||
|
|
||||||
// Similar logic for "relation_many"
|
// Similar logic for "relation_many"
|
||||||
|
|
||||||
await associateVehicleWithClient(),
|
await associateVehicleWithClient(),
|
||||||
|
|
||||||
|
await associatePowersportvehicleWithClient(),
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -602,5 +562,7 @@ module.exports = {
|
|||||||
await queryInterface.bulkDelete('vehicles', null, {});
|
await queryInterface.bulkDelete('vehicles', null, {});
|
||||||
|
|
||||||
await queryInterface.bulkDelete('clients', null, {});
|
await queryInterface.bulkDelete('clients', null, {});
|
||||||
|
|
||||||
|
await queryInterface.bulkDelete('powersportvehicles', null, {});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
87
backend/src/db/seeders/20250909204242.js
Normal file
87
backend/src/db/seeders/20250909204242.js
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
const { v4: uuid } = require('uuid');
|
||||||
|
const db = require('../models');
|
||||||
|
const Sequelize = require('sequelize');
|
||||||
|
const config = require('../../config');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
/**
|
||||||
|
* @param{import("sequelize").QueryInterface} queryInterface
|
||||||
|
* @return {Promise<void>}
|
||||||
|
*/
|
||||||
|
async up(queryInterface) {
|
||||||
|
const createdAt = new Date();
|
||||||
|
const updatedAt = new Date();
|
||||||
|
|
||||||
|
/** @type {Map<string, string>} */
|
||||||
|
const idMap = new Map();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} key
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
function getId(key) {
|
||||||
|
if (idMap.has(key)) {
|
||||||
|
return idMap.get(key);
|
||||||
|
}
|
||||||
|
const id = uuid();
|
||||||
|
idMap.set(key, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} name
|
||||||
|
*/
|
||||||
|
function createPermissions(name) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
id: getId(`CREATE_${name.toUpperCase()}`),
|
||||||
|
createdAt,
|
||||||
|
updatedAt,
|
||||||
|
name: `CREATE_${name.toUpperCase()}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: getId(`READ_${name.toUpperCase()}`),
|
||||||
|
createdAt,
|
||||||
|
updatedAt,
|
||||||
|
name: `READ_${name.toUpperCase()}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: getId(`UPDATE_${name.toUpperCase()}`),
|
||||||
|
createdAt,
|
||||||
|
updatedAt,
|
||||||
|
name: `UPDATE_${name.toUpperCase()}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: getId(`DELETE_${name.toUpperCase()}`),
|
||||||
|
createdAt,
|
||||||
|
updatedAt,
|
||||||
|
name: `DELETE_${name.toUpperCase()}`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
const entities = ['powersportvehicles'];
|
||||||
|
|
||||||
|
const createdPermissions = entities.flatMap(createPermissions);
|
||||||
|
|
||||||
|
// Add permissions to database
|
||||||
|
await queryInterface.bulkInsert('permissions', createdPermissions);
|
||||||
|
// Get permissions ids
|
||||||
|
const permissionsIds = createdPermissions.map((p) => p.id);
|
||||||
|
// Get admin role
|
||||||
|
const adminRole = await db.roles.findOne({
|
||||||
|
where: { name: config.roles.super_admin },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (adminRole) {
|
||||||
|
// Add permissions to admin role if it exists
|
||||||
|
await adminRole.addPermissions(permissionsIds);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
down: async (queryInterface, Sequelize) => {
|
||||||
|
await queryInterface.bulkDelete(
|
||||||
|
'permissions',
|
||||||
|
entities.flatMap(createPermissions),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
@ -33,6 +33,8 @@ const permissionsRoutes = require('./routes/permissions');
|
|||||||
|
|
||||||
const clientsRoutes = require('./routes/clients');
|
const clientsRoutes = require('./routes/clients');
|
||||||
|
|
||||||
|
const powersportvehiclesRoutes = require('./routes/powersportvehicles');
|
||||||
|
|
||||||
const getBaseUrl = (url) => {
|
const getBaseUrl = (url) => {
|
||||||
if (!url) return '';
|
if (!url) return '';
|
||||||
return url.endsWith('/api') ? url.slice(0, -4) : url;
|
return url.endsWith('/api') ? url.slice(0, -4) : url;
|
||||||
@ -43,9 +45,9 @@ const options = {
|
|||||||
openapi: '3.0.0',
|
openapi: '3.0.0',
|
||||||
info: {
|
info: {
|
||||||
version: '1.0.0',
|
version: '1.0.0',
|
||||||
title: 'Etherra',
|
title: 'Powersport Rentals',
|
||||||
description:
|
description:
|
||||||
'Etherra Online REST API for Testing and Prototyping application. You can perform all major operations with your entities - create, delete and etc.',
|
'Powersport Rentals Online REST API for Testing and Prototyping application. You can perform all major operations with your entities - create, delete and etc.',
|
||||||
},
|
},
|
||||||
servers: [
|
servers: [
|
||||||
{
|
{
|
||||||
@ -134,6 +136,12 @@ app.use(
|
|||||||
clientsRoutes,
|
clientsRoutes,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
app.use(
|
||||||
|
'/api/powersportvehicles',
|
||||||
|
passport.authenticate('jwt', { session: false }),
|
||||||
|
powersportvehiclesRoutes,
|
||||||
|
);
|
||||||
|
|
||||||
app.use(
|
app.use(
|
||||||
'/api/openai',
|
'/api/openai',
|
||||||
passport.authenticate('jwt', { session: false }),
|
passport.authenticate('jwt', { session: false }),
|
||||||
|
|||||||
495
backend/src/routes/powersportvehicles.js
Normal file
495
backend/src/routes/powersportvehicles.js
Normal file
@ -0,0 +1,495 @@
|
|||||||
|
const express = require('express');
|
||||||
|
|
||||||
|
const PowersportvehiclesService = require('../services/powersportvehicles');
|
||||||
|
const PowersportvehiclesDBApi = require('../db/api/powersportvehicles');
|
||||||
|
const wrapAsync = require('../helpers').wrapAsync;
|
||||||
|
|
||||||
|
const config = require('../config');
|
||||||
|
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
const { parse } = require('json2csv');
|
||||||
|
|
||||||
|
const { checkCrudPermissions } = require('../middlewares/check-permissions');
|
||||||
|
|
||||||
|
router.use(checkCrudPermissions('powersportvehicles'));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* components:
|
||||||
|
* schemas:
|
||||||
|
* Powersportvehicles:
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
|
||||||
|
* name:
|
||||||
|
* type: string
|
||||||
|
* default: name
|
||||||
|
* description:
|
||||||
|
* type: string
|
||||||
|
* default: description
|
||||||
|
* location:
|
||||||
|
* type: string
|
||||||
|
* default: location
|
||||||
|
|
||||||
|
* preptimebefore:
|
||||||
|
* type: integer
|
||||||
|
* format: int64
|
||||||
|
* preptimebetween:
|
||||||
|
* type: integer
|
||||||
|
* format: int64
|
||||||
|
|
||||||
|
* pricehourly:
|
||||||
|
* type: integer
|
||||||
|
* format: int64
|
||||||
|
* pricedaily:
|
||||||
|
* type: integer
|
||||||
|
* format: int64
|
||||||
|
* securitydeposit:
|
||||||
|
* type: integer
|
||||||
|
* format: int64
|
||||||
|
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* tags:
|
||||||
|
* name: Powersportvehicles
|
||||||
|
* description: The Powersportvehicles managing API
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /api/powersportvehicles:
|
||||||
|
* post:
|
||||||
|
* security:
|
||||||
|
* - bearerAuth: []
|
||||||
|
* tags: [Powersportvehicles]
|
||||||
|
* summary: Add new item
|
||||||
|
* description: Add new item
|
||||||
|
* requestBody:
|
||||||
|
* required: true
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* properties:
|
||||||
|
* data:
|
||||||
|
* description: Data of the updated item
|
||||||
|
* type: object
|
||||||
|
* $ref: "#/components/schemas/Powersportvehicles"
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: The item was successfully added
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* $ref: "#/components/schemas/Powersportvehicles"
|
||||||
|
* 401:
|
||||||
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
|
* 405:
|
||||||
|
* description: Invalid input data
|
||||||
|
* 500:
|
||||||
|
* description: Some server error
|
||||||
|
*/
|
||||||
|
router.post(
|
||||||
|
'/',
|
||||||
|
wrapAsync(async (req, res) => {
|
||||||
|
const referer =
|
||||||
|
req.headers.referer ||
|
||||||
|
`${req.protocol}://${req.hostname}${req.originalUrl}`;
|
||||||
|
const link = new URL(referer);
|
||||||
|
await PowersportvehiclesService.create(
|
||||||
|
req.body.data,
|
||||||
|
req.currentUser,
|
||||||
|
true,
|
||||||
|
link.host,
|
||||||
|
);
|
||||||
|
const payload = true;
|
||||||
|
res.status(200).send(payload);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /api/budgets/bulk-import:
|
||||||
|
* post:
|
||||||
|
* security:
|
||||||
|
* - bearerAuth: []
|
||||||
|
* tags: [Powersportvehicles]
|
||||||
|
* summary: Bulk import items
|
||||||
|
* description: Bulk import items
|
||||||
|
* requestBody:
|
||||||
|
* required: true
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* properties:
|
||||||
|
* data:
|
||||||
|
* description: Data of the updated items
|
||||||
|
* type: array
|
||||||
|
* items:
|
||||||
|
* $ref: "#/components/schemas/Powersportvehicles"
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: The items were successfully imported
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* $ref: "#/components/schemas/Powersportvehicles"
|
||||||
|
* 401:
|
||||||
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
|
* 405:
|
||||||
|
* description: Invalid input data
|
||||||
|
* 500:
|
||||||
|
* description: Some server error
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
router.post(
|
||||||
|
'/bulk-import',
|
||||||
|
wrapAsync(async (req, res) => {
|
||||||
|
const referer =
|
||||||
|
req.headers.referer ||
|
||||||
|
`${req.protocol}://${req.hostname}${req.originalUrl}`;
|
||||||
|
const link = new URL(referer);
|
||||||
|
await PowersportvehiclesService.bulkImport(req, res, true, link.host);
|
||||||
|
const payload = true;
|
||||||
|
res.status(200).send(payload);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /api/powersportvehicles/{id}:
|
||||||
|
* put:
|
||||||
|
* security:
|
||||||
|
* - bearerAuth: []
|
||||||
|
* tags: [Powersportvehicles]
|
||||||
|
* summary: Update the data of the selected item
|
||||||
|
* description: Update the data of the selected item
|
||||||
|
* parameters:
|
||||||
|
* - in: path
|
||||||
|
* name: id
|
||||||
|
* description: Item ID to update
|
||||||
|
* required: true
|
||||||
|
* schema:
|
||||||
|
* type: string
|
||||||
|
* requestBody:
|
||||||
|
* description: Set new item data
|
||||||
|
* required: true
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* properties:
|
||||||
|
* id:
|
||||||
|
* description: ID of the updated item
|
||||||
|
* type: string
|
||||||
|
* data:
|
||||||
|
* description: Data of the updated item
|
||||||
|
* type: object
|
||||||
|
* $ref: "#/components/schemas/Powersportvehicles"
|
||||||
|
* required:
|
||||||
|
* - id
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: The item data was successfully updated
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* $ref: "#/components/schemas/Powersportvehicles"
|
||||||
|
* 400:
|
||||||
|
* description: Invalid ID supplied
|
||||||
|
* 401:
|
||||||
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
|
* 404:
|
||||||
|
* description: Item not found
|
||||||
|
* 500:
|
||||||
|
* description: Some server error
|
||||||
|
*/
|
||||||
|
router.put(
|
||||||
|
'/:id',
|
||||||
|
wrapAsync(async (req, res) => {
|
||||||
|
await PowersportvehiclesService.update(
|
||||||
|
req.body.data,
|
||||||
|
req.body.id,
|
||||||
|
req.currentUser,
|
||||||
|
);
|
||||||
|
const payload = true;
|
||||||
|
res.status(200).send(payload);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /api/powersportvehicles/{id}:
|
||||||
|
* delete:
|
||||||
|
* security:
|
||||||
|
* - bearerAuth: []
|
||||||
|
* tags: [Powersportvehicles]
|
||||||
|
* summary: Delete the selected item
|
||||||
|
* description: Delete the selected item
|
||||||
|
* parameters:
|
||||||
|
* - in: path
|
||||||
|
* name: id
|
||||||
|
* description: Item ID to delete
|
||||||
|
* required: true
|
||||||
|
* schema:
|
||||||
|
* type: string
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: The item was successfully deleted
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* $ref: "#/components/schemas/Powersportvehicles"
|
||||||
|
* 400:
|
||||||
|
* description: Invalid ID supplied
|
||||||
|
* 401:
|
||||||
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
|
* 404:
|
||||||
|
* description: Item not found
|
||||||
|
* 500:
|
||||||
|
* description: Some server error
|
||||||
|
*/
|
||||||
|
router.delete(
|
||||||
|
'/:id',
|
||||||
|
wrapAsync(async (req, res) => {
|
||||||
|
await PowersportvehiclesService.remove(req.params.id, req.currentUser);
|
||||||
|
const payload = true;
|
||||||
|
res.status(200).send(payload);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /api/powersportvehicles/deleteByIds:
|
||||||
|
* post:
|
||||||
|
* security:
|
||||||
|
* - bearerAuth: []
|
||||||
|
* tags: [Powersportvehicles]
|
||||||
|
* summary: Delete the selected item list
|
||||||
|
* description: Delete the selected item list
|
||||||
|
* requestBody:
|
||||||
|
* required: true
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* properties:
|
||||||
|
* ids:
|
||||||
|
* description: IDs of the updated items
|
||||||
|
* type: array
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: The items was successfully deleted
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* $ref: "#/components/schemas/Powersportvehicles"
|
||||||
|
* 401:
|
||||||
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
|
* 404:
|
||||||
|
* description: Items not found
|
||||||
|
* 500:
|
||||||
|
* description: Some server error
|
||||||
|
*/
|
||||||
|
router.post(
|
||||||
|
'/deleteByIds',
|
||||||
|
wrapAsync(async (req, res) => {
|
||||||
|
await PowersportvehiclesService.deleteByIds(req.body.data, req.currentUser);
|
||||||
|
const payload = true;
|
||||||
|
res.status(200).send(payload);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /api/powersportvehicles:
|
||||||
|
* get:
|
||||||
|
* security:
|
||||||
|
* - bearerAuth: []
|
||||||
|
* tags: [Powersportvehicles]
|
||||||
|
* summary: Get all powersportvehicles
|
||||||
|
* description: Get all powersportvehicles
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: Powersportvehicles list successfully received
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* type: array
|
||||||
|
* items:
|
||||||
|
* $ref: "#/components/schemas/Powersportvehicles"
|
||||||
|
* 401:
|
||||||
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
|
* 404:
|
||||||
|
* description: Data not found
|
||||||
|
* 500:
|
||||||
|
* description: Some server error
|
||||||
|
*/
|
||||||
|
router.get(
|
||||||
|
'/',
|
||||||
|
wrapAsync(async (req, res) => {
|
||||||
|
const filetype = req.query.filetype;
|
||||||
|
|
||||||
|
const globalAccess = req.currentUser.app_role.globalAccess;
|
||||||
|
|
||||||
|
const currentUser = req.currentUser;
|
||||||
|
const payload = await PowersportvehiclesDBApi.findAll(
|
||||||
|
req.query,
|
||||||
|
globalAccess,
|
||||||
|
{ currentUser },
|
||||||
|
);
|
||||||
|
if (filetype && filetype === 'csv') {
|
||||||
|
const fields = [
|
||||||
|
'id',
|
||||||
|
'name',
|
||||||
|
'description',
|
||||||
|
'location',
|
||||||
|
'preptimebefore',
|
||||||
|
'preptimebetween',
|
||||||
|
'pricehourly',
|
||||||
|
'pricedaily',
|
||||||
|
'securitydeposit',
|
||||||
|
'availabilitystart',
|
||||||
|
'availabilityend',
|
||||||
|
];
|
||||||
|
const opts = { fields };
|
||||||
|
try {
|
||||||
|
const csv = parse(payload.rows, opts);
|
||||||
|
res.status(200).attachment(csv);
|
||||||
|
res.send(csv);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res.status(200).send(payload);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /api/powersportvehicles/count:
|
||||||
|
* get:
|
||||||
|
* security:
|
||||||
|
* - bearerAuth: []
|
||||||
|
* tags: [Powersportvehicles]
|
||||||
|
* summary: Count all powersportvehicles
|
||||||
|
* description: Count all powersportvehicles
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: Powersportvehicles count successfully received
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* type: array
|
||||||
|
* items:
|
||||||
|
* $ref: "#/components/schemas/Powersportvehicles"
|
||||||
|
* 401:
|
||||||
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
|
* 404:
|
||||||
|
* description: Data not found
|
||||||
|
* 500:
|
||||||
|
* description: Some server error
|
||||||
|
*/
|
||||||
|
router.get(
|
||||||
|
'/count',
|
||||||
|
wrapAsync(async (req, res) => {
|
||||||
|
const globalAccess = req.currentUser.app_role.globalAccess;
|
||||||
|
|
||||||
|
const currentUser = req.currentUser;
|
||||||
|
const payload = await PowersportvehiclesDBApi.findAll(
|
||||||
|
req.query,
|
||||||
|
globalAccess,
|
||||||
|
{ countOnly: true, currentUser },
|
||||||
|
);
|
||||||
|
|
||||||
|
res.status(200).send(payload);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /api/powersportvehicles/autocomplete:
|
||||||
|
* get:
|
||||||
|
* security:
|
||||||
|
* - bearerAuth: []
|
||||||
|
* tags: [Powersportvehicles]
|
||||||
|
* summary: Find all powersportvehicles that match search criteria
|
||||||
|
* description: Find all powersportvehicles that match search criteria
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: Powersportvehicles list successfully received
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* type: array
|
||||||
|
* items:
|
||||||
|
* $ref: "#/components/schemas/Powersportvehicles"
|
||||||
|
* 401:
|
||||||
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
|
* 404:
|
||||||
|
* description: Data not found
|
||||||
|
* 500:
|
||||||
|
* description: Some server error
|
||||||
|
*/
|
||||||
|
router.get('/autocomplete', async (req, res) => {
|
||||||
|
const globalAccess = req.currentUser.app_role.globalAccess;
|
||||||
|
|
||||||
|
const organizationId = req.currentUser.organization?.id;
|
||||||
|
|
||||||
|
const payload = await PowersportvehiclesDBApi.findAllAutocomplete(
|
||||||
|
req.query.query,
|
||||||
|
req.query.limit,
|
||||||
|
req.query.offset,
|
||||||
|
globalAccess,
|
||||||
|
organizationId,
|
||||||
|
);
|
||||||
|
|
||||||
|
res.status(200).send(payload);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /api/powersportvehicles/{id}:
|
||||||
|
* get:
|
||||||
|
* security:
|
||||||
|
* - bearerAuth: []
|
||||||
|
* tags: [Powersportvehicles]
|
||||||
|
* summary: Get selected item
|
||||||
|
* description: Get selected item
|
||||||
|
* parameters:
|
||||||
|
* - in: path
|
||||||
|
* name: id
|
||||||
|
* description: ID of item to get
|
||||||
|
* required: true
|
||||||
|
* schema:
|
||||||
|
* type: string
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: Selected item successfully received
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* $ref: "#/components/schemas/Powersportvehicles"
|
||||||
|
* 400:
|
||||||
|
* description: Invalid ID supplied
|
||||||
|
* 401:
|
||||||
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
|
* 404:
|
||||||
|
* description: Item not found
|
||||||
|
* 500:
|
||||||
|
* description: Some server error
|
||||||
|
*/
|
||||||
|
router.get(
|
||||||
|
'/:id',
|
||||||
|
wrapAsync(async (req, res) => {
|
||||||
|
const payload = await PowersportvehiclesDBApi.findBy({ id: req.params.id });
|
||||||
|
|
||||||
|
res.status(200).send(payload);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
router.use('/', require('../helpers').commonErrorHandler);
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
@ -42,6 +42,7 @@ router.use(checkCrudPermissions('vehicles'));
|
|||||||
* type: integer
|
* type: integer
|
||||||
* format: int64
|
* format: int64
|
||||||
|
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
const errors = {
|
const errors = {
|
||||||
app: {
|
app: {
|
||||||
title: 'Etherra',
|
title: 'Powersport Rentals',
|
||||||
},
|
},
|
||||||
|
|
||||||
auth: {
|
auth: {
|
||||||
|
|||||||
121
backend/src/services/powersportvehicles.js
Normal file
121
backend/src/services/powersportvehicles.js
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
const db = require('../db/models');
|
||||||
|
const PowersportvehiclesDBApi = require('../db/api/powersportvehicles');
|
||||||
|
const processFile = require('../middlewares/upload');
|
||||||
|
const ValidationError = require('./notifications/errors/validation');
|
||||||
|
const csv = require('csv-parser');
|
||||||
|
const axios = require('axios');
|
||||||
|
const config = require('../config');
|
||||||
|
const stream = require('stream');
|
||||||
|
|
||||||
|
module.exports = class PowersportvehiclesService {
|
||||||
|
static async create(data, currentUser) {
|
||||||
|
const transaction = await db.sequelize.transaction();
|
||||||
|
try {
|
||||||
|
await PowersportvehiclesDBApi.create(data, {
|
||||||
|
currentUser,
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (error) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async bulkImport(req, res, sendInvitationEmails = true, host) {
|
||||||
|
const transaction = await db.sequelize.transaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
await processFile(req, res);
|
||||||
|
const bufferStream = new stream.PassThrough();
|
||||||
|
const results = [];
|
||||||
|
|
||||||
|
await bufferStream.end(Buffer.from(req.file.buffer, 'utf-8')); // convert Buffer to Stream
|
||||||
|
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
bufferStream
|
||||||
|
.pipe(csv())
|
||||||
|
.on('data', (data) => results.push(data))
|
||||||
|
.on('end', async () => {
|
||||||
|
console.log('CSV results', results);
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
.on('error', (error) => reject(error));
|
||||||
|
});
|
||||||
|
|
||||||
|
await PowersportvehiclesDBApi.bulkImport(results, {
|
||||||
|
transaction,
|
||||||
|
ignoreDuplicates: true,
|
||||||
|
validate: true,
|
||||||
|
currentUser: req.currentUser,
|
||||||
|
});
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (error) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async update(data, id, currentUser) {
|
||||||
|
const transaction = await db.sequelize.transaction();
|
||||||
|
try {
|
||||||
|
let powersportvehicles = await PowersportvehiclesDBApi.findBy(
|
||||||
|
{ id },
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!powersportvehicles) {
|
||||||
|
throw new ValidationError('powersportvehiclesNotFound');
|
||||||
|
}
|
||||||
|
|
||||||
|
const updatedPowersportvehicles = await PowersportvehiclesDBApi.update(
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
{
|
||||||
|
currentUser,
|
||||||
|
transaction,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
return updatedPowersportvehicles;
|
||||||
|
} catch (error) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async deleteByIds(ids, currentUser) {
|
||||||
|
const transaction = await db.sequelize.transaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
await PowersportvehiclesDBApi.deleteByIds(ids, {
|
||||||
|
currentUser,
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (error) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async remove(id, currentUser) {
|
||||||
|
const transaction = await db.sequelize.transaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
await PowersportvehiclesDBApi.remove(id, {
|
||||||
|
currentUser,
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (error) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -46,11 +46,25 @@ module.exports = class SearchService {
|
|||||||
vehicles: ['title', 'description', 'location'],
|
vehicles: ['title', 'description', 'location'],
|
||||||
|
|
||||||
clients: ['name'],
|
clients: ['name'],
|
||||||
|
|
||||||
|
powersportvehicles: ['name', 'description', 'location'],
|
||||||
};
|
};
|
||||||
const columnsInt = {
|
const columnsInt = {
|
||||||
bookings: ['total_price'],
|
bookings: ['total_price'],
|
||||||
|
|
||||||
vehicles: ['price_hourly', 'price_daily', 'security_deposit'],
|
vehicles: ['price_hourly', 'price_daily', 'security_deposit'],
|
||||||
|
|
||||||
|
powersportvehicles: [
|
||||||
|
'pricehourly',
|
||||||
|
|
||||||
|
'pricedaily',
|
||||||
|
|
||||||
|
'securitydeposit',
|
||||||
|
|
||||||
|
'preptimebefore',
|
||||||
|
|
||||||
|
'preptimebetween',
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
let allFoundRecords = [];
|
let allFoundRecords = [];
|
||||||
|
|||||||
@ -25,7 +25,7 @@ services:
|
|||||||
- ./data/db:/var/lib/postgresql/data
|
- ./data/db:/var/lib/postgresql/data
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_HOST_AUTH_METHOD=trust
|
- POSTGRES_HOST_AUTH_METHOD=trust
|
||||||
- POSTGRES_DB=db_etherra
|
- POSTGRES_DB=db_powersport_rentals
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
logging:
|
logging:
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# Etherra
|
# Powersport Rentals
|
||||||
|
|
||||||
## This project was generated by Flatlogic Platform.
|
## This project was generated by Flatlogic Platform.
|
||||||
|
|
||||||
|
|||||||
1
frontend/json/runtimeError.json
Normal file
1
frontend/json/runtimeError.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
@ -76,7 +76,7 @@ export default function AsideMenuLayer({
|
|||||||
>
|
>
|
||||||
<div className='text-center flex-1 lg:text-left lg:pl-6 xl:text-center xl:pl-0'>
|
<div className='text-center flex-1 lg:text-left lg:pl-6 xl:text-center xl:pl-0'>
|
||||||
<Link href={'/home'}>
|
<Link href={'/home'}>
|
||||||
<b className='font-black'>Etherra</b>
|
<b className='font-black'>Powersport Rentals</b>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
{organizationName && <p>{organizationName}</p>}
|
{organizationName && <p>{organizationName}</p>}
|
||||||
|
|||||||
@ -141,6 +141,19 @@ const CardBookings = ({
|
|||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Powersportvehicle
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{dataFormatter.powersportvehiclesOneListFormatter(
|
||||||
|
item.powersportvehicle,
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -90,6 +90,17 @@ const ListBookings = ({
|
|||||||
<p className={'text-xs text-gray-500 '}>TotalPrice</p>
|
<p className={'text-xs text-gray-500 '}>TotalPrice</p>
|
||||||
<p className={'line-clamp-2'}>{item.total_price}</p>
|
<p className={'line-clamp-2'}>{item.total_price}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>
|
||||||
|
Powersportvehicle
|
||||||
|
</p>
|
||||||
|
<p className={'line-clamp-2'}>
|
||||||
|
{dataFormatter.powersportvehiclesOneListFormatter(
|
||||||
|
item.powersportvehicle,
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
|
|||||||
@ -136,6 +136,26 @@ export const loadColumns = async (
|
|||||||
type: 'number',
|
type: 'number',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'powersportvehicle',
|
||||||
|
headerName: 'Powersportvehicle',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
|
||||||
|
sortable: false,
|
||||||
|
type: 'singleSelect',
|
||||||
|
getOptionValue: (value: any) => value?.id,
|
||||||
|
getOptionLabel: (value: any) => value?.label,
|
||||||
|
valueOptions: await callOptionsApi('powersportvehicles'),
|
||||||
|
valueGetter: (params: GridValueGetterParams) =>
|
||||||
|
params?.value?.id ?? params?.value,
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'actions',
|
field: 'actions',
|
||||||
type: 'actions',
|
type: 'actions',
|
||||||
|
|||||||
@ -0,0 +1,239 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ImageField from '../ImageField';
|
||||||
|
import ListActionsPopover from '../ListActionsPopover';
|
||||||
|
import { useAppSelector } from '../../stores/hooks';
|
||||||
|
import dataFormatter from '../../helpers/dataFormatter';
|
||||||
|
import { Pagination } from '../Pagination';
|
||||||
|
import { saveFile } from '../../helpers/fileSaver';
|
||||||
|
import LoadingSpinner from '../LoadingSpinner';
|
||||||
|
import Link from 'next/link';
|
||||||
|
|
||||||
|
import { hasPermission } from '../../helpers/userPermissions';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
powersportvehicles: any[];
|
||||||
|
loading: boolean;
|
||||||
|
onDelete: (id: string) => void;
|
||||||
|
currentPage: number;
|
||||||
|
numPages: number;
|
||||||
|
onPageChange: (page: number) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
const CardPowersportvehicles = ({
|
||||||
|
powersportvehicles,
|
||||||
|
loading,
|
||||||
|
onDelete,
|
||||||
|
currentPage,
|
||||||
|
numPages,
|
||||||
|
onPageChange,
|
||||||
|
}: Props) => {
|
||||||
|
const asideScrollbarsStyle = useAppSelector(
|
||||||
|
(state) => state.style.asideScrollbarsStyle,
|
||||||
|
);
|
||||||
|
const bgColor = useAppSelector((state) => state.style.cardsColor);
|
||||||
|
const darkMode = useAppSelector((state) => state.style.darkMode);
|
||||||
|
const corners = useAppSelector((state) => state.style.corners);
|
||||||
|
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||||
|
|
||||||
|
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
||||||
|
const hasUpdatePermission = hasPermission(
|
||||||
|
currentUser,
|
||||||
|
'UPDATE_POWERSPORTVEHICLES',
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={'p-4'}>
|
||||||
|
{loading && <LoadingSpinner />}
|
||||||
|
<ul
|
||||||
|
role='list'
|
||||||
|
className='grid grid-cols-1 gap-x-6 gap-y-8 lg:grid-cols-3 2xl:grid-cols-4 xl:gap-x-8'
|
||||||
|
>
|
||||||
|
{!loading &&
|
||||||
|
powersportvehicles.map((item, index) => (
|
||||||
|
<li
|
||||||
|
key={item.id}
|
||||||
|
className={`overflow-hidden ${
|
||||||
|
corners !== 'rounded-full' ? corners : 'rounded-3xl'
|
||||||
|
} border ${focusRing} border-gray-200 dark:border-dark-700 ${
|
||||||
|
darkMode ? 'aside-scrollbars-[slate]' : asideScrollbarsStyle
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className={`flex items-center ${bgColor} p-6 md:p-0 md:block gap-x-4 border-b border-gray-900/5 bg-gray-50 dark:bg-dark-800 relative`}
|
||||||
|
>
|
||||||
|
<Link
|
||||||
|
href={`/powersportvehicles/powersportvehicles-view/?id=${item.id}`}
|
||||||
|
className={'cursor-pointer'}
|
||||||
|
>
|
||||||
|
<ImageField
|
||||||
|
name={'Avatar'}
|
||||||
|
image={item.photos}
|
||||||
|
className='w-12 h-12 md:w-full md:h-44 rounded-lg md:rounded-b-none overflow-hidden ring-1 ring-gray-900/10'
|
||||||
|
imageClassName='h-full w-full flex-none rounded-lg md:rounded-b-none bg-white object-cover'
|
||||||
|
/>
|
||||||
|
<p className={'px-6 py-2 font-semibold'}>{item.name}</p>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<div className='ml-auto md:absolute md:top-0 md:right-0 '>
|
||||||
|
<ListActionsPopover
|
||||||
|
onDelete={onDelete}
|
||||||
|
itemId={item.id}
|
||||||
|
pathEdit={`/powersportvehicles/powersportvehicles-edit/?id=${item.id}`}
|
||||||
|
pathView={`/powersportvehicles/powersportvehicles-view/?id=${item.id}`}
|
||||||
|
hasUpdatePermission={hasUpdatePermission}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<dl className='divide-y divide-gray-600 dark:divide-dark-700 px-6 py-4 text-sm leading-6 h-64 overflow-y-auto'>
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>Name</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>{item.name}</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Description
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{item.description}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Photos
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium'>
|
||||||
|
<ImageField
|
||||||
|
name={'Avatar'}
|
||||||
|
image={item.photos}
|
||||||
|
className='mx-auto w-8 h-8'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Location
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{item.location}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Pricehourly
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{item.pricehourly}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Pricedaily
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{item.pricedaily}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Securitydeposit
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{item.securitydeposit}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Availabilitystart
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{dataFormatter.dateTimeFormatter(item.availabilitystart)}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Availabilityend
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{dataFormatter.dateTimeFormatter(item.availabilityend)}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Vehicletype
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{item.vehicletype}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Preptimebefore
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{item.preptimebefore}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Preptimebetween
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{item.preptimebetween}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
{!loading && powersportvehicles.length === 0 && (
|
||||||
|
<div className='col-span-full flex items-center justify-center h-40'>
|
||||||
|
<p className=''>No data to display</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</ul>
|
||||||
|
<div className={'flex items-center justify-center my-6'}>
|
||||||
|
<Pagination
|
||||||
|
currentPage={currentPage}
|
||||||
|
numPages={numPages}
|
||||||
|
setCurrentPage={onPageChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CardPowersportvehicles;
|
||||||
@ -0,0 +1,176 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import CardBox from '../CardBox';
|
||||||
|
import ImageField from '../ImageField';
|
||||||
|
import dataFormatter from '../../helpers/dataFormatter';
|
||||||
|
import { saveFile } from '../../helpers/fileSaver';
|
||||||
|
import ListActionsPopover from '../ListActionsPopover';
|
||||||
|
import { useAppSelector } from '../../stores/hooks';
|
||||||
|
import { Pagination } from '../Pagination';
|
||||||
|
import LoadingSpinner from '../LoadingSpinner';
|
||||||
|
import Link from 'next/link';
|
||||||
|
|
||||||
|
import { hasPermission } from '../../helpers/userPermissions';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
powersportvehicles: any[];
|
||||||
|
loading: boolean;
|
||||||
|
onDelete: (id: string) => void;
|
||||||
|
currentPage: number;
|
||||||
|
numPages: number;
|
||||||
|
onPageChange: (page: number) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
const ListPowersportvehicles = ({
|
||||||
|
powersportvehicles,
|
||||||
|
loading,
|
||||||
|
onDelete,
|
||||||
|
currentPage,
|
||||||
|
numPages,
|
||||||
|
onPageChange,
|
||||||
|
}: Props) => {
|
||||||
|
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
||||||
|
const hasUpdatePermission = hasPermission(
|
||||||
|
currentUser,
|
||||||
|
'UPDATE_POWERSPORTVEHICLES',
|
||||||
|
);
|
||||||
|
|
||||||
|
const corners = useAppSelector((state) => state.style.corners);
|
||||||
|
const bgColor = useAppSelector((state) => state.style.cardsColor);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className='relative overflow-x-auto p-4 space-y-4'>
|
||||||
|
{loading && <LoadingSpinner />}
|
||||||
|
{!loading &&
|
||||||
|
powersportvehicles.map((item) => (
|
||||||
|
<div key={item.id}>
|
||||||
|
<CardBox hasTable isList className={'rounded shadow-none'}>
|
||||||
|
<div
|
||||||
|
className={`flex ${bgColor} ${
|
||||||
|
corners !== 'rounded-full' ? corners : 'rounded-3xl'
|
||||||
|
} dark:bg-dark-900 border border-gray-600 items-center overflow-hidden`}
|
||||||
|
>
|
||||||
|
<ImageField
|
||||||
|
name={'Avatar'}
|
||||||
|
image={item.photos}
|
||||||
|
className='w-24 h-24 rounded-l overflow-hidden hidden md:block'
|
||||||
|
imageClassName={
|
||||||
|
'rounded-l rounded-r-none h-full object-cover'
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Link
|
||||||
|
href={`/powersportvehicles/powersportvehicles-view/?id=${item.id}`}
|
||||||
|
className={
|
||||||
|
'flex-1 px-4 py-6 h-24 flex divide-x-2 divide-gray-600 items-center overflow-hidden`}> dark:divide-dark-700 overflow-x-auto'
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>Name</p>
|
||||||
|
<p className={'line-clamp-2'}>{item.name}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>Description</p>
|
||||||
|
<p className={'line-clamp-2'}>{item.description}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>Photos</p>
|
||||||
|
<ImageField
|
||||||
|
name={'Avatar'}
|
||||||
|
image={item.photos}
|
||||||
|
className='mx-auto w-8 h-8'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>Location</p>
|
||||||
|
<p className={'line-clamp-2'}>{item.location}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>Pricehourly</p>
|
||||||
|
<p className={'line-clamp-2'}>{item.pricehourly}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>Pricedaily</p>
|
||||||
|
<p className={'line-clamp-2'}>{item.pricedaily}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>
|
||||||
|
Securitydeposit
|
||||||
|
</p>
|
||||||
|
<p className={'line-clamp-2'}>{item.securitydeposit}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>
|
||||||
|
Availabilitystart
|
||||||
|
</p>
|
||||||
|
<p className={'line-clamp-2'}>
|
||||||
|
{dataFormatter.dateTimeFormatter(
|
||||||
|
item.availabilitystart,
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>
|
||||||
|
Availabilityend
|
||||||
|
</p>
|
||||||
|
<p className={'line-clamp-2'}>
|
||||||
|
{dataFormatter.dateTimeFormatter(item.availabilityend)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>Vehicletype</p>
|
||||||
|
<p className={'line-clamp-2'}>{item.vehicletype}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>
|
||||||
|
Preptimebefore
|
||||||
|
</p>
|
||||||
|
<p className={'line-clamp-2'}>{item.preptimebefore}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>
|
||||||
|
Preptimebetween
|
||||||
|
</p>
|
||||||
|
<p className={'line-clamp-2'}>{item.preptimebetween}</p>
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
<ListActionsPopover
|
||||||
|
onDelete={onDelete}
|
||||||
|
itemId={item.id}
|
||||||
|
pathEdit={`/powersportvehicles/powersportvehicles-edit/?id=${item.id}`}
|
||||||
|
pathView={`/powersportvehicles/powersportvehicles-view/?id=${item.id}`}
|
||||||
|
hasUpdatePermission={hasUpdatePermission}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</CardBox>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
{!loading && powersportvehicles.length === 0 && (
|
||||||
|
<div className='col-span-full flex items-center justify-center h-40'>
|
||||||
|
<p className=''>No data to display</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className={'flex items-center justify-center my-6'}>
|
||||||
|
<Pagination
|
||||||
|
currentPage={currentPage}
|
||||||
|
numPages={numPages}
|
||||||
|
setCurrentPage={onPageChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ListPowersportvehicles;
|
||||||
@ -0,0 +1,489 @@
|
|||||||
|
import React, { useEffect, useState, useMemo } from 'react';
|
||||||
|
import { createPortal } from 'react-dom';
|
||||||
|
import { ToastContainer, toast } from 'react-toastify';
|
||||||
|
import BaseButton from '../BaseButton';
|
||||||
|
import CardBoxModal from '../CardBoxModal';
|
||||||
|
import CardBox from '../CardBox';
|
||||||
|
import {
|
||||||
|
fetch,
|
||||||
|
update,
|
||||||
|
deleteItem,
|
||||||
|
setRefetch,
|
||||||
|
deleteItemsByIds,
|
||||||
|
} from '../../stores/powersportvehicles/powersportvehiclesSlice';
|
||||||
|
import { useAppDispatch, useAppSelector } from '../../stores/hooks';
|
||||||
|
import { useRouter } from 'next/router';
|
||||||
|
import { Field, Form, Formik } from 'formik';
|
||||||
|
import { DataGrid, GridColDef } from '@mui/x-data-grid';
|
||||||
|
import { loadColumns } from './configurePowersportvehiclesCols';
|
||||||
|
import _ from 'lodash';
|
||||||
|
import dataFormatter from '../../helpers/dataFormatter';
|
||||||
|
import { dataGridStyles } from '../../styles';
|
||||||
|
|
||||||
|
const perPage = 10;
|
||||||
|
|
||||||
|
const TableSamplePowersportvehicles = ({
|
||||||
|
filterItems,
|
||||||
|
setFilterItems,
|
||||||
|
filters,
|
||||||
|
showGrid,
|
||||||
|
}) => {
|
||||||
|
const notify = (type, msg) => toast(msg, { type, position: 'bottom-center' });
|
||||||
|
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const pagesList = [];
|
||||||
|
const [id, setId] = useState(null);
|
||||||
|
const [currentPage, setCurrentPage] = useState(0);
|
||||||
|
const [filterRequest, setFilterRequest] = React.useState('');
|
||||||
|
const [columns, setColumns] = useState<GridColDef[]>([]);
|
||||||
|
const [selectedRows, setSelectedRows] = useState([]);
|
||||||
|
const [sortModel, setSortModel] = useState([
|
||||||
|
{
|
||||||
|
field: '',
|
||||||
|
sort: 'desc',
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const {
|
||||||
|
powersportvehicles,
|
||||||
|
loading,
|
||||||
|
count,
|
||||||
|
notify: powersportvehiclesNotify,
|
||||||
|
refetch,
|
||||||
|
} = useAppSelector((state) => state.powersportvehicles);
|
||||||
|
const { currentUser } = useAppSelector((state) => state.auth);
|
||||||
|
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||||
|
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
||||||
|
const corners = useAppSelector((state) => state.style.corners);
|
||||||
|
const numPages =
|
||||||
|
Math.floor(count / perPage) === 0 ? 1 : Math.ceil(count / perPage);
|
||||||
|
for (let i = 0; i < numPages; i++) {
|
||||||
|
pagesList.push(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadData = async (page = currentPage, request = filterRequest) => {
|
||||||
|
if (page !== currentPage) setCurrentPage(page);
|
||||||
|
if (request !== filterRequest) setFilterRequest(request);
|
||||||
|
const { sort, field } = sortModel[0];
|
||||||
|
|
||||||
|
const query = `?page=${page}&limit=${perPage}${request}&sort=${sort}&field=${field}`;
|
||||||
|
dispatch(fetch({ limit: perPage, page, query }));
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (powersportvehiclesNotify.showNotification) {
|
||||||
|
notify(
|
||||||
|
powersportvehiclesNotify.typeNotification,
|
||||||
|
powersportvehiclesNotify.textNotification,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, [powersportvehiclesNotify.showNotification]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!currentUser) return;
|
||||||
|
loadData();
|
||||||
|
}, [sortModel, currentUser]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (refetch) {
|
||||||
|
loadData(0);
|
||||||
|
dispatch(setRefetch(false));
|
||||||
|
}
|
||||||
|
}, [refetch, dispatch]);
|
||||||
|
|
||||||
|
const [isModalInfoActive, setIsModalInfoActive] = useState(false);
|
||||||
|
const [isModalTrashActive, setIsModalTrashActive] = useState(false);
|
||||||
|
|
||||||
|
const handleModalAction = () => {
|
||||||
|
setIsModalInfoActive(false);
|
||||||
|
setIsModalTrashActive(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDeleteModalAction = (id: string) => {
|
||||||
|
setId(id);
|
||||||
|
setIsModalTrashActive(true);
|
||||||
|
};
|
||||||
|
const handleDeleteAction = async () => {
|
||||||
|
if (id) {
|
||||||
|
await dispatch(deleteItem(id));
|
||||||
|
await loadData(0);
|
||||||
|
setIsModalTrashActive(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const generateFilterRequests = useMemo(() => {
|
||||||
|
let request = '&';
|
||||||
|
filterItems.forEach((item) => {
|
||||||
|
const isRangeFilter = filters.find(
|
||||||
|
(filter) =>
|
||||||
|
filter.title === item.fields.selectedField &&
|
||||||
|
(filter.number || filter.date),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isRangeFilter) {
|
||||||
|
const from = item.fields.filterValueFrom;
|
||||||
|
const to = item.fields.filterValueTo;
|
||||||
|
if (from) {
|
||||||
|
request += `${item.fields.selectedField}Range=${from}&`;
|
||||||
|
}
|
||||||
|
if (to) {
|
||||||
|
request += `${item.fields.selectedField}Range=${to}&`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const value = item.fields.filterValue;
|
||||||
|
if (value) {
|
||||||
|
request += `${item.fields.selectedField}=${value}&`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return request;
|
||||||
|
}, [filterItems, filters]);
|
||||||
|
|
||||||
|
const deleteFilter = (value) => {
|
||||||
|
const newItems = filterItems.filter((item) => item.id !== value);
|
||||||
|
|
||||||
|
if (newItems.length) {
|
||||||
|
setFilterItems(newItems);
|
||||||
|
} else {
|
||||||
|
loadData(0, '');
|
||||||
|
|
||||||
|
setFilterItems(newItems);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = () => {
|
||||||
|
loadData(0, generateFilterRequests);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleChange = (id) => (e) => {
|
||||||
|
const value = e.target.value;
|
||||||
|
const name = e.target.name;
|
||||||
|
|
||||||
|
setFilterItems(
|
||||||
|
filterItems.map((item) => {
|
||||||
|
if (item.id !== id) return item;
|
||||||
|
if (name === 'selectedField') return { id, fields: { [name]: value } };
|
||||||
|
|
||||||
|
return { id, fields: { ...item.fields, [name]: value } };
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleReset = () => {
|
||||||
|
setFilterItems([]);
|
||||||
|
loadData(0, '');
|
||||||
|
};
|
||||||
|
|
||||||
|
const onPageChange = (page: number) => {
|
||||||
|
loadData(page);
|
||||||
|
setCurrentPage(page);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!currentUser) return;
|
||||||
|
|
||||||
|
loadColumns(
|
||||||
|
handleDeleteModalAction,
|
||||||
|
`powersportvehicles`,
|
||||||
|
currentUser,
|
||||||
|
).then((newCols) => setColumns(newCols));
|
||||||
|
}, [currentUser]);
|
||||||
|
|
||||||
|
const handleTableSubmit = async (id: string, data) => {
|
||||||
|
if (!_.isEmpty(data)) {
|
||||||
|
await dispatch(update({ id, data }))
|
||||||
|
.unwrap()
|
||||||
|
.then((res) => res)
|
||||||
|
.catch((err) => {
|
||||||
|
throw new Error(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onDeleteRows = async (selectedRows) => {
|
||||||
|
await dispatch(deleteItemsByIds(selectedRows));
|
||||||
|
await loadData(0);
|
||||||
|
};
|
||||||
|
|
||||||
|
const controlClasses =
|
||||||
|
'w-full py-2 px-2 my-2 rounded dark:placeholder-gray-400 ' +
|
||||||
|
` ${bgColor} ${focusRing} ${corners} ` +
|
||||||
|
'dark:bg-slate-800 border';
|
||||||
|
|
||||||
|
const dataGrid = (
|
||||||
|
<div className='relative overflow-x-auto'>
|
||||||
|
<DataGrid
|
||||||
|
autoHeight
|
||||||
|
rowHeight={64}
|
||||||
|
sx={dataGridStyles}
|
||||||
|
className={'datagrid--table'}
|
||||||
|
getRowClassName={() => `datagrid--row`}
|
||||||
|
rows={powersportvehicles ?? []}
|
||||||
|
columns={columns}
|
||||||
|
initialState={{
|
||||||
|
pagination: {
|
||||||
|
paginationModel: {
|
||||||
|
pageSize: 10,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
disableRowSelectionOnClick
|
||||||
|
onProcessRowUpdateError={(params) => {
|
||||||
|
console.log('Error', params);
|
||||||
|
}}
|
||||||
|
processRowUpdate={async (newRow, oldRow) => {
|
||||||
|
const data = dataFormatter.dataGridEditFormatter(newRow);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await handleTableSubmit(newRow.id, data);
|
||||||
|
return newRow;
|
||||||
|
} catch {
|
||||||
|
return oldRow;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
sortingMode={'server'}
|
||||||
|
checkboxSelection
|
||||||
|
onRowSelectionModelChange={(ids) => {
|
||||||
|
setSelectedRows(ids);
|
||||||
|
}}
|
||||||
|
onSortModelChange={(params) => {
|
||||||
|
params.length
|
||||||
|
? setSortModel(params)
|
||||||
|
: setSortModel([{ field: '', sort: 'desc' }]);
|
||||||
|
}}
|
||||||
|
rowCount={count}
|
||||||
|
pageSizeOptions={[10]}
|
||||||
|
paginationMode={'server'}
|
||||||
|
loading={loading}
|
||||||
|
onPaginationModelChange={(params) => {
|
||||||
|
onPageChange(params.page);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{filterItems && Array.isArray(filterItems) && filterItems.length ? (
|
||||||
|
<CardBox>
|
||||||
|
<Formik
|
||||||
|
initialValues={{
|
||||||
|
checkboxes: ['lorem'],
|
||||||
|
switches: ['lorem'],
|
||||||
|
radio: 'lorem',
|
||||||
|
}}
|
||||||
|
onSubmit={() => null}
|
||||||
|
>
|
||||||
|
<Form>
|
||||||
|
<>
|
||||||
|
{filterItems &&
|
||||||
|
filterItems.map((filterItem) => {
|
||||||
|
return (
|
||||||
|
<div key={filterItem.id} className='flex mb-4'>
|
||||||
|
<div className='flex flex-col w-full mr-3'>
|
||||||
|
<div className=' text-gray-500 font-bold'>
|
||||||
|
Filter
|
||||||
|
</div>
|
||||||
|
<Field
|
||||||
|
className={controlClasses}
|
||||||
|
name='selectedField'
|
||||||
|
id='selectedField'
|
||||||
|
component='select'
|
||||||
|
value={filterItem?.fields?.selectedField || ''}
|
||||||
|
onChange={handleChange(filterItem.id)}
|
||||||
|
>
|
||||||
|
{filters.map((selectOption) => (
|
||||||
|
<option
|
||||||
|
key={selectOption.title}
|
||||||
|
value={`${selectOption.title}`}
|
||||||
|
>
|
||||||
|
{selectOption.label}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</Field>
|
||||||
|
</div>
|
||||||
|
{filters.find(
|
||||||
|
(filter) =>
|
||||||
|
filter.title === filterItem?.fields?.selectedField,
|
||||||
|
)?.type === 'enum' ? (
|
||||||
|
<div className='flex flex-col w-full mr-3'>
|
||||||
|
<div className='text-gray-500 font-bold'>Value</div>
|
||||||
|
<Field
|
||||||
|
className={controlClasses}
|
||||||
|
name='filterValue'
|
||||||
|
id='filterValue'
|
||||||
|
component='select'
|
||||||
|
value={filterItem?.fields?.filterValue || ''}
|
||||||
|
onChange={handleChange(filterItem.id)}
|
||||||
|
>
|
||||||
|
<option value=''>Select Value</option>
|
||||||
|
{filters
|
||||||
|
.find(
|
||||||
|
(filter) =>
|
||||||
|
filter.title ===
|
||||||
|
filterItem?.fields?.selectedField,
|
||||||
|
)
|
||||||
|
?.options?.map((option) => (
|
||||||
|
<option key={option} value={option}>
|
||||||
|
{option}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</Field>
|
||||||
|
</div>
|
||||||
|
) : filters.find(
|
||||||
|
(filter) =>
|
||||||
|
filter.title ===
|
||||||
|
filterItem?.fields?.selectedField,
|
||||||
|
)?.number ? (
|
||||||
|
<div className='flex flex-row w-full mr-3'>
|
||||||
|
<div className='flex flex-col w-full mr-3'>
|
||||||
|
<div className=' text-gray-500 font-bold'>
|
||||||
|
From
|
||||||
|
</div>
|
||||||
|
<Field
|
||||||
|
className={controlClasses}
|
||||||
|
name='filterValueFrom'
|
||||||
|
placeholder='From'
|
||||||
|
id='filterValueFrom'
|
||||||
|
value={
|
||||||
|
filterItem?.fields?.filterValueFrom || ''
|
||||||
|
}
|
||||||
|
onChange={handleChange(filterItem.id)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className='flex flex-col w-full'>
|
||||||
|
<div className=' text-gray-500 font-bold'>
|
||||||
|
To
|
||||||
|
</div>
|
||||||
|
<Field
|
||||||
|
className={controlClasses}
|
||||||
|
name='filterValueTo'
|
||||||
|
placeholder='to'
|
||||||
|
id='filterValueTo'
|
||||||
|
value={filterItem?.fields?.filterValueTo || ''}
|
||||||
|
onChange={handleChange(filterItem.id)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : filters.find(
|
||||||
|
(filter) =>
|
||||||
|
filter.title ===
|
||||||
|
filterItem?.fields?.selectedField,
|
||||||
|
)?.date ? (
|
||||||
|
<div className='flex flex-row w-full mr-3'>
|
||||||
|
<div className='flex flex-col w-full mr-3'>
|
||||||
|
<div className=' text-gray-500 font-bold'>
|
||||||
|
From
|
||||||
|
</div>
|
||||||
|
<Field
|
||||||
|
className={controlClasses}
|
||||||
|
name='filterValueFrom'
|
||||||
|
placeholder='From'
|
||||||
|
id='filterValueFrom'
|
||||||
|
type='datetime-local'
|
||||||
|
value={
|
||||||
|
filterItem?.fields?.filterValueFrom || ''
|
||||||
|
}
|
||||||
|
onChange={handleChange(filterItem.id)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className='flex flex-col w-full'>
|
||||||
|
<div className=' text-gray-500 font-bold'>
|
||||||
|
To
|
||||||
|
</div>
|
||||||
|
<Field
|
||||||
|
className={controlClasses}
|
||||||
|
name='filterValueTo'
|
||||||
|
placeholder='to'
|
||||||
|
id='filterValueTo'
|
||||||
|
type='datetime-local'
|
||||||
|
value={filterItem?.fields?.filterValueTo || ''}
|
||||||
|
onChange={handleChange(filterItem.id)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className='flex flex-col w-full mr-3'>
|
||||||
|
<div className=' text-gray-500 font-bold'>
|
||||||
|
Contains
|
||||||
|
</div>
|
||||||
|
<Field
|
||||||
|
className={controlClasses}
|
||||||
|
name='filterValue'
|
||||||
|
placeholder='Contained'
|
||||||
|
id='filterValue'
|
||||||
|
value={filterItem?.fields?.filterValue || ''}
|
||||||
|
onChange={handleChange(filterItem.id)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className='flex flex-col'>
|
||||||
|
<div className=' text-gray-500 font-bold'>
|
||||||
|
Action
|
||||||
|
</div>
|
||||||
|
<BaseButton
|
||||||
|
className='my-2'
|
||||||
|
type='reset'
|
||||||
|
color='danger'
|
||||||
|
label='Delete'
|
||||||
|
onClick={() => {
|
||||||
|
deleteFilter(filterItem.id);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
<div className='flex'>
|
||||||
|
<BaseButton
|
||||||
|
className='my-2 mr-3'
|
||||||
|
type='submit'
|
||||||
|
color='info'
|
||||||
|
label='Apply'
|
||||||
|
onClick={handleSubmit}
|
||||||
|
/>
|
||||||
|
<BaseButton
|
||||||
|
className='my-2'
|
||||||
|
type='reset'
|
||||||
|
color='info'
|
||||||
|
outline
|
||||||
|
label='Cancel'
|
||||||
|
onClick={handleReset}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
</Form>
|
||||||
|
</Formik>
|
||||||
|
</CardBox>
|
||||||
|
) : null}
|
||||||
|
<CardBoxModal
|
||||||
|
title='Please confirm'
|
||||||
|
buttonColor='info'
|
||||||
|
buttonLabel={loading ? 'Deleting...' : 'Confirm'}
|
||||||
|
isActive={isModalTrashActive}
|
||||||
|
onConfirm={handleDeleteAction}
|
||||||
|
onCancel={handleModalAction}
|
||||||
|
>
|
||||||
|
<p>Are you sure you want to delete this item?</p>
|
||||||
|
</CardBoxModal>
|
||||||
|
|
||||||
|
{dataGrid}
|
||||||
|
|
||||||
|
{selectedRows.length > 0 &&
|
||||||
|
createPortal(
|
||||||
|
<BaseButton
|
||||||
|
className='me-4'
|
||||||
|
color='danger'
|
||||||
|
label={`Delete ${selectedRows.length === 1 ? 'Row' : 'Rows'}`}
|
||||||
|
onClick={() => onDeleteRows(selectedRows)}
|
||||||
|
/>,
|
||||||
|
document.getElementById('delete-rows-button'),
|
||||||
|
)}
|
||||||
|
<ToastContainer />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TableSamplePowersportvehicles;
|
||||||
@ -0,0 +1,235 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import BaseIcon from '../BaseIcon';
|
||||||
|
import { mdiEye, mdiTrashCan, mdiPencilOutline } from '@mdi/js';
|
||||||
|
import axios from 'axios';
|
||||||
|
import {
|
||||||
|
GridActionsCellItem,
|
||||||
|
GridRowParams,
|
||||||
|
GridValueGetterParams,
|
||||||
|
} from '@mui/x-data-grid';
|
||||||
|
import ImageField from '../ImageField';
|
||||||
|
import { saveFile } from '../../helpers/fileSaver';
|
||||||
|
import dataFormatter from '../../helpers/dataFormatter';
|
||||||
|
import DataGridMultiSelect from '../DataGridMultiSelect';
|
||||||
|
import ListActionsPopover from '../ListActionsPopover';
|
||||||
|
|
||||||
|
import { hasPermission } from '../../helpers/userPermissions';
|
||||||
|
|
||||||
|
type Params = (id: string) => void;
|
||||||
|
|
||||||
|
export const loadColumns = async (
|
||||||
|
onDelete: Params,
|
||||||
|
entityName: string,
|
||||||
|
|
||||||
|
user,
|
||||||
|
) => {
|
||||||
|
async function callOptionsApi(entityName: string) {
|
||||||
|
if (!hasPermission(user, 'READ_' + entityName.toUpperCase())) return [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = await axios(`/${entityName}/autocomplete?limit=100`);
|
||||||
|
return data.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasUpdatePermission = hasPermission(user, 'UPDATE_POWERSPORTVEHICLES');
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
headerName: 'Name',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'description',
|
||||||
|
headerName: 'Description',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'photos',
|
||||||
|
headerName: 'Photos',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: false,
|
||||||
|
sortable: false,
|
||||||
|
renderCell: (params: GridValueGetterParams) => (
|
||||||
|
<ImageField
|
||||||
|
name={'Avatar'}
|
||||||
|
image={params?.row?.photos}
|
||||||
|
className='w-24 h-24 mx-auto lg:w-6 lg:h-6'
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'location',
|
||||||
|
headerName: 'Location',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'pricehourly',
|
||||||
|
headerName: 'Pricehourly',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
|
||||||
|
type: 'number',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'pricedaily',
|
||||||
|
headerName: 'Pricedaily',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
|
||||||
|
type: 'number',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'securitydeposit',
|
||||||
|
headerName: 'Securitydeposit',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
|
||||||
|
type: 'number',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'availabilitystart',
|
||||||
|
headerName: 'Availabilitystart',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
|
||||||
|
type: 'dateTime',
|
||||||
|
valueGetter: (params: GridValueGetterParams) =>
|
||||||
|
new Date(params.row.availabilitystart),
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'availabilityend',
|
||||||
|
headerName: 'Availabilityend',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
|
||||||
|
type: 'dateTime',
|
||||||
|
valueGetter: (params: GridValueGetterParams) =>
|
||||||
|
new Date(params.row.availabilityend),
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'vehicletype',
|
||||||
|
headerName: 'Vehicletype',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
|
||||||
|
type: 'singleSelect',
|
||||||
|
valueOptions: ['value'],
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'preptimebefore',
|
||||||
|
headerName: 'Preptimebefore',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
|
||||||
|
type: 'number',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'preptimebetween',
|
||||||
|
headerName: 'Preptimebetween',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
|
||||||
|
type: 'number',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'actions',
|
||||||
|
type: 'actions',
|
||||||
|
minWidth: 30,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
getActions: (params: GridRowParams) => {
|
||||||
|
return [
|
||||||
|
<div key={params?.row?.id}>
|
||||||
|
<ListActionsPopover
|
||||||
|
onDelete={onDelete}
|
||||||
|
itemId={params?.row?.id}
|
||||||
|
pathEdit={`/powersportvehicles/powersportvehicles-edit/?id=${params?.row?.id}`}
|
||||||
|
pathView={`/powersportvehicles/powersportvehicles-view/?id=${params?.row?.id}`}
|
||||||
|
hasUpdatePermission={hasUpdatePermission}
|
||||||
|
/>
|
||||||
|
</div>,
|
||||||
|
];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
};
|
||||||
@ -180,6 +180,17 @@ const CardVehicles = ({
|
|||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Vehicletype
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{item.vehicletype}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -118,6 +118,11 @@ const ListVehicles = ({
|
|||||||
.join(', ')}
|
.join(', ')}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>Vehicletype</p>
|
||||||
|
<p className={'line-clamp-2'}>{item.vehicletype}</p>
|
||||||
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
|
|||||||
@ -175,6 +175,21 @@ export const loadColumns = async (
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'vehicletype',
|
||||||
|
headerName: 'Vehicletype',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
|
||||||
|
type: 'singleSelect',
|
||||||
|
valueOptions: ['value'],
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'actions',
|
field: 'actions',
|
||||||
type: 'actions',
|
type: 'actions',
|
||||||
|
|||||||
@ -17,9 +17,9 @@ export default function WebSiteFooter({ projectName }: WebSiteFooterProps) {
|
|||||||
const borders = useAppSelector((state) => state.style.borders);
|
const borders = useAppSelector((state) => state.style.borders);
|
||||||
const websiteHeder = useAppSelector((state) => state.style.websiteHeder);
|
const websiteHeder = useAppSelector((state) => state.style.websiteHeder);
|
||||||
|
|
||||||
const style = FooterStyle.WITH_PAGES;
|
const style = FooterStyle.WITH_PROJECT_NAME;
|
||||||
|
|
||||||
const design = FooterDesigns.DEFAULT_DESIGN;
|
const design = FooterDesigns.DESIGN_DIVERSITY;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@ -17,9 +17,9 @@ export default function WebSiteHeader({ projectName }: WebSiteHeaderProps) {
|
|||||||
const websiteHeder = useAppSelector((state) => state.style.websiteHeder);
|
const websiteHeder = useAppSelector((state) => state.style.websiteHeder);
|
||||||
const borders = useAppSelector((state) => state.style.borders);
|
const borders = useAppSelector((state) => state.style.borders);
|
||||||
|
|
||||||
const style = HeaderStyle.PAGES_RIGHT;
|
const style = HeaderStyle.PAGES_LEFT;
|
||||||
|
|
||||||
const design = HeaderDesigns.DEFAULT_DESIGN;
|
const design = HeaderDesigns.DESIGN_DIVERSITY;
|
||||||
return (
|
return (
|
||||||
<header id='websiteHeader' className='overflow-hidden'>
|
<header id='websiteHeader' className='overflow-hidden'>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@ -152,4 +152,23 @@ export default {
|
|||||||
if (!val) return '';
|
if (!val) return '';
|
||||||
return { label: val.name, id: val.id };
|
return { label: val.name, id: val.id };
|
||||||
},
|
},
|
||||||
|
|
||||||
|
powersportvehiclesManyListFormatter(val) {
|
||||||
|
if (!val || !val.length) return [];
|
||||||
|
return val.map((item) => item.name);
|
||||||
|
},
|
||||||
|
powersportvehiclesOneListFormatter(val) {
|
||||||
|
if (!val) return '';
|
||||||
|
return val.name;
|
||||||
|
},
|
||||||
|
powersportvehiclesManyListFormatterEdit(val) {
|
||||||
|
if (!val || !val.length) return [];
|
||||||
|
return val.map((item) => {
|
||||||
|
return { id: item.id, label: item.name };
|
||||||
|
});
|
||||||
|
},
|
||||||
|
powersportvehiclesOneListFormatterEdit(val) {
|
||||||
|
if (!val) return '';
|
||||||
|
return { label: val.name, id: val.id };
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -62,6 +62,14 @@ const menuAside: MenuAsideItem[] = [
|
|||||||
icon: icon.mdiTable ?? icon.mdiTable,
|
icon: icon.mdiTable ?? icon.mdiTable,
|
||||||
permissions: 'READ_CLIENTS',
|
permissions: 'READ_CLIENTS',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
href: '/powersportvehicles/powersportvehicles-list',
|
||||||
|
label: 'Powersportvehicles',
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
|
icon: icon.mdiTable ?? icon.mdiTable,
|
||||||
|
permissions: 'READ_POWERSPORTVEHICLES',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
href: '/profile',
|
href: '/profile',
|
||||||
label: 'Profile',
|
label: 'Profile',
|
||||||
|
|||||||
@ -140,8 +140,8 @@ function MyApp({ Component, pageProps }: AppPropsWithLayout) {
|
|||||||
setStepsEnabled(false);
|
setStepsEnabled(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const title = 'Etherra';
|
const title = 'Powersport Rentals';
|
||||||
const description = 'Etherra generated by Flatlogic';
|
const description = 'Powersport Rentals generated by Flatlogic';
|
||||||
const url = 'https://flatlogic.com/';
|
const url = 'https://flatlogic.com/';
|
||||||
const image = `https://flatlogic.com/logo.svg`;
|
const image = `https://flatlogic.com/logo.svg`;
|
||||||
const imageWidth = '1920';
|
const imageWidth = '1920';
|
||||||
|
|||||||
@ -51,6 +51,8 @@ const EditBookings = () => {
|
|||||||
total_price: '',
|
total_price: '',
|
||||||
|
|
||||||
clients: null,
|
clients: null,
|
||||||
|
|
||||||
|
powersportvehicle: null,
|
||||||
};
|
};
|
||||||
const [initialValues, setInitialValues] = useState(initVals);
|
const [initialValues, setInitialValues] = useState(initVals);
|
||||||
|
|
||||||
@ -198,6 +200,17 @@ const EditBookings = () => {
|
|||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Powersportvehicle' labelFor='powersportvehicle'>
|
||||||
|
<Field
|
||||||
|
name='powersportvehicle'
|
||||||
|
id='powersportvehicle'
|
||||||
|
component={SelectField}
|
||||||
|
options={initialValues.powersportvehicle}
|
||||||
|
itemRef={'powersportvehicles'}
|
||||||
|
showField={'name'}
|
||||||
|
></Field>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -51,6 +51,8 @@ const EditBookingsPage = () => {
|
|||||||
total_price: '',
|
total_price: '',
|
||||||
|
|
||||||
clients: null,
|
clients: null,
|
||||||
|
|
||||||
|
powersportvehicle: null,
|
||||||
};
|
};
|
||||||
const [initialValues, setInitialValues] = useState(initVals);
|
const [initialValues, setInitialValues] = useState(initVals);
|
||||||
|
|
||||||
@ -196,6 +198,17 @@ const EditBookingsPage = () => {
|
|||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Powersportvehicle' labelFor='powersportvehicle'>
|
||||||
|
<Field
|
||||||
|
name='powersportvehicle'
|
||||||
|
id='powersportvehicle'
|
||||||
|
component={SelectField}
|
||||||
|
options={initialValues.powersportvehicle}
|
||||||
|
itemRef={'powersportvehicles'}
|
||||||
|
showField={'name'}
|
||||||
|
></Field>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -37,6 +37,8 @@ const BookingsTablesPage = () => {
|
|||||||
|
|
||||||
{ label: 'Rentee', title: 'rentee' },
|
{ label: 'Rentee', title: 'rentee' },
|
||||||
|
|
||||||
|
{ label: 'Powersportvehicle', title: 'powersportvehicle' },
|
||||||
|
|
||||||
{
|
{
|
||||||
label: 'Status',
|
label: 'Status',
|
||||||
title: 'status',
|
title: 'status',
|
||||||
|
|||||||
@ -46,6 +46,8 @@ const initialValues = {
|
|||||||
total_price: '',
|
total_price: '',
|
||||||
|
|
||||||
clients: '',
|
clients: '',
|
||||||
|
|
||||||
|
powersportvehicle: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
const BookingsNew = () => {
|
const BookingsNew = () => {
|
||||||
@ -155,6 +157,16 @@ const BookingsNew = () => {
|
|||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Powersportvehicle' labelFor='powersportvehicle'>
|
||||||
|
<Field
|
||||||
|
name='powersportvehicle'
|
||||||
|
id='powersportvehicle'
|
||||||
|
component={SelectField}
|
||||||
|
options={[]}
|
||||||
|
itemRef={'powersportvehicles'}
|
||||||
|
></Field>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -37,6 +37,8 @@ const BookingsTablesPage = () => {
|
|||||||
|
|
||||||
{ label: 'Rentee', title: 'rentee' },
|
{ label: 'Rentee', title: 'rentee' },
|
||||||
|
|
||||||
|
{ label: 'Powersportvehicle', title: 'powersportvehicle' },
|
||||||
|
|
||||||
{
|
{
|
||||||
label: 'Status',
|
label: 'Status',
|
||||||
title: 'status',
|
title: 'status',
|
||||||
|
|||||||
@ -124,6 +124,12 @@ const BookingsView = () => {
|
|||||||
<p>{bookings?.clients?.name ?? 'No data'}</p>
|
<p>{bookings?.clients?.name ?? 'No data'}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Powersportvehicle</p>
|
||||||
|
|
||||||
|
<p>{bookings?.powersportvehicle?.name ?? 'No data'}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
|
|
||||||
<BaseButton
|
<BaseButton
|
||||||
|
|||||||
@ -188,6 +188,8 @@ const ClientsView = () => {
|
|||||||
<th>PriceDaily</th>
|
<th>PriceDaily</th>
|
||||||
|
|
||||||
<th>SecurityDeposit</th>
|
<th>SecurityDeposit</th>
|
||||||
|
|
||||||
|
<th>Vehicletype</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -213,6 +215,8 @@ const ClientsView = () => {
|
|||||||
<td data-label='security_deposit'>
|
<td data-label='security_deposit'>
|
||||||
{item.security_deposit}
|
{item.security_deposit}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
<td data-label='vehicletype'>{item.vehicletype}</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -224,6 +228,97 @@ const ClientsView = () => {
|
|||||||
</CardBox>
|
</CardBox>
|
||||||
</>
|
</>
|
||||||
|
|
||||||
|
<>
|
||||||
|
<p className={'block font-bold mb-2'}>Powersportvehicles clients</p>
|
||||||
|
<CardBox
|
||||||
|
className='mb-6 border border-gray-300 rounded overflow-hidden'
|
||||||
|
hasTable
|
||||||
|
>
|
||||||
|
<div className='overflow-x-auto'>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
|
||||||
|
<th>Description</th>
|
||||||
|
|
||||||
|
<th>Location</th>
|
||||||
|
|
||||||
|
<th>Pricehourly</th>
|
||||||
|
|
||||||
|
<th>Pricedaily</th>
|
||||||
|
|
||||||
|
<th>Securitydeposit</th>
|
||||||
|
|
||||||
|
<th>Availabilitystart</th>
|
||||||
|
|
||||||
|
<th>Availabilityend</th>
|
||||||
|
|
||||||
|
<th>Vehicletype</th>
|
||||||
|
|
||||||
|
<th>Preptimebefore</th>
|
||||||
|
|
||||||
|
<th>Preptimebetween</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{clients.powersportvehicles_clients &&
|
||||||
|
Array.isArray(clients.powersportvehicles_clients) &&
|
||||||
|
clients.powersportvehicles_clients.map((item: any) => (
|
||||||
|
<tr
|
||||||
|
key={item.id}
|
||||||
|
onClick={() =>
|
||||||
|
router.push(
|
||||||
|
`/powersportvehicles/powersportvehicles-view/?id=${item.id}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<td data-label='name'>{item.name}</td>
|
||||||
|
|
||||||
|
<td data-label='description'>{item.description}</td>
|
||||||
|
|
||||||
|
<td data-label='location'>{item.location}</td>
|
||||||
|
|
||||||
|
<td data-label='pricehourly'>{item.pricehourly}</td>
|
||||||
|
|
||||||
|
<td data-label='pricedaily'>{item.pricedaily}</td>
|
||||||
|
|
||||||
|
<td data-label='securitydeposit'>
|
||||||
|
{item.securitydeposit}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td data-label='availabilitystart'>
|
||||||
|
{dataFormatter.dateTimeFormatter(
|
||||||
|
item.availabilitystart,
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td data-label='availabilityend'>
|
||||||
|
{dataFormatter.dateTimeFormatter(
|
||||||
|
item.availabilityend,
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td data-label='vehicletype'>{item.vehicletype}</td>
|
||||||
|
|
||||||
|
<td data-label='preptimebefore'>
|
||||||
|
{item.preptimebefore}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td data-label='preptimebetween'>
|
||||||
|
{item.preptimebetween}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{!clients?.powersportvehicles_clients?.length && (
|
||||||
|
<div className={'text-center py-4'}>No data</div>
|
||||||
|
)}
|
||||||
|
</CardBox>
|
||||||
|
</>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
|
|
||||||
<BaseButton
|
<BaseButton
|
||||||
|
|||||||
@ -34,6 +34,8 @@ const Dashboard = () => {
|
|||||||
const [roles, setRoles] = React.useState(loadingMessage);
|
const [roles, setRoles] = React.useState(loadingMessage);
|
||||||
const [permissions, setPermissions] = React.useState(loadingMessage);
|
const [permissions, setPermissions] = React.useState(loadingMessage);
|
||||||
const [clients, setClients] = React.useState(loadingMessage);
|
const [clients, setClients] = React.useState(loadingMessage);
|
||||||
|
const [powersportvehicles, setPowersportvehicles] =
|
||||||
|
React.useState(loadingMessage);
|
||||||
|
|
||||||
const [widgetsRole, setWidgetsRole] = React.useState({
|
const [widgetsRole, setWidgetsRole] = React.useState({
|
||||||
role: { value: '', label: '' },
|
role: { value: '', label: '' },
|
||||||
@ -53,6 +55,7 @@ const Dashboard = () => {
|
|||||||
'roles',
|
'roles',
|
||||||
'permissions',
|
'permissions',
|
||||||
'clients',
|
'clients',
|
||||||
|
'powersportvehicles',
|
||||||
];
|
];
|
||||||
const fns = [
|
const fns = [
|
||||||
setUsers,
|
setUsers,
|
||||||
@ -61,6 +64,7 @@ const Dashboard = () => {
|
|||||||
setRoles,
|
setRoles,
|
||||||
setPermissions,
|
setPermissions,
|
||||||
setClients,
|
setClients,
|
||||||
|
setPowersportvehicles,
|
||||||
];
|
];
|
||||||
|
|
||||||
const requests = entities.map((entity, index) => {
|
const requests = entities.map((entity, index) => {
|
||||||
@ -376,6 +380,38 @@ const Dashboard = () => {
|
|||||||
</div>
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{hasPermission(currentUser, 'READ_POWERSPORTVEHICLES') && (
|
||||||
|
<Link href={'/powersportvehicles/powersportvehicles-list'}>
|
||||||
|
<div
|
||||||
|
className={`${
|
||||||
|
corners !== 'rounded-full' ? corners : 'rounded-3xl'
|
||||||
|
} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}
|
||||||
|
>
|
||||||
|
<div className='flex justify-between align-center'>
|
||||||
|
<div>
|
||||||
|
<div className='text-lg leading-tight text-gray-500 dark:text-gray-400'>
|
||||||
|
Powersportvehicles
|
||||||
|
</div>
|
||||||
|
<div className='text-3xl leading-tight font-semibold'>
|
||||||
|
{powersportvehicles}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<BaseIcon
|
||||||
|
className={`${iconsColor}`}
|
||||||
|
w='w-16'
|
||||||
|
h='h-16'
|
||||||
|
size={48}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
|
path={icon.mdiTable || icon.mdiTable}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</SectionMain>
|
</SectionMain>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import ContactFormSection from '../components/WebPageComponents/ContactFormCompo
|
|||||||
export default function WebSite() {
|
export default function WebSite() {
|
||||||
const cardsStyle = useAppSelector((state) => state.style.cardsStyle);
|
const cardsStyle = useAppSelector((state) => state.style.cardsStyle);
|
||||||
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
||||||
const projectName = 'Etherra';
|
const projectName = 'Powersport Rentals';
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const darkElement = document.querySelector('body .dark');
|
const darkElement = document.querySelector('body .dark');
|
||||||
@ -112,10 +112,10 @@ export default function WebSite() {
|
|||||||
content={`Discover and rent recreational vehicles with ease on our peer-to-peer RV rental platform. List your RV or find the perfect one for your next adventure.`}
|
content={`Discover and rent recreational vehicles with ease on our peer-to-peer RV rental platform. List your RV or find the perfect one for your next adventure.`}
|
||||||
/>
|
/>
|
||||||
</Head>
|
</Head>
|
||||||
<WebSiteHeader projectName={'Etherra'} pages={pages} />
|
<WebSiteHeader projectName={'Powersport Rentals'} pages={pages} />
|
||||||
<main className={`flex-grow ${bgColor} rounded-none `}>
|
<main className={`flex-grow ${bgColor} rounded-none `}>
|
||||||
<HeroSection
|
<HeroSection
|
||||||
projectName={'Etherra'}
|
projectName={'Powersport Rentals'}
|
||||||
image={['RV on a scenic highway']}
|
image={['RV on a scenic highway']}
|
||||||
mainText={`Explore the Open Road with ${projectName}`}
|
mainText={`Explore the Open Road with ${projectName}`}
|
||||||
subTitle={`Discover the freedom of the open road with our peer-to-peer RV rental platform. Whether you're listing your RV or searching for the perfect getaway vehicle, ${projectName} makes it easy and secure.`}
|
subTitle={`Discover the freedom of the open road with our peer-to-peer RV rental platform. Whether you're listing your RV or searching for the perfect getaway vehicle, ${projectName} makes it easy and secure.`}
|
||||||
@ -124,9 +124,9 @@ export default function WebSite() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<FeaturesSection
|
<FeaturesSection
|
||||||
projectName={'Etherra'}
|
projectName={'Powersport Rentals'}
|
||||||
image={['RV keys and map']}
|
image={['RV keys and map']}
|
||||||
withBg={0}
|
withBg={1}
|
||||||
features={features_points}
|
features={features_points}
|
||||||
mainText={`Discover Key Features of ${projectName}`}
|
mainText={`Discover Key Features of ${projectName}`}
|
||||||
subTitle={`Explore the unique features of ${projectName} that make RV renting seamless and enjoyable for both renters and rentees.`}
|
subTitle={`Explore the unique features of ${projectName} that make RV renting seamless and enjoyable for both renters and rentees.`}
|
||||||
@ -134,21 +134,21 @@ export default function WebSite() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<TestimonialsSection
|
<TestimonialsSection
|
||||||
projectName={'Etherra'}
|
projectName={'Powersport Rentals'}
|
||||||
design={TestimonialsDesigns.MULTI_CARD_DISPLAY || ''}
|
design={TestimonialsDesigns.MULTI_CARD_DISPLAY || ''}
|
||||||
testimonials={testimonials}
|
testimonials={testimonials}
|
||||||
mainText={`What Our Users Say About ${projectName} `}
|
mainText={`What Our Users Say About ${projectName} `}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ContactFormSection
|
<ContactFormSection
|
||||||
projectName={'Etherra'}
|
projectName={'Powersport Rentals'}
|
||||||
design={ContactFormDesigns.WITH_IMAGE || ''}
|
design={ContactFormDesigns.WITH_IMAGE || ''}
|
||||||
image={['Contact form on a tablet']}
|
image={['Contact form on a tablet']}
|
||||||
mainText={`Get in Touch with ${projectName} `}
|
mainText={`Get in Touch with ${projectName} `}
|
||||||
subTitle={`Have questions or need assistance? Reach out to us anytime, and our team will respond promptly to ensure your experience with ${projectName} is seamless.`}
|
subTitle={`Have questions or need assistance? Reach out to us anytime, and our team will respond promptly to ensure your experience with ${projectName} is seamless.`}
|
||||||
/>
|
/>
|
||||||
</main>
|
</main>
|
||||||
<WebSiteFooter projectName={'Etherra'} pages={pages} />
|
<WebSiteFooter projectName={'Powersport Rentals'} pages={pages} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,7 +52,7 @@ export default function Login() {
|
|||||||
remember: true,
|
remember: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const title = 'Etherra';
|
const title = 'Powersport Rentals';
|
||||||
|
|
||||||
// Fetch Pexels image/video
|
// Fetch Pexels image/video
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
288
frontend/src/pages/powersportvehicles/[powersportvehiclesId].tsx
Normal file
288
frontend/src/pages/powersportvehicles/[powersportvehiclesId].tsx
Normal file
@ -0,0 +1,288 @@
|
|||||||
|
import { mdiChartTimelineVariant, mdiUpload } from '@mdi/js';
|
||||||
|
import Head from 'next/head';
|
||||||
|
import React, { ReactElement, useEffect, useState } from 'react';
|
||||||
|
import DatePicker from 'react-datepicker';
|
||||||
|
import 'react-datepicker/dist/react-datepicker.css';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
import CardBox from '../../components/CardBox';
|
||||||
|
import LayoutAuthenticated from '../../layouts/Authenticated';
|
||||||
|
import SectionMain from '../../components/SectionMain';
|
||||||
|
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
|
||||||
|
import { getPageTitle } from '../../config';
|
||||||
|
|
||||||
|
import { Field, Form, Formik } from 'formik';
|
||||||
|
import FormField from '../../components/FormField';
|
||||||
|
import BaseDivider from '../../components/BaseDivider';
|
||||||
|
import BaseButtons from '../../components/BaseButtons';
|
||||||
|
import BaseButton from '../../components/BaseButton';
|
||||||
|
import FormCheckRadio from '../../components/FormCheckRadio';
|
||||||
|
import FormCheckRadioGroup from '../../components/FormCheckRadioGroup';
|
||||||
|
import FormFilePicker from '../../components/FormFilePicker';
|
||||||
|
import FormImagePicker from '../../components/FormImagePicker';
|
||||||
|
import { SelectField } from '../../components/SelectField';
|
||||||
|
import { SelectFieldMany } from '../../components/SelectFieldMany';
|
||||||
|
import { SwitchField } from '../../components/SwitchField';
|
||||||
|
import { RichTextField } from '../../components/RichTextField';
|
||||||
|
|
||||||
|
import {
|
||||||
|
update,
|
||||||
|
fetch,
|
||||||
|
} from '../../stores/powersportvehicles/powersportvehiclesSlice';
|
||||||
|
import { useAppDispatch, useAppSelector } from '../../stores/hooks';
|
||||||
|
import { useRouter } from 'next/router';
|
||||||
|
import { saveFile } from '../../helpers/fileSaver';
|
||||||
|
import dataFormatter from '../../helpers/dataFormatter';
|
||||||
|
import ImageField from '../../components/ImageField';
|
||||||
|
|
||||||
|
import { hasPermission } from '../../helpers/userPermissions';
|
||||||
|
|
||||||
|
const EditPowersportvehicles = () => {
|
||||||
|
const router = useRouter();
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
const initVals = {
|
||||||
|
clients: null,
|
||||||
|
|
||||||
|
name: '',
|
||||||
|
|
||||||
|
description: '',
|
||||||
|
|
||||||
|
photos: [],
|
||||||
|
|
||||||
|
location: '',
|
||||||
|
|
||||||
|
pricehourly: '',
|
||||||
|
|
||||||
|
pricedaily: '',
|
||||||
|
|
||||||
|
securitydeposit: '',
|
||||||
|
|
||||||
|
availabilitystart: new Date(),
|
||||||
|
|
||||||
|
availabilityend: new Date(),
|
||||||
|
|
||||||
|
vehicletype: '',
|
||||||
|
|
||||||
|
preptimebefore: '',
|
||||||
|
|
||||||
|
preptimebetween: '',
|
||||||
|
};
|
||||||
|
const [initialValues, setInitialValues] = useState(initVals);
|
||||||
|
|
||||||
|
const { powersportvehicles } = useAppSelector(
|
||||||
|
(state) => state.powersportvehicles,
|
||||||
|
);
|
||||||
|
|
||||||
|
const { currentUser } = useAppSelector((state) => state.auth);
|
||||||
|
|
||||||
|
const { powersportvehiclesId } = router.query;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
dispatch(fetch({ id: powersportvehiclesId }));
|
||||||
|
}, [powersportvehiclesId]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (typeof powersportvehicles === 'object') {
|
||||||
|
setInitialValues(powersportvehicles);
|
||||||
|
}
|
||||||
|
}, [powersportvehicles]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (typeof powersportvehicles === 'object') {
|
||||||
|
const newInitialVal = { ...initVals };
|
||||||
|
|
||||||
|
Object.keys(initVals).forEach(
|
||||||
|
(el) => (newInitialVal[el] = powersportvehicles[el]),
|
||||||
|
);
|
||||||
|
|
||||||
|
setInitialValues(newInitialVal);
|
||||||
|
}
|
||||||
|
}, [powersportvehicles]);
|
||||||
|
|
||||||
|
const handleSubmit = async (data) => {
|
||||||
|
await dispatch(update({ id: powersportvehiclesId, data }));
|
||||||
|
await router.push('/powersportvehicles/powersportvehicles-list');
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Head>
|
||||||
|
<title>{getPageTitle('Edit powersportvehicles')}</title>
|
||||||
|
</Head>
|
||||||
|
<SectionMain>
|
||||||
|
<SectionTitleLineWithButton
|
||||||
|
icon={mdiChartTimelineVariant}
|
||||||
|
title={'Edit powersportvehicles'}
|
||||||
|
main
|
||||||
|
>
|
||||||
|
{''}
|
||||||
|
</SectionTitleLineWithButton>
|
||||||
|
<CardBox>
|
||||||
|
<Formik
|
||||||
|
enableReinitialize
|
||||||
|
initialValues={initialValues}
|
||||||
|
onSubmit={(values) => handleSubmit(values)}
|
||||||
|
>
|
||||||
|
<Form>
|
||||||
|
<FormField label='clients' labelFor='clients'>
|
||||||
|
<Field
|
||||||
|
name='clients'
|
||||||
|
id='clients'
|
||||||
|
component={SelectField}
|
||||||
|
options={initialValues.clients}
|
||||||
|
itemRef={'clients'}
|
||||||
|
showField={'name'}
|
||||||
|
></Field>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Name'>
|
||||||
|
<Field name='name' placeholder='Name' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Description'>
|
||||||
|
<Field name='description' placeholder='Description' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField>
|
||||||
|
<Field
|
||||||
|
label='Photos'
|
||||||
|
color='info'
|
||||||
|
icon={mdiUpload}
|
||||||
|
path={'powersportvehicles/photos'}
|
||||||
|
name='photos'
|
||||||
|
id='photos'
|
||||||
|
schema={{
|
||||||
|
size: undefined,
|
||||||
|
formats: undefined,
|
||||||
|
}}
|
||||||
|
component={FormImagePicker}
|
||||||
|
></Field>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Location'>
|
||||||
|
<Field name='location' placeholder='Location' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Pricehourly'>
|
||||||
|
<Field
|
||||||
|
type='number'
|
||||||
|
name='pricehourly'
|
||||||
|
placeholder='Pricehourly'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Pricedaily'>
|
||||||
|
<Field
|
||||||
|
type='number'
|
||||||
|
name='pricedaily'
|
||||||
|
placeholder='Pricedaily'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Securitydeposit'>
|
||||||
|
<Field
|
||||||
|
type='number'
|
||||||
|
name='securitydeposit'
|
||||||
|
placeholder='Securitydeposit'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Availabilitystart'>
|
||||||
|
<DatePicker
|
||||||
|
dateFormat='yyyy-MM-dd hh:mm'
|
||||||
|
showTimeSelect
|
||||||
|
selected={
|
||||||
|
initialValues.availabilitystart
|
||||||
|
? new Date(
|
||||||
|
dayjs(initialValues.availabilitystart).format(
|
||||||
|
'YYYY-MM-DD hh:mm',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
onChange={(date) =>
|
||||||
|
setInitialValues({
|
||||||
|
...initialValues,
|
||||||
|
availabilitystart: date,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Availabilityend'>
|
||||||
|
<DatePicker
|
||||||
|
dateFormat='yyyy-MM-dd hh:mm'
|
||||||
|
showTimeSelect
|
||||||
|
selected={
|
||||||
|
initialValues.availabilityend
|
||||||
|
? new Date(
|
||||||
|
dayjs(initialValues.availabilityend).format(
|
||||||
|
'YYYY-MM-DD hh:mm',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
onChange={(date) =>
|
||||||
|
setInitialValues({
|
||||||
|
...initialValues,
|
||||||
|
availabilityend: date,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Vehicletype'>
|
||||||
|
<FormCheckRadioGroup>
|
||||||
|
<FormCheckRadio type='radio' label='value'>
|
||||||
|
<Field type='radio' name='vehicletype' value='value' />
|
||||||
|
</FormCheckRadio>
|
||||||
|
</FormCheckRadioGroup>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Preptimebefore'>
|
||||||
|
<Field
|
||||||
|
type='number'
|
||||||
|
name='preptimebefore'
|
||||||
|
placeholder='Preptimebefore'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Preptimebetween'>
|
||||||
|
<Field
|
||||||
|
type='number'
|
||||||
|
name='preptimebetween'
|
||||||
|
placeholder='Preptimebetween'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<BaseDivider />
|
||||||
|
<BaseButtons>
|
||||||
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
<BaseButton type='reset' color='info' outline label='Reset' />
|
||||||
|
<BaseButton
|
||||||
|
type='reset'
|
||||||
|
color='danger'
|
||||||
|
outline
|
||||||
|
label='Cancel'
|
||||||
|
onClick={() =>
|
||||||
|
router.push('/powersportvehicles/powersportvehicles-list')
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</BaseButtons>
|
||||||
|
</Form>
|
||||||
|
</Formik>
|
||||||
|
</CardBox>
|
||||||
|
</SectionMain>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
EditPowersportvehicles.getLayout = function getLayout(page: ReactElement) {
|
||||||
|
return (
|
||||||
|
<LayoutAuthenticated permission={'UPDATE_POWERSPORTVEHICLES'}>
|
||||||
|
{page}
|
||||||
|
</LayoutAuthenticated>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EditPowersportvehicles;
|
||||||
@ -0,0 +1,286 @@
|
|||||||
|
import { mdiChartTimelineVariant, mdiUpload } from '@mdi/js';
|
||||||
|
import Head from 'next/head';
|
||||||
|
import React, { ReactElement, useEffect, useState } from 'react';
|
||||||
|
import DatePicker from 'react-datepicker';
|
||||||
|
import 'react-datepicker/dist/react-datepicker.css';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
import CardBox from '../../components/CardBox';
|
||||||
|
import LayoutAuthenticated from '../../layouts/Authenticated';
|
||||||
|
import SectionMain from '../../components/SectionMain';
|
||||||
|
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
|
||||||
|
import { getPageTitle } from '../../config';
|
||||||
|
|
||||||
|
import { Field, Form, Formik } from 'formik';
|
||||||
|
import FormField from '../../components/FormField';
|
||||||
|
import BaseDivider from '../../components/BaseDivider';
|
||||||
|
import BaseButtons from '../../components/BaseButtons';
|
||||||
|
import BaseButton from '../../components/BaseButton';
|
||||||
|
import FormCheckRadio from '../../components/FormCheckRadio';
|
||||||
|
import FormCheckRadioGroup from '../../components/FormCheckRadioGroup';
|
||||||
|
import FormFilePicker from '../../components/FormFilePicker';
|
||||||
|
import FormImagePicker from '../../components/FormImagePicker';
|
||||||
|
import { SelectField } from '../../components/SelectField';
|
||||||
|
import { SelectFieldMany } from '../../components/SelectFieldMany';
|
||||||
|
import { SwitchField } from '../../components/SwitchField';
|
||||||
|
import { RichTextField } from '../../components/RichTextField';
|
||||||
|
|
||||||
|
import {
|
||||||
|
update,
|
||||||
|
fetch,
|
||||||
|
} from '../../stores/powersportvehicles/powersportvehiclesSlice';
|
||||||
|
import { useAppDispatch, useAppSelector } from '../../stores/hooks';
|
||||||
|
import { useRouter } from 'next/router';
|
||||||
|
import { saveFile } from '../../helpers/fileSaver';
|
||||||
|
import dataFormatter from '../../helpers/dataFormatter';
|
||||||
|
import ImageField from '../../components/ImageField';
|
||||||
|
|
||||||
|
import { hasPermission } from '../../helpers/userPermissions';
|
||||||
|
|
||||||
|
const EditPowersportvehiclesPage = () => {
|
||||||
|
const router = useRouter();
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
const initVals = {
|
||||||
|
clients: null,
|
||||||
|
|
||||||
|
name: '',
|
||||||
|
|
||||||
|
description: '',
|
||||||
|
|
||||||
|
photos: [],
|
||||||
|
|
||||||
|
location: '',
|
||||||
|
|
||||||
|
pricehourly: '',
|
||||||
|
|
||||||
|
pricedaily: '',
|
||||||
|
|
||||||
|
securitydeposit: '',
|
||||||
|
|
||||||
|
availabilitystart: new Date(),
|
||||||
|
|
||||||
|
availabilityend: new Date(),
|
||||||
|
|
||||||
|
vehicletype: '',
|
||||||
|
|
||||||
|
preptimebefore: '',
|
||||||
|
|
||||||
|
preptimebetween: '',
|
||||||
|
};
|
||||||
|
const [initialValues, setInitialValues] = useState(initVals);
|
||||||
|
|
||||||
|
const { powersportvehicles } = useAppSelector(
|
||||||
|
(state) => state.powersportvehicles,
|
||||||
|
);
|
||||||
|
|
||||||
|
const { currentUser } = useAppSelector((state) => state.auth);
|
||||||
|
|
||||||
|
const { id } = router.query;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
dispatch(fetch({ id: id }));
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (typeof powersportvehicles === 'object') {
|
||||||
|
setInitialValues(powersportvehicles);
|
||||||
|
}
|
||||||
|
}, [powersportvehicles]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (typeof powersportvehicles === 'object') {
|
||||||
|
const newInitialVal = { ...initVals };
|
||||||
|
Object.keys(initVals).forEach(
|
||||||
|
(el) => (newInitialVal[el] = powersportvehicles[el]),
|
||||||
|
);
|
||||||
|
setInitialValues(newInitialVal);
|
||||||
|
}
|
||||||
|
}, [powersportvehicles]);
|
||||||
|
|
||||||
|
const handleSubmit = async (data) => {
|
||||||
|
await dispatch(update({ id: id, data }));
|
||||||
|
await router.push('/powersportvehicles/powersportvehicles-list');
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Head>
|
||||||
|
<title>{getPageTitle('Edit powersportvehicles')}</title>
|
||||||
|
</Head>
|
||||||
|
<SectionMain>
|
||||||
|
<SectionTitleLineWithButton
|
||||||
|
icon={mdiChartTimelineVariant}
|
||||||
|
title={'Edit powersportvehicles'}
|
||||||
|
main
|
||||||
|
>
|
||||||
|
{''}
|
||||||
|
</SectionTitleLineWithButton>
|
||||||
|
<CardBox>
|
||||||
|
<Formik
|
||||||
|
enableReinitialize
|
||||||
|
initialValues={initialValues}
|
||||||
|
onSubmit={(values) => handleSubmit(values)}
|
||||||
|
>
|
||||||
|
<Form>
|
||||||
|
<FormField label='clients' labelFor='clients'>
|
||||||
|
<Field
|
||||||
|
name='clients'
|
||||||
|
id='clients'
|
||||||
|
component={SelectField}
|
||||||
|
options={initialValues.clients}
|
||||||
|
itemRef={'clients'}
|
||||||
|
showField={'name'}
|
||||||
|
></Field>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Name'>
|
||||||
|
<Field name='name' placeholder='Name' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Description'>
|
||||||
|
<Field name='description' placeholder='Description' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField>
|
||||||
|
<Field
|
||||||
|
label='Photos'
|
||||||
|
color='info'
|
||||||
|
icon={mdiUpload}
|
||||||
|
path={'powersportvehicles/photos'}
|
||||||
|
name='photos'
|
||||||
|
id='photos'
|
||||||
|
schema={{
|
||||||
|
size: undefined,
|
||||||
|
formats: undefined,
|
||||||
|
}}
|
||||||
|
component={FormImagePicker}
|
||||||
|
></Field>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Location'>
|
||||||
|
<Field name='location' placeholder='Location' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Pricehourly'>
|
||||||
|
<Field
|
||||||
|
type='number'
|
||||||
|
name='pricehourly'
|
||||||
|
placeholder='Pricehourly'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Pricedaily'>
|
||||||
|
<Field
|
||||||
|
type='number'
|
||||||
|
name='pricedaily'
|
||||||
|
placeholder='Pricedaily'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Securitydeposit'>
|
||||||
|
<Field
|
||||||
|
type='number'
|
||||||
|
name='securitydeposit'
|
||||||
|
placeholder='Securitydeposit'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Availabilitystart'>
|
||||||
|
<DatePicker
|
||||||
|
dateFormat='yyyy-MM-dd hh:mm'
|
||||||
|
showTimeSelect
|
||||||
|
selected={
|
||||||
|
initialValues.availabilitystart
|
||||||
|
? new Date(
|
||||||
|
dayjs(initialValues.availabilitystart).format(
|
||||||
|
'YYYY-MM-DD hh:mm',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
onChange={(date) =>
|
||||||
|
setInitialValues({
|
||||||
|
...initialValues,
|
||||||
|
availabilitystart: date,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Availabilityend'>
|
||||||
|
<DatePicker
|
||||||
|
dateFormat='yyyy-MM-dd hh:mm'
|
||||||
|
showTimeSelect
|
||||||
|
selected={
|
||||||
|
initialValues.availabilityend
|
||||||
|
? new Date(
|
||||||
|
dayjs(initialValues.availabilityend).format(
|
||||||
|
'YYYY-MM-DD hh:mm',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
onChange={(date) =>
|
||||||
|
setInitialValues({
|
||||||
|
...initialValues,
|
||||||
|
availabilityend: date,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Vehicletype'>
|
||||||
|
<FormCheckRadioGroup>
|
||||||
|
<FormCheckRadio type='radio' label='value'>
|
||||||
|
<Field type='radio' name='vehicletype' value='value' />
|
||||||
|
</FormCheckRadio>
|
||||||
|
</FormCheckRadioGroup>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Preptimebefore'>
|
||||||
|
<Field
|
||||||
|
type='number'
|
||||||
|
name='preptimebefore'
|
||||||
|
placeholder='Preptimebefore'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Preptimebetween'>
|
||||||
|
<Field
|
||||||
|
type='number'
|
||||||
|
name='preptimebetween'
|
||||||
|
placeholder='Preptimebetween'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<BaseDivider />
|
||||||
|
<BaseButtons>
|
||||||
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
<BaseButton type='reset' color='info' outline label='Reset' />
|
||||||
|
<BaseButton
|
||||||
|
type='reset'
|
||||||
|
color='danger'
|
||||||
|
outline
|
||||||
|
label='Cancel'
|
||||||
|
onClick={() =>
|
||||||
|
router.push('/powersportvehicles/powersportvehicles-list')
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</BaseButtons>
|
||||||
|
</Form>
|
||||||
|
</Formik>
|
||||||
|
</CardBox>
|
||||||
|
</SectionMain>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
EditPowersportvehiclesPage.getLayout = function getLayout(page: ReactElement) {
|
||||||
|
return (
|
||||||
|
<LayoutAuthenticated permission={'UPDATE_POWERSPORTVEHICLES'}>
|
||||||
|
{page}
|
||||||
|
</LayoutAuthenticated>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EditPowersportvehiclesPage;
|
||||||
@ -0,0 +1,185 @@
|
|||||||
|
import { mdiChartTimelineVariant } from '@mdi/js';
|
||||||
|
import Head from 'next/head';
|
||||||
|
import { uniqueId } from 'lodash';
|
||||||
|
import React, { ReactElement, useState } from 'react';
|
||||||
|
import CardBox from '../../components/CardBox';
|
||||||
|
import LayoutAuthenticated from '../../layouts/Authenticated';
|
||||||
|
import SectionMain from '../../components/SectionMain';
|
||||||
|
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
|
||||||
|
import { getPageTitle } from '../../config';
|
||||||
|
import TablePowersportvehicles from '../../components/Powersportvehicles/TablePowersportvehicles';
|
||||||
|
import BaseButton from '../../components/BaseButton';
|
||||||
|
import axios from 'axios';
|
||||||
|
import Link from 'next/link';
|
||||||
|
import { useAppDispatch, useAppSelector } from '../../stores/hooks';
|
||||||
|
import CardBoxModal from '../../components/CardBoxModal';
|
||||||
|
import DragDropFilePicker from '../../components/DragDropFilePicker';
|
||||||
|
import {
|
||||||
|
setRefetch,
|
||||||
|
uploadCsv,
|
||||||
|
} from '../../stores/powersportvehicles/powersportvehiclesSlice';
|
||||||
|
|
||||||
|
import { hasPermission } from '../../helpers/userPermissions';
|
||||||
|
|
||||||
|
const PowersportvehiclesTablesPage = () => {
|
||||||
|
const [filterItems, setFilterItems] = useState([]);
|
||||||
|
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||||
|
const [isModalActive, setIsModalActive] = useState(false);
|
||||||
|
const [showTableView, setShowTableView] = useState(false);
|
||||||
|
|
||||||
|
const { currentUser } = useAppSelector((state) => state.auth);
|
||||||
|
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
const [filters] = useState([
|
||||||
|
{ label: 'Name', title: 'name' },
|
||||||
|
{ label: 'Description', title: 'description' },
|
||||||
|
{ label: 'Location', title: 'location' },
|
||||||
|
{ label: 'Preptimebefore', title: 'preptimebefore', number: 'true' },
|
||||||
|
{ label: 'Preptimebetween', title: 'preptimebetween', number: 'true' },
|
||||||
|
{ label: 'Pricehourly', title: 'pricehourly', number: 'true' },
|
||||||
|
{ label: 'Pricedaily', title: 'pricedaily', number: 'true' },
|
||||||
|
{ label: 'Securitydeposit', title: 'securitydeposit', number: 'true' },
|
||||||
|
{ label: 'Availabilitystart', title: 'availabilitystart', date: 'true' },
|
||||||
|
{ label: 'Availabilityend', title: 'availabilityend', date: 'true' },
|
||||||
|
|
||||||
|
{
|
||||||
|
label: 'Vehicletype',
|
||||||
|
title: 'vehicletype',
|
||||||
|
type: 'enum',
|
||||||
|
options: ['value'],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const hasCreatePermission =
|
||||||
|
currentUser && hasPermission(currentUser, 'CREATE_POWERSPORTVEHICLES');
|
||||||
|
|
||||||
|
const addFilter = () => {
|
||||||
|
const newItem = {
|
||||||
|
id: uniqueId(),
|
||||||
|
fields: {
|
||||||
|
filterValue: '',
|
||||||
|
filterValueFrom: '',
|
||||||
|
filterValueTo: '',
|
||||||
|
selectedField: '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
newItem.fields.selectedField = filters[0].title;
|
||||||
|
setFilterItems([...filterItems, newItem]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getPowersportvehiclesCSV = async () => {
|
||||||
|
const response = await axios({
|
||||||
|
url: '/powersportvehicles?filetype=csv',
|
||||||
|
method: 'GET',
|
||||||
|
responseType: 'blob',
|
||||||
|
});
|
||||||
|
const type = response.headers['content-type'];
|
||||||
|
const blob = new Blob([response.data], { type: type });
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = window.URL.createObjectURL(blob);
|
||||||
|
link.download = 'powersportvehiclesCSV.csv';
|
||||||
|
link.click();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onModalConfirm = async () => {
|
||||||
|
if (!csvFile) return;
|
||||||
|
await dispatch(uploadCsv(csvFile));
|
||||||
|
dispatch(setRefetch(true));
|
||||||
|
setCsvFile(null);
|
||||||
|
setIsModalActive(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onModalCancel = () => {
|
||||||
|
setCsvFile(null);
|
||||||
|
setIsModalActive(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Head>
|
||||||
|
<title>{getPageTitle('Powersportvehicles')}</title>
|
||||||
|
</Head>
|
||||||
|
<SectionMain>
|
||||||
|
<SectionTitleLineWithButton
|
||||||
|
icon={mdiChartTimelineVariant}
|
||||||
|
title='Powersportvehicles'
|
||||||
|
main
|
||||||
|
>
|
||||||
|
{''}
|
||||||
|
</SectionTitleLineWithButton>
|
||||||
|
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
||||||
|
{hasCreatePermission && (
|
||||||
|
<BaseButton
|
||||||
|
className={'mr-3'}
|
||||||
|
href={'/powersportvehicles/powersportvehicles-new'}
|
||||||
|
color='info'
|
||||||
|
label='New Item'
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<BaseButton
|
||||||
|
className={'mr-3'}
|
||||||
|
color='info'
|
||||||
|
label='Filter'
|
||||||
|
onClick={addFilter}
|
||||||
|
/>
|
||||||
|
<BaseButton
|
||||||
|
className={'mr-3'}
|
||||||
|
color='info'
|
||||||
|
label='Download CSV'
|
||||||
|
onClick={getPowersportvehiclesCSV}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{hasCreatePermission && (
|
||||||
|
<BaseButton
|
||||||
|
color='info'
|
||||||
|
label='Upload CSV'
|
||||||
|
onClick={() => setIsModalActive(true)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className='md:inline-flex items-center ms-auto'>
|
||||||
|
<div id='delete-rows-button'></div>
|
||||||
|
</div>
|
||||||
|
</CardBox>
|
||||||
|
|
||||||
|
<CardBox className='mb-6' hasTable>
|
||||||
|
<TablePowersportvehicles
|
||||||
|
filterItems={filterItems}
|
||||||
|
setFilterItems={setFilterItems}
|
||||||
|
filters={filters}
|
||||||
|
showGrid={false}
|
||||||
|
/>
|
||||||
|
</CardBox>
|
||||||
|
</SectionMain>
|
||||||
|
<CardBoxModal
|
||||||
|
title='Upload CSV'
|
||||||
|
buttonColor='info'
|
||||||
|
buttonLabel={'Confirm'}
|
||||||
|
// buttonLabel={false ? 'Deleting...' : 'Confirm'}
|
||||||
|
isActive={isModalActive}
|
||||||
|
onConfirm={onModalConfirm}
|
||||||
|
onCancel={onModalCancel}
|
||||||
|
>
|
||||||
|
<DragDropFilePicker
|
||||||
|
file={csvFile}
|
||||||
|
setFile={setCsvFile}
|
||||||
|
formats={'.csv'}
|
||||||
|
/>
|
||||||
|
</CardBoxModal>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
PowersportvehiclesTablesPage.getLayout = function getLayout(
|
||||||
|
page: ReactElement,
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<LayoutAuthenticated permission={'READ_POWERSPORTVEHICLES'}>
|
||||||
|
{page}
|
||||||
|
</LayoutAuthenticated>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PowersportvehiclesTablesPage;
|
||||||
222
frontend/src/pages/powersportvehicles/powersportvehicles-new.tsx
Normal file
222
frontend/src/pages/powersportvehicles/powersportvehicles-new.tsx
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
import {
|
||||||
|
mdiAccount,
|
||||||
|
mdiChartTimelineVariant,
|
||||||
|
mdiMail,
|
||||||
|
mdiUpload,
|
||||||
|
} from '@mdi/js';
|
||||||
|
import Head from 'next/head';
|
||||||
|
import React, { ReactElement } from 'react';
|
||||||
|
import CardBox from '../../components/CardBox';
|
||||||
|
import LayoutAuthenticated from '../../layouts/Authenticated';
|
||||||
|
import SectionMain from '../../components/SectionMain';
|
||||||
|
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
|
||||||
|
import { getPageTitle } from '../../config';
|
||||||
|
|
||||||
|
import { Field, Form, Formik } from 'formik';
|
||||||
|
import FormField from '../../components/FormField';
|
||||||
|
import BaseDivider from '../../components/BaseDivider';
|
||||||
|
import BaseButtons from '../../components/BaseButtons';
|
||||||
|
import BaseButton from '../../components/BaseButton';
|
||||||
|
import FormCheckRadio from '../../components/FormCheckRadio';
|
||||||
|
import FormCheckRadioGroup from '../../components/FormCheckRadioGroup';
|
||||||
|
import FormFilePicker from '../../components/FormFilePicker';
|
||||||
|
import FormImagePicker from '../../components/FormImagePicker';
|
||||||
|
import { SwitchField } from '../../components/SwitchField';
|
||||||
|
|
||||||
|
import { SelectField } from '../../components/SelectField';
|
||||||
|
import { SelectFieldMany } from '../../components/SelectFieldMany';
|
||||||
|
import { RichTextField } from '../../components/RichTextField';
|
||||||
|
|
||||||
|
import { create } from '../../stores/powersportvehicles/powersportvehiclesSlice';
|
||||||
|
import { useAppDispatch } from '../../stores/hooks';
|
||||||
|
import { useRouter } from 'next/router';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
|
const initialValues = {
|
||||||
|
clients: '',
|
||||||
|
|
||||||
|
name: '',
|
||||||
|
|
||||||
|
description: '',
|
||||||
|
|
||||||
|
photos: [],
|
||||||
|
|
||||||
|
location: '',
|
||||||
|
|
||||||
|
pricehourly: '',
|
||||||
|
|
||||||
|
pricedaily: '',
|
||||||
|
|
||||||
|
securitydeposit: '',
|
||||||
|
|
||||||
|
availabilitystart: '',
|
||||||
|
|
||||||
|
availabilityend: '',
|
||||||
|
|
||||||
|
vehicletype: '',
|
||||||
|
|
||||||
|
preptimebefore: '',
|
||||||
|
|
||||||
|
preptimebetween: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
const PowersportvehiclesNew = () => {
|
||||||
|
const router = useRouter();
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
const handleSubmit = async (data) => {
|
||||||
|
await dispatch(create(data));
|
||||||
|
await router.push('/powersportvehicles/powersportvehicles-list');
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Head>
|
||||||
|
<title>{getPageTitle('New Item')}</title>
|
||||||
|
</Head>
|
||||||
|
<SectionMain>
|
||||||
|
<SectionTitleLineWithButton
|
||||||
|
icon={mdiChartTimelineVariant}
|
||||||
|
title='New Item'
|
||||||
|
main
|
||||||
|
>
|
||||||
|
{''}
|
||||||
|
</SectionTitleLineWithButton>
|
||||||
|
<CardBox>
|
||||||
|
<Formik
|
||||||
|
initialValues={initialValues}
|
||||||
|
onSubmit={(values) => handleSubmit(values)}
|
||||||
|
>
|
||||||
|
<Form>
|
||||||
|
<FormField label='clients' labelFor='clients'>
|
||||||
|
<Field
|
||||||
|
name='clients'
|
||||||
|
id='clients'
|
||||||
|
component={SelectField}
|
||||||
|
options={[]}
|
||||||
|
itemRef={'clients'}
|
||||||
|
></Field>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Name'>
|
||||||
|
<Field name='name' placeholder='Name' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Description'>
|
||||||
|
<Field name='description' placeholder='Description' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField>
|
||||||
|
<Field
|
||||||
|
label='Photos'
|
||||||
|
color='info'
|
||||||
|
icon={mdiUpload}
|
||||||
|
path={'powersportvehicles/photos'}
|
||||||
|
name='photos'
|
||||||
|
id='photos'
|
||||||
|
schema={{
|
||||||
|
size: undefined,
|
||||||
|
formats: undefined,
|
||||||
|
}}
|
||||||
|
component={FormImagePicker}
|
||||||
|
></Field>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Location'>
|
||||||
|
<Field name='location' placeholder='Location' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Pricehourly'>
|
||||||
|
<Field
|
||||||
|
type='number'
|
||||||
|
name='pricehourly'
|
||||||
|
placeholder='Pricehourly'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Pricedaily'>
|
||||||
|
<Field
|
||||||
|
type='number'
|
||||||
|
name='pricedaily'
|
||||||
|
placeholder='Pricedaily'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Securitydeposit'>
|
||||||
|
<Field
|
||||||
|
type='number'
|
||||||
|
name='securitydeposit'
|
||||||
|
placeholder='Securitydeposit'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Availabilitystart'>
|
||||||
|
<Field
|
||||||
|
type='datetime-local'
|
||||||
|
name='availabilitystart'
|
||||||
|
placeholder='Availabilitystart'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Availabilityend'>
|
||||||
|
<Field
|
||||||
|
type='datetime-local'
|
||||||
|
name='availabilityend'
|
||||||
|
placeholder='Availabilityend'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Vehicletype'>
|
||||||
|
<FormCheckRadioGroup>
|
||||||
|
<FormCheckRadio type='radio' label='value'>
|
||||||
|
<Field type='radio' name='vehicletype' value='value' />
|
||||||
|
</FormCheckRadio>
|
||||||
|
</FormCheckRadioGroup>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Preptimebefore'>
|
||||||
|
<Field
|
||||||
|
type='number'
|
||||||
|
name='preptimebefore'
|
||||||
|
placeholder='Preptimebefore'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Preptimebetween'>
|
||||||
|
<Field
|
||||||
|
type='number'
|
||||||
|
name='preptimebetween'
|
||||||
|
placeholder='Preptimebetween'
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<BaseDivider />
|
||||||
|
<BaseButtons>
|
||||||
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
<BaseButton type='reset' color='info' outline label='Reset' />
|
||||||
|
<BaseButton
|
||||||
|
type='reset'
|
||||||
|
color='danger'
|
||||||
|
outline
|
||||||
|
label='Cancel'
|
||||||
|
onClick={() =>
|
||||||
|
router.push('/powersportvehicles/powersportvehicles-list')
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</BaseButtons>
|
||||||
|
</Form>
|
||||||
|
</Formik>
|
||||||
|
</CardBox>
|
||||||
|
</SectionMain>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
PowersportvehiclesNew.getLayout = function getLayout(page: ReactElement) {
|
||||||
|
return (
|
||||||
|
<LayoutAuthenticated permission={'CREATE_POWERSPORTVEHICLES'}>
|
||||||
|
{page}
|
||||||
|
</LayoutAuthenticated>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PowersportvehiclesNew;
|
||||||
@ -0,0 +1,184 @@
|
|||||||
|
import { mdiChartTimelineVariant } from '@mdi/js';
|
||||||
|
import Head from 'next/head';
|
||||||
|
import { uniqueId } from 'lodash';
|
||||||
|
import React, { ReactElement, useState } from 'react';
|
||||||
|
import CardBox from '../../components/CardBox';
|
||||||
|
import LayoutAuthenticated from '../../layouts/Authenticated';
|
||||||
|
import SectionMain from '../../components/SectionMain';
|
||||||
|
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
|
||||||
|
import { getPageTitle } from '../../config';
|
||||||
|
import TablePowersportvehicles from '../../components/Powersportvehicles/TablePowersportvehicles';
|
||||||
|
import BaseButton from '../../components/BaseButton';
|
||||||
|
import axios from 'axios';
|
||||||
|
import Link from 'next/link';
|
||||||
|
import { useAppDispatch, useAppSelector } from '../../stores/hooks';
|
||||||
|
import CardBoxModal from '../../components/CardBoxModal';
|
||||||
|
import DragDropFilePicker from '../../components/DragDropFilePicker';
|
||||||
|
import {
|
||||||
|
setRefetch,
|
||||||
|
uploadCsv,
|
||||||
|
} from '../../stores/powersportvehicles/powersportvehiclesSlice';
|
||||||
|
|
||||||
|
import { hasPermission } from '../../helpers/userPermissions';
|
||||||
|
|
||||||
|
const PowersportvehiclesTablesPage = () => {
|
||||||
|
const [filterItems, setFilterItems] = useState([]);
|
||||||
|
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||||
|
const [isModalActive, setIsModalActive] = useState(false);
|
||||||
|
const [showTableView, setShowTableView] = useState(false);
|
||||||
|
|
||||||
|
const { currentUser } = useAppSelector((state) => state.auth);
|
||||||
|
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
const [filters] = useState([
|
||||||
|
{ label: 'Name', title: 'name' },
|
||||||
|
{ label: 'Description', title: 'description' },
|
||||||
|
{ label: 'Location', title: 'location' },
|
||||||
|
{ label: 'Preptimebefore', title: 'preptimebefore', number: 'true' },
|
||||||
|
{ label: 'Preptimebetween', title: 'preptimebetween', number: 'true' },
|
||||||
|
{ label: 'Pricehourly', title: 'pricehourly', number: 'true' },
|
||||||
|
{ label: 'Pricedaily', title: 'pricedaily', number: 'true' },
|
||||||
|
{ label: 'Securitydeposit', title: 'securitydeposit', number: 'true' },
|
||||||
|
{ label: 'Availabilitystart', title: 'availabilitystart', date: 'true' },
|
||||||
|
{ label: 'Availabilityend', title: 'availabilityend', date: 'true' },
|
||||||
|
|
||||||
|
{
|
||||||
|
label: 'Vehicletype',
|
||||||
|
title: 'vehicletype',
|
||||||
|
type: 'enum',
|
||||||
|
options: ['value'],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const hasCreatePermission =
|
||||||
|
currentUser && hasPermission(currentUser, 'CREATE_POWERSPORTVEHICLES');
|
||||||
|
|
||||||
|
const addFilter = () => {
|
||||||
|
const newItem = {
|
||||||
|
id: uniqueId(),
|
||||||
|
fields: {
|
||||||
|
filterValue: '',
|
||||||
|
filterValueFrom: '',
|
||||||
|
filterValueTo: '',
|
||||||
|
selectedField: '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
newItem.fields.selectedField = filters[0].title;
|
||||||
|
setFilterItems([...filterItems, newItem]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getPowersportvehiclesCSV = async () => {
|
||||||
|
const response = await axios({
|
||||||
|
url: '/powersportvehicles?filetype=csv',
|
||||||
|
method: 'GET',
|
||||||
|
responseType: 'blob',
|
||||||
|
});
|
||||||
|
const type = response.headers['content-type'];
|
||||||
|
const blob = new Blob([response.data], { type: type });
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = window.URL.createObjectURL(blob);
|
||||||
|
link.download = 'powersportvehiclesCSV.csv';
|
||||||
|
link.click();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onModalConfirm = async () => {
|
||||||
|
if (!csvFile) return;
|
||||||
|
await dispatch(uploadCsv(csvFile));
|
||||||
|
dispatch(setRefetch(true));
|
||||||
|
setCsvFile(null);
|
||||||
|
setIsModalActive(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onModalCancel = () => {
|
||||||
|
setCsvFile(null);
|
||||||
|
setIsModalActive(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Head>
|
||||||
|
<title>{getPageTitle('Powersportvehicles')}</title>
|
||||||
|
</Head>
|
||||||
|
<SectionMain>
|
||||||
|
<SectionTitleLineWithButton
|
||||||
|
icon={mdiChartTimelineVariant}
|
||||||
|
title='Powersportvehicles'
|
||||||
|
main
|
||||||
|
>
|
||||||
|
{''}
|
||||||
|
</SectionTitleLineWithButton>
|
||||||
|
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
||||||
|
{hasCreatePermission && (
|
||||||
|
<BaseButton
|
||||||
|
className={'mr-3'}
|
||||||
|
href={'/powersportvehicles/powersportvehicles-new'}
|
||||||
|
color='info'
|
||||||
|
label='New Item'
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<BaseButton
|
||||||
|
className={'mr-3'}
|
||||||
|
color='info'
|
||||||
|
label='Filter'
|
||||||
|
onClick={addFilter}
|
||||||
|
/>
|
||||||
|
<BaseButton
|
||||||
|
className={'mr-3'}
|
||||||
|
color='info'
|
||||||
|
label='Download CSV'
|
||||||
|
onClick={getPowersportvehiclesCSV}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{hasCreatePermission && (
|
||||||
|
<BaseButton
|
||||||
|
color='info'
|
||||||
|
label='Upload CSV'
|
||||||
|
onClick={() => setIsModalActive(true)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className='md:inline-flex items-center ms-auto'>
|
||||||
|
<div id='delete-rows-button'></div>
|
||||||
|
</div>
|
||||||
|
</CardBox>
|
||||||
|
<CardBox className='mb-6' hasTable>
|
||||||
|
<TablePowersportvehicles
|
||||||
|
filterItems={filterItems}
|
||||||
|
setFilterItems={setFilterItems}
|
||||||
|
filters={filters}
|
||||||
|
showGrid={true}
|
||||||
|
/>
|
||||||
|
</CardBox>
|
||||||
|
</SectionMain>
|
||||||
|
<CardBoxModal
|
||||||
|
title='Upload CSV'
|
||||||
|
buttonColor='info'
|
||||||
|
buttonLabel={'Confirm'}
|
||||||
|
// buttonLabel={false ? 'Deleting...' : 'Confirm'}
|
||||||
|
isActive={isModalActive}
|
||||||
|
onConfirm={onModalConfirm}
|
||||||
|
onCancel={onModalCancel}
|
||||||
|
>
|
||||||
|
<DragDropFilePicker
|
||||||
|
file={csvFile}
|
||||||
|
setFile={setCsvFile}
|
||||||
|
formats={'.csv'}
|
||||||
|
/>
|
||||||
|
</CardBoxModal>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
PowersportvehiclesTablesPage.getLayout = function getLayout(
|
||||||
|
page: ReactElement,
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<LayoutAuthenticated permission={'READ_POWERSPORTVEHICLES'}>
|
||||||
|
{page}
|
||||||
|
</LayoutAuthenticated>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PowersportvehiclesTablesPage;
|
||||||
@ -0,0 +1,249 @@
|
|||||||
|
import React, { ReactElement, useEffect } from 'react';
|
||||||
|
import Head from 'next/head';
|
||||||
|
import DatePicker from 'react-datepicker';
|
||||||
|
import 'react-datepicker/dist/react-datepicker.css';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
import { useAppDispatch, useAppSelector } from '../../stores/hooks';
|
||||||
|
import { useRouter } from 'next/router';
|
||||||
|
import { fetch } from '../../stores/powersportvehicles/powersportvehiclesSlice';
|
||||||
|
import { saveFile } from '../../helpers/fileSaver';
|
||||||
|
import dataFormatter from '../../helpers/dataFormatter';
|
||||||
|
import ImageField from '../../components/ImageField';
|
||||||
|
import LayoutAuthenticated from '../../layouts/Authenticated';
|
||||||
|
import { getPageTitle } from '../../config';
|
||||||
|
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
|
||||||
|
import SectionMain from '../../components/SectionMain';
|
||||||
|
import CardBox from '../../components/CardBox';
|
||||||
|
import BaseButton from '../../components/BaseButton';
|
||||||
|
import BaseDivider from '../../components/BaseDivider';
|
||||||
|
import { mdiChartTimelineVariant } from '@mdi/js';
|
||||||
|
import { SwitchField } from '../../components/SwitchField';
|
||||||
|
import FormField from '../../components/FormField';
|
||||||
|
|
||||||
|
import { hasPermission } from '../../helpers/userPermissions';
|
||||||
|
|
||||||
|
const PowersportvehiclesView = () => {
|
||||||
|
const router = useRouter();
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
const { powersportvehicles } = useAppSelector(
|
||||||
|
(state) => state.powersportvehicles,
|
||||||
|
);
|
||||||
|
|
||||||
|
const { currentUser } = useAppSelector((state) => state.auth);
|
||||||
|
|
||||||
|
const { id } = router.query;
|
||||||
|
|
||||||
|
function removeLastCharacter(str) {
|
||||||
|
console.log(str, `str`);
|
||||||
|
return str.slice(0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
dispatch(fetch({ id }));
|
||||||
|
}, [dispatch, id]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Head>
|
||||||
|
<title>{getPageTitle('View powersportvehicles')}</title>
|
||||||
|
</Head>
|
||||||
|
<SectionMain>
|
||||||
|
<SectionTitleLineWithButton
|
||||||
|
icon={mdiChartTimelineVariant}
|
||||||
|
title={removeLastCharacter('View powersportvehicles')}
|
||||||
|
main
|
||||||
|
>
|
||||||
|
<BaseButton
|
||||||
|
color='info'
|
||||||
|
label='Edit'
|
||||||
|
href={`/powersportvehicles/powersportvehicles-edit/?id=${id}`}
|
||||||
|
/>
|
||||||
|
</SectionTitleLineWithButton>
|
||||||
|
<CardBox>
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>clients</p>
|
||||||
|
|
||||||
|
<p>{powersportvehicles?.clients?.name ?? 'No data'}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Name</p>
|
||||||
|
<p>{powersportvehicles?.name}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Description</p>
|
||||||
|
<p>{powersportvehicles?.description}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Photos</p>
|
||||||
|
{powersportvehicles?.photos?.length ? (
|
||||||
|
<ImageField
|
||||||
|
name={'photos'}
|
||||||
|
image={powersportvehicles?.photos}
|
||||||
|
className='w-20 h-20'
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<p>No Photos</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Location</p>
|
||||||
|
<p>{powersportvehicles?.location}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Pricehourly</p>
|
||||||
|
<p>{powersportvehicles?.pricehourly || 'No data'}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Pricedaily</p>
|
||||||
|
<p>{powersportvehicles?.pricedaily || 'No data'}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Securitydeposit</p>
|
||||||
|
<p>{powersportvehicles?.securitydeposit || 'No data'}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<FormField label='Availabilitystart'>
|
||||||
|
{powersportvehicles.availabilitystart ? (
|
||||||
|
<DatePicker
|
||||||
|
dateFormat='yyyy-MM-dd hh:mm'
|
||||||
|
showTimeSelect
|
||||||
|
selected={
|
||||||
|
powersportvehicles.availabilitystart
|
||||||
|
? new Date(
|
||||||
|
dayjs(powersportvehicles.availabilitystart).format(
|
||||||
|
'YYYY-MM-DD hh:mm',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
disabled
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<p>No Availabilitystart</p>
|
||||||
|
)}
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Availabilityend'>
|
||||||
|
{powersportvehicles.availabilityend ? (
|
||||||
|
<DatePicker
|
||||||
|
dateFormat='yyyy-MM-dd hh:mm'
|
||||||
|
showTimeSelect
|
||||||
|
selected={
|
||||||
|
powersportvehicles.availabilityend
|
||||||
|
? new Date(
|
||||||
|
dayjs(powersportvehicles.availabilityend).format(
|
||||||
|
'YYYY-MM-DD hh:mm',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
disabled
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<p>No Availabilityend</p>
|
||||||
|
)}
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Vehicletype</p>
|
||||||
|
<p>{powersportvehicles?.vehicletype ?? 'No data'}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Preptimebefore</p>
|
||||||
|
<p>{powersportvehicles?.preptimebefore || 'No data'}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Preptimebetween</p>
|
||||||
|
<p>{powersportvehicles?.preptimebetween || 'No data'}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<>
|
||||||
|
<p className={'block font-bold mb-2'}>Bookings Powersportvehicle</p>
|
||||||
|
<CardBox
|
||||||
|
className='mb-6 border border-gray-300 rounded overflow-hidden'
|
||||||
|
hasTable
|
||||||
|
>
|
||||||
|
<div className='overflow-x-auto'>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>StartDate</th>
|
||||||
|
|
||||||
|
<th>EndDate</th>
|
||||||
|
|
||||||
|
<th>Status</th>
|
||||||
|
|
||||||
|
<th>TotalPrice</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{powersportvehicles.bookings_powersportvehicle &&
|
||||||
|
Array.isArray(
|
||||||
|
powersportvehicles.bookings_powersportvehicle,
|
||||||
|
) &&
|
||||||
|
powersportvehicles.bookings_powersportvehicle.map(
|
||||||
|
(item: any) => (
|
||||||
|
<tr
|
||||||
|
key={item.id}
|
||||||
|
onClick={() =>
|
||||||
|
router.push(
|
||||||
|
`/bookings/bookings-view/?id=${item.id}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<td data-label='start_date'>
|
||||||
|
{dataFormatter.dateTimeFormatter(item.start_date)}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td data-label='end_date'>
|
||||||
|
{dataFormatter.dateTimeFormatter(item.end_date)}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td data-label='status'>{item.status}</td>
|
||||||
|
|
||||||
|
<td data-label='total_price'>{item.total_price}</td>
|
||||||
|
</tr>
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{!powersportvehicles?.bookings_powersportvehicle?.length && (
|
||||||
|
<div className={'text-center py-4'}>No data</div>
|
||||||
|
)}
|
||||||
|
</CardBox>
|
||||||
|
</>
|
||||||
|
|
||||||
|
<BaseDivider />
|
||||||
|
|
||||||
|
<BaseButton
|
||||||
|
color='info'
|
||||||
|
label='Back'
|
||||||
|
onClick={() =>
|
||||||
|
router.push('/powersportvehicles/powersportvehicles-list')
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</CardBox>
|
||||||
|
</SectionMain>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
PowersportvehiclesView.getLayout = function getLayout(page: ReactElement) {
|
||||||
|
return (
|
||||||
|
<LayoutAuthenticated permission={'READ_POWERSPORTVEHICLES'}>
|
||||||
|
{page}
|
||||||
|
</LayoutAuthenticated>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PowersportvehiclesView;
|
||||||
@ -5,7 +5,7 @@ import LayoutGuest from '../layouts/Guest';
|
|||||||
import { getPageTitle } from '../config';
|
import { getPageTitle } from '../config';
|
||||||
|
|
||||||
export default function PrivacyPolicy() {
|
export default function PrivacyPolicy() {
|
||||||
const title = 'Etherra';
|
const title = 'Powersport Rentals';
|
||||||
const [projectUrl, setProjectUrl] = useState('');
|
const [projectUrl, setProjectUrl] = useState('');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import LayoutGuest from '../layouts/Guest';
|
|||||||
import { getPageTitle } from '../config';
|
import { getPageTitle } from '../config';
|
||||||
|
|
||||||
export default function PrivacyPolicy() {
|
export default function PrivacyPolicy() {
|
||||||
const title = 'Etherra';
|
const title = 'Powersport Rentals';
|
||||||
const [projectUrl, setProjectUrl] = useState('');
|
const [projectUrl, setProjectUrl] = useState('');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@ -220,6 +220,8 @@ const UsersView = () => {
|
|||||||
<th>PriceDaily</th>
|
<th>PriceDaily</th>
|
||||||
|
|
||||||
<th>SecurityDeposit</th>
|
<th>SecurityDeposit</th>
|
||||||
|
|
||||||
|
<th>Vehicletype</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -245,6 +247,8 @@ const UsersView = () => {
|
|||||||
<td data-label='security_deposit'>
|
<td data-label='security_deposit'>
|
||||||
{item.security_deposit}
|
{item.security_deposit}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
<td data-label='vehicletype'>{item.vehicletype}</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@ -57,6 +57,8 @@ const EditVehicles = () => {
|
|||||||
bookings: [],
|
bookings: [],
|
||||||
|
|
||||||
clients: null,
|
clients: null,
|
||||||
|
|
||||||
|
vehicletype: '',
|
||||||
};
|
};
|
||||||
const [initialValues, setInitialValues] = useState(initVals);
|
const [initialValues, setInitialValues] = useState(initVals);
|
||||||
|
|
||||||
@ -200,6 +202,14 @@ const EditVehicles = () => {
|
|||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Vehicletype'>
|
||||||
|
<FormCheckRadioGroup>
|
||||||
|
<FormCheckRadio type='radio' label='value'>
|
||||||
|
<Field type='radio' name='vehicletype' value='value' />
|
||||||
|
</FormCheckRadio>
|
||||||
|
</FormCheckRadioGroup>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -57,6 +57,8 @@ const EditVehiclesPage = () => {
|
|||||||
bookings: [],
|
bookings: [],
|
||||||
|
|
||||||
clients: null,
|
clients: null,
|
||||||
|
|
||||||
|
vehicletype: '',
|
||||||
};
|
};
|
||||||
const [initialValues, setInitialValues] = useState(initVals);
|
const [initialValues, setInitialValues] = useState(initVals);
|
||||||
|
|
||||||
@ -198,6 +200,14 @@ const EditVehiclesPage = () => {
|
|||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Vehicletype'>
|
||||||
|
<FormCheckRadioGroup>
|
||||||
|
<FormCheckRadio type='radio' label='value'>
|
||||||
|
<Field type='radio' name='vehicletype' value='value' />
|
||||||
|
</FormCheckRadio>
|
||||||
|
</FormCheckRadioGroup>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -40,6 +40,12 @@ const VehiclesTablesPage = () => {
|
|||||||
{ label: 'Owner', title: 'owner' },
|
{ label: 'Owner', title: 'owner' },
|
||||||
|
|
||||||
{ label: 'Bookings', title: 'bookings' },
|
{ label: 'Bookings', title: 'bookings' },
|
||||||
|
{
|
||||||
|
label: 'Vehicletype',
|
||||||
|
title: 'vehicletype',
|
||||||
|
type: 'enum',
|
||||||
|
options: ['value'],
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const hasCreatePermission =
|
const hasCreatePermission =
|
||||||
|
|||||||
@ -52,6 +52,8 @@ const initialValues = {
|
|||||||
bookings: [],
|
bookings: [],
|
||||||
|
|
||||||
clients: '',
|
clients: '',
|
||||||
|
|
||||||
|
vehicletype: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
const VehiclesNew = () => {
|
const VehiclesNew = () => {
|
||||||
@ -167,6 +169,14 @@ const VehiclesNew = () => {
|
|||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Vehicletype'>
|
||||||
|
<FormCheckRadioGroup>
|
||||||
|
<FormCheckRadio type='radio' label='value'>
|
||||||
|
<Field type='radio' name='vehicletype' value='value' />
|
||||||
|
</FormCheckRadio>
|
||||||
|
</FormCheckRadioGroup>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -40,6 +40,12 @@ const VehiclesTablesPage = () => {
|
|||||||
{ label: 'Owner', title: 'owner' },
|
{ label: 'Owner', title: 'owner' },
|
||||||
|
|
||||||
{ label: 'Bookings', title: 'bookings' },
|
{ label: 'Bookings', title: 'bookings' },
|
||||||
|
{
|
||||||
|
label: 'Vehicletype',
|
||||||
|
title: 'vehicletype',
|
||||||
|
type: 'enum',
|
||||||
|
options: ['value'],
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const hasCreatePermission =
|
const hasCreatePermission =
|
||||||
|
|||||||
@ -170,6 +170,11 @@ const VehiclesView = () => {
|
|||||||
<p>{vehicles?.clients?.name ?? 'No data'}</p>
|
<p>{vehicles?.clients?.name ?? 'No data'}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Vehicletype</p>
|
||||||
|
<p>{vehicles?.vehicletype ?? 'No data'}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<>
|
<>
|
||||||
<p className={'block font-bold mb-2'}>Bookings Vehicle</p>
|
<p className={'block font-bold mb-2'}>Bookings Vehicle</p>
|
||||||
<CardBox
|
<CardBox
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import FaqSection from '../../components/WebPageComponents/FaqComponent';
|
|||||||
export default function WebSite() {
|
export default function WebSite() {
|
||||||
const cardsStyle = useAppSelector((state) => state.style.cardsStyle);
|
const cardsStyle = useAppSelector((state) => state.style.cardsStyle);
|
||||||
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
||||||
const projectName = 'Etherra';
|
const projectName = 'Powersport Rentals';
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const darkElement = document.querySelector('body .dark');
|
const darkElement = document.querySelector('body .dark');
|
||||||
@ -77,10 +77,10 @@ export default function WebSite() {
|
|||||||
content={`Get in touch with our team for any inquiries or support related to our peer-to-peer RV rental platform. We're here to help you with your adventure needs.`}
|
content={`Get in touch with our team for any inquiries or support related to our peer-to-peer RV rental platform. We're here to help you with your adventure needs.`}
|
||||||
/>
|
/>
|
||||||
</Head>
|
</Head>
|
||||||
<WebSiteHeader projectName={'Etherra'} />
|
<WebSiteHeader projectName={'Powersport Rentals'} />
|
||||||
<main className={`flex-grow ${bgColor} rounded-none `}>
|
<main className={`flex-grow ${bgColor} rounded-none `}>
|
||||||
<HeroSection
|
<HeroSection
|
||||||
projectName={'Etherra'}
|
projectName={'Powersport Rentals'}
|
||||||
image={['Customer support team assisting clients']}
|
image={['Customer support team assisting clients']}
|
||||||
mainText={`Connect with ${projectName} Today`}
|
mainText={`Connect with ${projectName} Today`}
|
||||||
subTitle={`We're here to assist you with any questions or support you need. Reach out to us and let us help make your RV rental experience seamless and enjoyable.`}
|
subTitle={`We're here to assist you with any questions or support you need. Reach out to us and let us help make your RV rental experience seamless and enjoyable.`}
|
||||||
@ -89,21 +89,21 @@ export default function WebSite() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<FaqSection
|
<FaqSection
|
||||||
projectName={'Etherra'}
|
projectName={'Powersport Rentals'}
|
||||||
design={FaqDesigns.ACCORDION || ''}
|
design={FaqDesigns.ACCORDION || ''}
|
||||||
faqs={faqs}
|
faqs={faqs}
|
||||||
mainText={`Frequently Asked Questions about ${projectName} `}
|
mainText={`Frequently Asked Questions about ${projectName} `}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ContactFormSection
|
<ContactFormSection
|
||||||
projectName={'Etherra'}
|
projectName={'Powersport Rentals'}
|
||||||
design={ContactFormDesigns.HIGHLIGHTED || ''}
|
design={ContactFormDesigns.HIGHLIGHTED || ''}
|
||||||
image={['Email communication illustration']}
|
image={['Email communication illustration']}
|
||||||
mainText={`Reach Out to ${projectName} `}
|
mainText={`Reach Out to ${projectName} `}
|
||||||
subTitle={`We're available 24/7 to assist you. Send us a message, and our team will respond promptly to ensure your needs are met.`}
|
subTitle={`We're available 24/7 to assist you. Send us a message, and our team will respond promptly to ensure your needs are met.`}
|
||||||
/>
|
/>
|
||||||
</main>
|
</main>
|
||||||
<WebSiteFooter projectName={'Etherra'} />
|
<WebSiteFooter projectName={'Powersport Rentals'} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import FaqSection from '../../components/WebPageComponents/FaqComponent';
|
|||||||
export default function WebSite() {
|
export default function WebSite() {
|
||||||
const cardsStyle = useAppSelector((state) => state.style.cardsStyle);
|
const cardsStyle = useAppSelector((state) => state.style.cardsStyle);
|
||||||
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
||||||
const projectName = 'Etherra';
|
const projectName = 'Powersport Rentals';
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const darkElement = document.querySelector('body .dark');
|
const darkElement = document.querySelector('body .dark');
|
||||||
@ -69,10 +69,10 @@ export default function WebSite() {
|
|||||||
content={`Find answers to common questions about our peer-to-peer RV rental platform. Learn about listing, booking, security, and more to enhance your rental experience.`}
|
content={`Find answers to common questions about our peer-to-peer RV rental platform. Learn about listing, booking, security, and more to enhance your rental experience.`}
|
||||||
/>
|
/>
|
||||||
</Head>
|
</Head>
|
||||||
<WebSiteHeader projectName={'Etherra'} />
|
<WebSiteHeader projectName={'Powersport Rentals'} />
|
||||||
<main className={`flex-grow ${bgColor} rounded-none `}>
|
<main className={`flex-grow ${bgColor} rounded-none `}>
|
||||||
<HeroSection
|
<HeroSection
|
||||||
projectName={'Etherra'}
|
projectName={'Powersport Rentals'}
|
||||||
image={['FAQ section with question marks']}
|
image={['FAQ section with question marks']}
|
||||||
mainText={`Your Questions Answered with ${projectName}`}
|
mainText={`Your Questions Answered with ${projectName}`}
|
||||||
subTitle={`Explore our comprehensive FAQ section to find answers to your questions about our peer-to-peer RV rental platform. From listing to booking, we've got you covered.`}
|
subTitle={`Explore our comprehensive FAQ section to find answers to your questions about our peer-to-peer RV rental platform. From listing to booking, we've got you covered.`}
|
||||||
@ -81,13 +81,13 @@ export default function WebSite() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<FaqSection
|
<FaqSection
|
||||||
projectName={'Etherra'}
|
projectName={'Powersport Rentals'}
|
||||||
design={FaqDesigns.TWO_COLUMN || ''}
|
design={FaqDesigns.TWO_COLUMN || ''}
|
||||||
faqs={faqs}
|
faqs={faqs}
|
||||||
mainText={`Common Questions About ${projectName} `}
|
mainText={`Common Questions About ${projectName} `}
|
||||||
/>
|
/>
|
||||||
</main>
|
</main>
|
||||||
<WebSiteFooter projectName={'Etherra'} />
|
<WebSiteFooter projectName={'Powersport Rentals'} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import ContactFormSection from '../../components/WebPageComponents/ContactFormCo
|
|||||||
export default function WebSite() {
|
export default function WebSite() {
|
||||||
const cardsStyle = useAppSelector((state) => state.style.cardsStyle);
|
const cardsStyle = useAppSelector((state) => state.style.cardsStyle);
|
||||||
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
||||||
const projectName = 'Etherra';
|
const projectName = 'Powersport Rentals';
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const darkElement = document.querySelector('body .dark');
|
const darkElement = document.querySelector('body .dark');
|
||||||
@ -96,10 +96,10 @@ export default function WebSite() {
|
|||||||
content={`Discover and rent recreational vehicles with ease on our peer-to-peer RV rental platform. List your RV or find the perfect one for your next adventure.`}
|
content={`Discover and rent recreational vehicles with ease on our peer-to-peer RV rental platform. List your RV or find the perfect one for your next adventure.`}
|
||||||
/>
|
/>
|
||||||
</Head>
|
</Head>
|
||||||
<WebSiteHeader projectName={'Etherra'} />
|
<WebSiteHeader projectName={'Powersport Rentals'} />
|
||||||
<main className={`flex-grow ${bgColor} rounded-none `}>
|
<main className={`flex-grow ${bgColor} rounded-none `}>
|
||||||
<HeroSection
|
<HeroSection
|
||||||
projectName={'Etherra'}
|
projectName={'Powersport Rentals'}
|
||||||
image={['RV on a scenic highway']}
|
image={['RV on a scenic highway']}
|
||||||
mainText={`Explore the Open Road with ${projectName}`}
|
mainText={`Explore the Open Road with ${projectName}`}
|
||||||
subTitle={`Discover the freedom of the open road with our peer-to-peer RV rental platform. Whether you're listing your RV or searching for the perfect getaway vehicle, ${projectName} makes it easy and secure.`}
|
subTitle={`Discover the freedom of the open road with our peer-to-peer RV rental platform. Whether you're listing your RV or searching for the perfect getaway vehicle, ${projectName} makes it easy and secure.`}
|
||||||
@ -108,9 +108,9 @@ export default function WebSite() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<FeaturesSection
|
<FeaturesSection
|
||||||
projectName={'Etherra'}
|
projectName={'Powersport Rentals'}
|
||||||
image={['RV keys and map']}
|
image={['RV keys and map']}
|
||||||
withBg={1}
|
withBg={0}
|
||||||
features={features_points}
|
features={features_points}
|
||||||
mainText={`Discover Key Features of ${projectName}`}
|
mainText={`Discover Key Features of ${projectName}`}
|
||||||
subTitle={`Explore the unique features of ${projectName} that make RV renting seamless and enjoyable for both renters and rentees.`}
|
subTitle={`Explore the unique features of ${projectName} that make RV renting seamless and enjoyable for both renters and rentees.`}
|
||||||
@ -118,21 +118,21 @@ export default function WebSite() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<TestimonialsSection
|
<TestimonialsSection
|
||||||
projectName={'Etherra'}
|
projectName={'Powersport Rentals'}
|
||||||
design={TestimonialsDesigns.MULTI_CARD_DISPLAY || ''}
|
design={TestimonialsDesigns.MULTI_CARD_DISPLAY || ''}
|
||||||
testimonials={testimonials}
|
testimonials={testimonials}
|
||||||
mainText={`What Our Users Say About ${projectName} `}
|
mainText={`What Our Users Say About ${projectName} `}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ContactFormSection
|
<ContactFormSection
|
||||||
projectName={'Etherra'}
|
projectName={'Powersport Rentals'}
|
||||||
design={ContactFormDesigns.WITH_IMAGE || ''}
|
design={ContactFormDesigns.WITH_IMAGE || ''}
|
||||||
image={['Contact form on a tablet']}
|
image={['Contact form on a tablet']}
|
||||||
mainText={`Get in Touch with ${projectName} `}
|
mainText={`Get in Touch with ${projectName} `}
|
||||||
subTitle={`Have questions or need assistance? Reach out to us anytime, and our team will respond promptly to ensure your experience with ${projectName} is seamless.`}
|
subTitle={`Have questions or need assistance? Reach out to us anytime, and our team will respond promptly to ensure your experience with ${projectName} is seamless.`}
|
||||||
/>
|
/>
|
||||||
</main>
|
</main>
|
||||||
<WebSiteFooter projectName={'Etherra'} />
|
<WebSiteFooter projectName={'Powersport Rentals'} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,250 @@
|
|||||||
|
import { createSlice, createAsyncThunk, PayloadAction } from '@reduxjs/toolkit';
|
||||||
|
import axios from 'axios';
|
||||||
|
import {
|
||||||
|
fulfilledNotify,
|
||||||
|
rejectNotify,
|
||||||
|
resetNotify,
|
||||||
|
} from '../../helpers/notifyStateHandler';
|
||||||
|
|
||||||
|
interface MainState {
|
||||||
|
powersportvehicles: any;
|
||||||
|
loading: boolean;
|
||||||
|
count: number;
|
||||||
|
refetch: boolean;
|
||||||
|
rolesWidgets: any[];
|
||||||
|
notify: {
|
||||||
|
showNotification: boolean;
|
||||||
|
textNotification: string;
|
||||||
|
typeNotification: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const initialState: MainState = {
|
||||||
|
powersportvehicles: [],
|
||||||
|
loading: false,
|
||||||
|
count: 0,
|
||||||
|
refetch: false,
|
||||||
|
rolesWidgets: [],
|
||||||
|
notify: {
|
||||||
|
showNotification: false,
|
||||||
|
textNotification: '',
|
||||||
|
typeNotification: 'warn',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const fetch = createAsyncThunk(
|
||||||
|
'powersportvehicles/fetch',
|
||||||
|
async (data: any) => {
|
||||||
|
const { id, query } = data;
|
||||||
|
const result = await axios.get(
|
||||||
|
`powersportvehicles${query || (id ? `/${id}` : '')}`,
|
||||||
|
);
|
||||||
|
return id
|
||||||
|
? result.data
|
||||||
|
: { rows: result.data.rows, count: result.data.count };
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
export const deleteItemsByIds = createAsyncThunk(
|
||||||
|
'powersportvehicles/deleteByIds',
|
||||||
|
async (data: any, { rejectWithValue }) => {
|
||||||
|
try {
|
||||||
|
await axios.post('powersportvehicles/deleteByIds', { data });
|
||||||
|
} catch (error) {
|
||||||
|
if (!error.response) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rejectWithValue(error.response.data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
export const deleteItem = createAsyncThunk(
|
||||||
|
'powersportvehicles/deletePowersportvehicles',
|
||||||
|
async (id: string, { rejectWithValue }) => {
|
||||||
|
try {
|
||||||
|
await axios.delete(`powersportvehicles/${id}`);
|
||||||
|
} catch (error) {
|
||||||
|
if (!error.response) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rejectWithValue(error.response.data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
export const create = createAsyncThunk(
|
||||||
|
'powersportvehicles/createPowersportvehicles',
|
||||||
|
async (data: any, { rejectWithValue }) => {
|
||||||
|
try {
|
||||||
|
const result = await axios.post('powersportvehicles', { data });
|
||||||
|
return result.data;
|
||||||
|
} catch (error) {
|
||||||
|
if (!error.response) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rejectWithValue(error.response.data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
export const uploadCsv = createAsyncThunk(
|
||||||
|
'powersportvehicles/uploadCsv',
|
||||||
|
async (file: File, { rejectWithValue }) => {
|
||||||
|
try {
|
||||||
|
const data = new FormData();
|
||||||
|
data.append('file', file);
|
||||||
|
data.append('filename', file.name);
|
||||||
|
|
||||||
|
const result = await axios.post('powersportvehicles/bulk-import', data, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return result.data;
|
||||||
|
} catch (error) {
|
||||||
|
if (!error.response) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rejectWithValue(error.response.data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
export const update = createAsyncThunk(
|
||||||
|
'powersportvehicles/updatePowersportvehicles',
|
||||||
|
async (payload: any, { rejectWithValue }) => {
|
||||||
|
try {
|
||||||
|
const result = await axios.put(`powersportvehicles/${payload.id}`, {
|
||||||
|
id: payload.id,
|
||||||
|
data: payload.data,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
} catch (error) {
|
||||||
|
if (!error.response) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rejectWithValue(error.response.data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
export const powersportvehiclesSlice = createSlice({
|
||||||
|
name: 'powersportvehicles',
|
||||||
|
initialState,
|
||||||
|
reducers: {
|
||||||
|
setRefetch: (state, action: PayloadAction<boolean>) => {
|
||||||
|
state.refetch = action.payload;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
extraReducers: (builder) => {
|
||||||
|
builder.addCase(fetch.pending, (state) => {
|
||||||
|
state.loading = true;
|
||||||
|
resetNotify(state);
|
||||||
|
});
|
||||||
|
builder.addCase(fetch.rejected, (state, action) => {
|
||||||
|
state.loading = false;
|
||||||
|
rejectNotify(state, action);
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.addCase(fetch.fulfilled, (state, action) => {
|
||||||
|
if (action.payload.rows && action.payload.count >= 0) {
|
||||||
|
state.powersportvehicles = action.payload.rows;
|
||||||
|
state.count = action.payload.count;
|
||||||
|
} else {
|
||||||
|
state.powersportvehicles = action.payload;
|
||||||
|
}
|
||||||
|
state.loading = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.addCase(deleteItemsByIds.pending, (state) => {
|
||||||
|
state.loading = true;
|
||||||
|
resetNotify(state);
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.addCase(deleteItemsByIds.fulfilled, (state) => {
|
||||||
|
state.loading = false;
|
||||||
|
fulfilledNotify(state, 'Powersportvehicles has been deleted');
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.addCase(deleteItemsByIds.rejected, (state, action) => {
|
||||||
|
state.loading = false;
|
||||||
|
rejectNotify(state, action);
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.addCase(deleteItem.pending, (state) => {
|
||||||
|
state.loading = true;
|
||||||
|
resetNotify(state);
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.addCase(deleteItem.fulfilled, (state) => {
|
||||||
|
state.loading = false;
|
||||||
|
fulfilledNotify(
|
||||||
|
state,
|
||||||
|
`${'Powersportvehicles'.slice(0, -1)} has been deleted`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.addCase(deleteItem.rejected, (state, action) => {
|
||||||
|
state.loading = false;
|
||||||
|
rejectNotify(state, action);
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.addCase(create.pending, (state) => {
|
||||||
|
state.loading = true;
|
||||||
|
resetNotify(state);
|
||||||
|
});
|
||||||
|
builder.addCase(create.rejected, (state, action) => {
|
||||||
|
state.loading = false;
|
||||||
|
rejectNotify(state, action);
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.addCase(create.fulfilled, (state) => {
|
||||||
|
state.loading = false;
|
||||||
|
fulfilledNotify(
|
||||||
|
state,
|
||||||
|
`${'Powersportvehicles'.slice(0, -1)} has been created`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.addCase(update.pending, (state) => {
|
||||||
|
state.loading = true;
|
||||||
|
resetNotify(state);
|
||||||
|
});
|
||||||
|
builder.addCase(update.fulfilled, (state) => {
|
||||||
|
state.loading = false;
|
||||||
|
fulfilledNotify(
|
||||||
|
state,
|
||||||
|
`${'Powersportvehicles'.slice(0, -1)} has been updated`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
builder.addCase(update.rejected, (state, action) => {
|
||||||
|
state.loading = false;
|
||||||
|
rejectNotify(state, action);
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.addCase(uploadCsv.pending, (state) => {
|
||||||
|
state.loading = true;
|
||||||
|
resetNotify(state);
|
||||||
|
});
|
||||||
|
builder.addCase(uploadCsv.fulfilled, (state) => {
|
||||||
|
state.loading = false;
|
||||||
|
fulfilledNotify(state, 'Powersportvehicles has been uploaded');
|
||||||
|
});
|
||||||
|
builder.addCase(uploadCsv.rejected, (state, action) => {
|
||||||
|
state.loading = false;
|
||||||
|
rejectNotify(state, action);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Action creators are generated for each case reducer function
|
||||||
|
export const { setRefetch } = powersportvehiclesSlice.actions;
|
||||||
|
|
||||||
|
export default powersportvehiclesSlice.reducer;
|
||||||
@ -10,6 +10,7 @@ import vehiclesSlice from './vehicles/vehiclesSlice';
|
|||||||
import rolesSlice from './roles/rolesSlice';
|
import rolesSlice from './roles/rolesSlice';
|
||||||
import permissionsSlice from './permissions/permissionsSlice';
|
import permissionsSlice from './permissions/permissionsSlice';
|
||||||
import clientsSlice from './clients/clientsSlice';
|
import clientsSlice from './clients/clientsSlice';
|
||||||
|
import powersportvehiclesSlice from './powersportvehicles/powersportvehiclesSlice';
|
||||||
|
|
||||||
export const store = configureStore({
|
export const store = configureStore({
|
||||||
reducer: {
|
reducer: {
|
||||||
@ -24,6 +25,7 @@ export const store = configureStore({
|
|||||||
roles: rolesSlice,
|
roles: rolesSlice,
|
||||||
permissions: permissionsSlice,
|
permissions: permissionsSlice,
|
||||||
clients: clientsSlice,
|
clients: clientsSlice,
|
||||||
|
powersportvehicles: powersportvehiclesSlice,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user