v1
This commit is contained in:
parent
64d7379d57
commit
d4a5e6b45c
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,3 +1,6 @@
|
||||
/backend/node_modules
|
||||
/frontend/node_modules
|
||||
node_modules/
|
||||
*/node_modules/
|
||||
*/build/
|
||||
**/node_modules/
|
||||
*/build/
|
||||
4
502.html
4
502.html
@ -129,8 +129,8 @@
|
||||
<p class="tip">The application is currently launching. The page will automatically refresh once site is
|
||||
available.</p>
|
||||
<div class="project-info">
|
||||
<h2>Instructor-Student LMS</h2>
|
||||
<p>Instructor-student LMS for courses, lessons, enrollments, and progress tracking.</p>
|
||||
<h2>Sales Pipeline CRM</h2>
|
||||
<p>Sales Pipeline CRM for managing leads, deals, contacts, activities and automated follow-ups.</p>
|
||||
</div>
|
||||
<div class="loader-container">
|
||||
<img src="https://flatlogic.com/blog/wp-content/uploads/2025/05/logo-bot-1.png" alt="App Logo"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
# Instructor-Student LMS
|
||||
# Sales Pipeline CRM
|
||||
|
||||
|
||||
## This project was generated by [Flatlogic Platform](https://flatlogic.com).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
DB_NAME=app_37612
|
||||
DB_USER=app_37612
|
||||
DB_PASS=e52941c5-df65-471d-838b-20ceb5eda155
|
||||
DB_NAME=app_37742
|
||||
DB_USER=app_37742
|
||||
DB_PASS=72a5084e-302a-4f10-bdae-c6ada26bc4fa
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=5432
|
||||
PORT=3000
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
#Instructor-Student LMS - template backend,
|
||||
#Sales Pipeline CRM - template backend,
|
||||
|
||||
#### Run App on local machine:
|
||||
|
||||
@ -30,10 +30,10 @@
|
||||
- `psql postgres -U admin`
|
||||
|
||||
- Type this command to creating a new database.
|
||||
- `postgres=> CREATE DATABASE db_instructor_student_lms;`
|
||||
- `postgres=> CREATE DATABASE db_sales_pipeline_crm;`
|
||||
|
||||
- Then give that new user privileges to the new database then quit the `psql`.
|
||||
- `postgres=> GRANT ALL PRIVILEGES ON DATABASE db_instructor_student_lms TO admin;`
|
||||
- `postgres=> GRANT ALL PRIVILEGES ON DATABASE db_sales_pipeline_crm TO admin;`
|
||||
- `postgres=> \q`
|
||||
|
||||
------------
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "instructorstudentlms",
|
||||
"description": "Instructor-Student LMS - template backend",
|
||||
"name": "salespipelinecrm",
|
||||
"description": "Sales Pipeline CRM - template backend",
|
||||
"scripts": {
|
||||
"start": "npm run db:migrate && npm run db:seed && npm run watch",
|
||||
"lint": "eslint . --ext .js",
|
||||
|
||||
@ -11,15 +11,15 @@ const config = {
|
||||
bcrypt: {
|
||||
saltRounds: 12
|
||||
},
|
||||
admin_pass: "e52941c5",
|
||||
user_pass: "20ceb5eda155",
|
||||
admin_pass: "72a5084e",
|
||||
user_pass: "c6ada26bc4fa",
|
||||
admin_email: "admin@flatlogic.com",
|
||||
providers: {
|
||||
LOCAL: 'local',
|
||||
GOOGLE: 'google',
|
||||
MICROSOFT: 'microsoft'
|
||||
},
|
||||
secret_key: process.env.SECRET_KEY || 'e52941c5-df65-471d-838b-20ceb5eda155',
|
||||
secret_key: process.env.SECRET_KEY || '72a5084e-302a-4f10-bdae-c6ada26bc4fa',
|
||||
remote: '',
|
||||
port: process.env.NODE_ENV === "production" ? "" : "8080",
|
||||
hostUI: process.env.NODE_ENV === "production" ? "" : "http://localhost",
|
||||
@ -39,7 +39,7 @@ const config = {
|
||||
},
|
||||
uploadDir: os.tmpdir(),
|
||||
email: {
|
||||
from: 'Instructor-Student LMS <app@flatlogic.app>',
|
||||
from: 'Sales Pipeline CRM <app@flatlogic.app>',
|
||||
host: 'email-smtp.us-east-1.amazonaws.com',
|
||||
port: 587,
|
||||
auth: {
|
||||
@ -56,11 +56,11 @@ const config = {
|
||||
|
||||
|
||||
|
||||
user: 'Student',
|
||||
user: 'Support Specialist',
|
||||
|
||||
},
|
||||
|
||||
project_uuid: 'e52941c5-df65-471d-838b-20ceb5eda155',
|
||||
project_uuid: '72a5084e-302a-4f10-bdae-c6ada26bc4fa',
|
||||
flHost: process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'dev_stage' ? 'https://flatlogic.com/projects' : 'http://localhost:3000/projects',
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ const config = {
|
||||
|
||||
config.pexelsKey = process.env.PEXELS_KEY || '';
|
||||
|
||||
config.pexelsQuery = 'soaring paper airplane over calm sea';
|
||||
config.pexelsQuery = 'mountain path leading to sunrise';
|
||||
config.host = process.env.NODE_ENV === "production" ? config.remote : "http://localhost";
|
||||
config.apiUrl = `${config.host}${config.port ? `:${config.port}` : ``}/api`;
|
||||
config.swaggerUrl = `${config.swaggerUI}${config.swaggerPort}`;
|
||||
|
||||
@ -9,7 +9,7 @@ const Utils = require('../utils');
|
||||
const Sequelize = db.Sequelize;
|
||||
const Op = Sequelize.Op;
|
||||
|
||||
module.exports = class ProgressDBApi {
|
||||
module.exports = class ActivitiesDBApi {
|
||||
|
||||
|
||||
|
||||
@ -17,11 +17,26 @@ module.exports = class ProgressDBApi {
|
||||
const currentUser = (options && options.currentUser) || { id: null };
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const progress = await db.progress.create(
|
||||
const activities = await db.activities.create(
|
||||
{
|
||||
id: data.id || undefined,
|
||||
|
||||
note: data.note
|
||||
subject: data.subject
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
activity_type: data.activity_type
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
start: data.start
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
end: data.end
|
||||
||
|
||||
null
|
||||
,
|
||||
@ -32,17 +47,7 @@ module.exports = class ProgressDBApi {
|
||||
|
||||
,
|
||||
|
||||
completed_at: data.completed_at
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
score: data.score
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
attempts: data.attempts
|
||||
notes: data.notes
|
||||
||
|
||||
null
|
||||
,
|
||||
@ -55,11 +60,15 @@ module.exports = class ProgressDBApi {
|
||||
);
|
||||
|
||||
|
||||
await progress.setEnrollment( data.enrollment || null, {
|
||||
await activities.setOwner( data.owner || null, {
|
||||
transaction,
|
||||
});
|
||||
|
||||
await progress.setLesson( data.lesson || null, {
|
||||
await activities.setRelated_deal( data.related_deal || null, {
|
||||
transaction,
|
||||
});
|
||||
|
||||
await activities.setRelated_lead( data.related_lead || null, {
|
||||
transaction,
|
||||
});
|
||||
|
||||
@ -68,7 +77,7 @@ module.exports = class ProgressDBApi {
|
||||
|
||||
|
||||
|
||||
return progress;
|
||||
return activities;
|
||||
}
|
||||
|
||||
|
||||
@ -77,10 +86,25 @@ module.exports = class ProgressDBApi {
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
// Prepare data - wrapping individual data transformations in a map() method
|
||||
const progressData = data.map((item, index) => ({
|
||||
const activitiesData = data.map((item, index) => ({
|
||||
id: item.id || undefined,
|
||||
|
||||
note: item.note
|
||||
subject: item.subject
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
activity_type: item.activity_type
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
start: item.start
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
end: item.end
|
||||
||
|
||||
null
|
||||
,
|
||||
@ -91,17 +115,7 @@ module.exports = class ProgressDBApi {
|
||||
|
||||
,
|
||||
|
||||
completed_at: item.completed_at
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
score: item.score
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
attempts: item.attempts
|
||||
notes: item.notes
|
||||
||
|
||||
null
|
||||
,
|
||||
@ -113,12 +127,12 @@ module.exports = class ProgressDBApi {
|
||||
}));
|
||||
|
||||
// Bulk create items
|
||||
const progress = await db.progress.bulkCreate(progressData, { transaction });
|
||||
const activities = await db.activities.bulkCreate(activitiesData, { transaction });
|
||||
|
||||
// For each item created, replace relation files
|
||||
|
||||
|
||||
return progress;
|
||||
return activities;
|
||||
}
|
||||
|
||||
static async update(id, data, options) {
|
||||
@ -126,47 +140,59 @@ module.exports = class ProgressDBApi {
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
|
||||
const progress = await db.progress.findByPk(id, {}, {transaction});
|
||||
const activities = await db.activities.findByPk(id, {}, {transaction});
|
||||
|
||||
|
||||
|
||||
|
||||
const updatePayload = {};
|
||||
|
||||
if (data.note !== undefined) updatePayload.note = data.note;
|
||||
if (data.subject !== undefined) updatePayload.subject = data.subject;
|
||||
|
||||
|
||||
if (data.activity_type !== undefined) updatePayload.activity_type = data.activity_type;
|
||||
|
||||
|
||||
if (data.start !== undefined) updatePayload.start = data.start;
|
||||
|
||||
|
||||
if (data.end !== undefined) updatePayload.end = data.end;
|
||||
|
||||
|
||||
if (data.completed !== undefined) updatePayload.completed = data.completed;
|
||||
|
||||
|
||||
if (data.completed_at !== undefined) updatePayload.completed_at = data.completed_at;
|
||||
|
||||
|
||||
if (data.score !== undefined) updatePayload.score = data.score;
|
||||
|
||||
|
||||
if (data.attempts !== undefined) updatePayload.attempts = data.attempts;
|
||||
if (data.notes !== undefined) updatePayload.notes = data.notes;
|
||||
|
||||
|
||||
updatePayload.updatedById = currentUser.id;
|
||||
|
||||
await progress.update(updatePayload, {transaction});
|
||||
await activities.update(updatePayload, {transaction});
|
||||
|
||||
|
||||
|
||||
if (data.enrollment !== undefined) {
|
||||
await progress.setEnrollment(
|
||||
if (data.owner !== undefined) {
|
||||
await activities.setOwner(
|
||||
|
||||
data.enrollment,
|
||||
data.owner,
|
||||
|
||||
{ transaction }
|
||||
);
|
||||
}
|
||||
|
||||
if (data.lesson !== undefined) {
|
||||
await progress.setLesson(
|
||||
if (data.related_deal !== undefined) {
|
||||
await activities.setRelated_deal(
|
||||
|
||||
data.lesson,
|
||||
data.related_deal,
|
||||
|
||||
{ transaction }
|
||||
);
|
||||
}
|
||||
|
||||
if (data.related_lead !== undefined) {
|
||||
await activities.setRelated_lead(
|
||||
|
||||
data.related_lead,
|
||||
|
||||
{ transaction }
|
||||
);
|
||||
@ -178,14 +204,14 @@ module.exports = class ProgressDBApi {
|
||||
|
||||
|
||||
|
||||
return progress;
|
||||
return activities;
|
||||
}
|
||||
|
||||
static async deleteByIds(ids, options) {
|
||||
const currentUser = (options && options.currentUser) || { id: null };
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const progress = await db.progress.findAll({
|
||||
const activities = await db.activities.findAll({
|
||||
where: {
|
||||
id: {
|
||||
[Op.in]: ids,
|
||||
@ -195,53 +221,53 @@ module.exports = class ProgressDBApi {
|
||||
});
|
||||
|
||||
await db.sequelize.transaction(async (transaction) => {
|
||||
for (const record of progress) {
|
||||
for (const record of activities) {
|
||||
await record.update(
|
||||
{deletedBy: currentUser.id},
|
||||
{transaction}
|
||||
);
|
||||
}
|
||||
for (const record of progress) {
|
||||
for (const record of activities) {
|
||||
await record.destroy({transaction});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return progress;
|
||||
return activities;
|
||||
}
|
||||
|
||||
static async remove(id, options) {
|
||||
const currentUser = (options && options.currentUser) || {id: null};
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const progress = await db.progress.findByPk(id, options);
|
||||
const activities = await db.activities.findByPk(id, options);
|
||||
|
||||
await progress.update({
|
||||
await activities.update({
|
||||
deletedBy: currentUser.id
|
||||
}, {
|
||||
transaction,
|
||||
});
|
||||
|
||||
await progress.destroy({
|
||||
await activities.destroy({
|
||||
transaction
|
||||
});
|
||||
|
||||
return progress;
|
||||
return activities;
|
||||
}
|
||||
|
||||
static async findBy(where, options) {
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const progress = await db.progress.findOne(
|
||||
const activities = await db.activities.findOne(
|
||||
{ where },
|
||||
{ transaction },
|
||||
);
|
||||
|
||||
if (!progress) {
|
||||
return progress;
|
||||
if (!activities) {
|
||||
return activities;
|
||||
}
|
||||
|
||||
const output = progress.get({plain: true});
|
||||
const output = activities.get({plain: true});
|
||||
|
||||
|
||||
|
||||
@ -252,12 +278,18 @@ module.exports = class ProgressDBApi {
|
||||
|
||||
|
||||
|
||||
output.enrollment = await progress.getEnrollment({
|
||||
|
||||
output.owner = await activities.getOwner({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
output.lesson = await progress.getLesson({
|
||||
output.related_deal = await activities.getRelated_deal({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
output.related_lead = await activities.getRelated_lead({
|
||||
transaction
|
||||
});
|
||||
|
||||
@ -288,15 +320,15 @@ module.exports = class ProgressDBApi {
|
||||
let include = [
|
||||
|
||||
{
|
||||
model: db.enrollments,
|
||||
as: 'enrollment',
|
||||
model: db.users,
|
||||
as: 'owner',
|
||||
|
||||
where: filter.enrollment ? {
|
||||
where: filter.owner ? {
|
||||
[Op.or]: [
|
||||
{ id: { [Op.in]: filter.enrollment.split('|').map(term => Utils.uuid(term)) } },
|
||||
{ id: { [Op.in]: filter.owner.split('|').map(term => Utils.uuid(term)) } },
|
||||
{
|
||||
enrollment_label: {
|
||||
[Op.or]: filter.enrollment.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
||||
firstName: {
|
||||
[Op.or]: filter.owner.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
||||
}
|
||||
},
|
||||
]
|
||||
@ -305,15 +337,32 @@ module.exports = class ProgressDBApi {
|
||||
},
|
||||
|
||||
{
|
||||
model: db.lessons,
|
||||
as: 'lesson',
|
||||
model: db.deals,
|
||||
as: 'related_deal',
|
||||
|
||||
where: filter.lesson ? {
|
||||
where: filter.related_deal ? {
|
||||
[Op.or]: [
|
||||
{ id: { [Op.in]: filter.lesson.split('|').map(term => Utils.uuid(term)) } },
|
||||
{ id: { [Op.in]: filter.related_deal.split('|').map(term => Utils.uuid(term)) } },
|
||||
{
|
||||
title: {
|
||||
[Op.or]: filter.lesson.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
||||
[Op.or]: filter.related_deal.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
||||
}
|
||||
},
|
||||
]
|
||||
} : {},
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
model: db.leads,
|
||||
as: 'related_lead',
|
||||
|
||||
where: filter.related_lead ? {
|
||||
[Op.or]: [
|
||||
{ id: { [Op.in]: filter.related_lead.split('|').map(term => Utils.uuid(term)) } },
|
||||
{
|
||||
name: {
|
||||
[Op.or]: filter.related_lead.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
||||
}
|
||||
},
|
||||
]
|
||||
@ -334,13 +383,24 @@ module.exports = class ProgressDBApi {
|
||||
}
|
||||
|
||||
|
||||
if (filter.note) {
|
||||
if (filter.subject) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'progress',
|
||||
'note',
|
||||
filter.note,
|
||||
'activities',
|
||||
'subject',
|
||||
filter.subject,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.notes) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'activities',
|
||||
'notes',
|
||||
filter.notes,
|
||||
),
|
||||
};
|
||||
}
|
||||
@ -348,16 +408,34 @@ module.exports = class ProgressDBApi {
|
||||
|
||||
|
||||
|
||||
if (filter.calendarStart && filter.calendarEnd) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.or]: [
|
||||
{
|
||||
start: {
|
||||
[Op.between]: [filter.calendarStart, filter.calendarEnd],
|
||||
},
|
||||
},
|
||||
{
|
||||
end: {
|
||||
[Op.between]: [filter.calendarStart, filter.calendarEnd],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (filter.completed_atRange) {
|
||||
const [start, end] = filter.completed_atRange;
|
||||
if (filter.startRange) {
|
||||
const [start, end] = filter.startRange;
|
||||
|
||||
if (start !== undefined && start !== null && start !== '') {
|
||||
where = {
|
||||
...where,
|
||||
completed_at: {
|
||||
...where.completed_at,
|
||||
start: {
|
||||
...where.start,
|
||||
[Op.gte]: start,
|
||||
},
|
||||
};
|
||||
@ -366,22 +444,22 @@ module.exports = class ProgressDBApi {
|
||||
if (end !== undefined && end !== null && end !== '') {
|
||||
where = {
|
||||
...where,
|
||||
completed_at: {
|
||||
...where.completed_at,
|
||||
start: {
|
||||
...where.start,
|
||||
[Op.lte]: end,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (filter.scoreRange) {
|
||||
const [start, end] = filter.scoreRange;
|
||||
if (filter.endRange) {
|
||||
const [start, end] = filter.endRange;
|
||||
|
||||
if (start !== undefined && start !== null && start !== '') {
|
||||
where = {
|
||||
...where,
|
||||
score: {
|
||||
...where.score,
|
||||
end: {
|
||||
...where.end,
|
||||
[Op.gte]: start,
|
||||
},
|
||||
};
|
||||
@ -390,32 +468,8 @@ module.exports = class ProgressDBApi {
|
||||
if (end !== undefined && end !== null && end !== '') {
|
||||
where = {
|
||||
...where,
|
||||
score: {
|
||||
...where.score,
|
||||
[Op.lte]: end,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (filter.attemptsRange) {
|
||||
const [start, end] = filter.attemptsRange;
|
||||
|
||||
if (start !== undefined && start !== null && start !== '') {
|
||||
where = {
|
||||
...where,
|
||||
attempts: {
|
||||
...where.attempts,
|
||||
[Op.gte]: start,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (end !== undefined && end !== null && end !== '') {
|
||||
where = {
|
||||
...where,
|
||||
attempts: {
|
||||
...where.attempts,
|
||||
end: {
|
||||
...where.end,
|
||||
[Op.lte]: end,
|
||||
},
|
||||
};
|
||||
@ -431,6 +485,13 @@ module.exports = class ProgressDBApi {
|
||||
}
|
||||
|
||||
|
||||
if (filter.activity_type) {
|
||||
where = {
|
||||
...where,
|
||||
activity_type: filter.activity_type,
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.completed) {
|
||||
where = {
|
||||
...where,
|
||||
@ -444,6 +505,8 @@ module.exports = class ProgressDBApi {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (filter.createdAtRange) {
|
||||
@ -491,7 +554,7 @@ module.exports = class ProgressDBApi {
|
||||
}
|
||||
|
||||
try {
|
||||
const { rows, count } = await db.progress.findAndCountAll(queryOptions);
|
||||
const { rows, count } = await db.activities.findAndCountAll(queryOptions);
|
||||
|
||||
return {
|
||||
rows: options?.countOnly ? [] : rows,
|
||||
@ -513,25 +576,25 @@ module.exports = class ProgressDBApi {
|
||||
[Op.or]: [
|
||||
{ ['id']: Utils.uuid(query) },
|
||||
Utils.ilike(
|
||||
'progress',
|
||||
'note',
|
||||
'activities',
|
||||
'subject',
|
||||
query,
|
||||
),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const records = await db.progress.findAll({
|
||||
attributes: [ 'id', 'note' ],
|
||||
const records = await db.activities.findAll({
|
||||
attributes: [ 'id', 'subject' ],
|
||||
where,
|
||||
limit: limit ? Number(limit) : undefined,
|
||||
offset: offset ? Number(offset) : undefined,
|
||||
orderBy: [['note', 'ASC']],
|
||||
orderBy: [['subject', 'ASC']],
|
||||
});
|
||||
|
||||
return records.map((record) => ({
|
||||
id: record.id,
|
||||
label: record.note,
|
||||
label: record.subject,
|
||||
}));
|
||||
}
|
||||
|
||||
495
backend/src/db/api/contacts.js
Normal file
495
backend/src/db/api/contacts.js
Normal file
@ -0,0 +1,495 @@
|
||||
|
||||
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 ContactsDBApi {
|
||||
|
||||
|
||||
|
||||
static async create(data, options) {
|
||||
const currentUser = (options && options.currentUser) || { id: null };
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const contacts = await db.contacts.create(
|
||||
{
|
||||
id: data.id || undefined,
|
||||
|
||||
name: data.name
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
email: data.email
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
phone: data.phone
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
title: data.title
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
company: data.company
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
notes: data.notes
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
importHash: data.importHash || null,
|
||||
createdById: currentUser.id,
|
||||
updatedById: currentUser.id,
|
||||
},
|
||||
{ transaction },
|
||||
);
|
||||
|
||||
|
||||
await contacts.setOwner( data.owner || null, {
|
||||
transaction,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return contacts;
|
||||
}
|
||||
|
||||
|
||||
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 contactsData = data.map((item, index) => ({
|
||||
id: item.id || undefined,
|
||||
|
||||
name: item.name
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
email: item.email
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
phone: item.phone
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
title: item.title
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
company: item.company
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
notes: item.notes
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
importHash: item.importHash || null,
|
||||
createdById: currentUser.id,
|
||||
updatedById: currentUser.id,
|
||||
createdAt: new Date(Date.now() + index * 1000),
|
||||
}));
|
||||
|
||||
// Bulk create items
|
||||
const contacts = await db.contacts.bulkCreate(contactsData, { transaction });
|
||||
|
||||
// For each item created, replace relation files
|
||||
|
||||
|
||||
return contacts;
|
||||
}
|
||||
|
||||
static async update(id, data, options) {
|
||||
const currentUser = (options && options.currentUser) || {id: null};
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
|
||||
const contacts = await db.contacts.findByPk(id, {}, {transaction});
|
||||
|
||||
|
||||
|
||||
|
||||
const updatePayload = {};
|
||||
|
||||
if (data.name !== undefined) updatePayload.name = data.name;
|
||||
|
||||
|
||||
if (data.email !== undefined) updatePayload.email = data.email;
|
||||
|
||||
|
||||
if (data.phone !== undefined) updatePayload.phone = data.phone;
|
||||
|
||||
|
||||
if (data.title !== undefined) updatePayload.title = data.title;
|
||||
|
||||
|
||||
if (data.company !== undefined) updatePayload.company = data.company;
|
||||
|
||||
|
||||
if (data.notes !== undefined) updatePayload.notes = data.notes;
|
||||
|
||||
|
||||
updatePayload.updatedById = currentUser.id;
|
||||
|
||||
await contacts.update(updatePayload, {transaction});
|
||||
|
||||
|
||||
|
||||
if (data.owner !== undefined) {
|
||||
await contacts.setOwner(
|
||||
|
||||
data.owner,
|
||||
|
||||
{ transaction }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return contacts;
|
||||
}
|
||||
|
||||
static async deleteByIds(ids, options) {
|
||||
const currentUser = (options && options.currentUser) || { id: null };
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const contacts = await db.contacts.findAll({
|
||||
where: {
|
||||
id: {
|
||||
[Op.in]: ids,
|
||||
},
|
||||
},
|
||||
transaction,
|
||||
});
|
||||
|
||||
await db.sequelize.transaction(async (transaction) => {
|
||||
for (const record of contacts) {
|
||||
await record.update(
|
||||
{deletedBy: currentUser.id},
|
||||
{transaction}
|
||||
);
|
||||
}
|
||||
for (const record of contacts) {
|
||||
await record.destroy({transaction});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return contacts;
|
||||
}
|
||||
|
||||
static async remove(id, options) {
|
||||
const currentUser = (options && options.currentUser) || {id: null};
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const contacts = await db.contacts.findByPk(id, options);
|
||||
|
||||
await contacts.update({
|
||||
deletedBy: currentUser.id
|
||||
}, {
|
||||
transaction,
|
||||
});
|
||||
|
||||
await contacts.destroy({
|
||||
transaction
|
||||
});
|
||||
|
||||
return contacts;
|
||||
}
|
||||
|
||||
static async findBy(where, options) {
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const contacts = await db.contacts.findOne(
|
||||
{ where },
|
||||
{ transaction },
|
||||
);
|
||||
|
||||
if (!contacts) {
|
||||
return contacts;
|
||||
}
|
||||
|
||||
const output = contacts.get({plain: true});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
output.deals_primary_contact = await contacts.getDeals_primary_contact({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
output.owner = await contacts.getOwner({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
static async findAll(
|
||||
filter,
|
||||
options
|
||||
) {
|
||||
const limit = filter.limit || 0;
|
||||
let offset = 0;
|
||||
let where = {};
|
||||
const currentPage = +filter.page;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
offset = currentPage * limit;
|
||||
|
||||
const orderBy = null;
|
||||
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
let include = [
|
||||
|
||||
{
|
||||
model: db.users,
|
||||
as: 'owner',
|
||||
|
||||
where: filter.owner ? {
|
||||
[Op.or]: [
|
||||
{ id: { [Op.in]: filter.owner.split('|').map(term => Utils.uuid(term)) } },
|
||||
{
|
||||
firstName: {
|
||||
[Op.or]: filter.owner.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
||||
}
|
||||
},
|
||||
]
|
||||
} : {},
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
];
|
||||
|
||||
if (filter) {
|
||||
if (filter.id) {
|
||||
where = {
|
||||
...where,
|
||||
['id']: Utils.uuid(filter.id),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
if (filter.name) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'contacts',
|
||||
'name',
|
||||
filter.name,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.email) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'contacts',
|
||||
'email',
|
||||
filter.email,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.phone) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'contacts',
|
||||
'phone',
|
||||
filter.phone,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.title) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'contacts',
|
||||
'title',
|
||||
filter.title,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.company) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'contacts',
|
||||
'company',
|
||||
filter.company,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.notes) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'contacts',
|
||||
'notes',
|
||||
filter.notes,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (filter.active !== undefined) {
|
||||
where = {
|
||||
...where,
|
||||
active: filter.active === true || filter.active === 'true'
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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.contacts.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, ) {
|
||||
let where = {};
|
||||
|
||||
|
||||
|
||||
if (query) {
|
||||
where = {
|
||||
[Op.or]: [
|
||||
{ ['id']: Utils.uuid(query) },
|
||||
Utils.ilike(
|
||||
'contacts',
|
||||
'name',
|
||||
query,
|
||||
),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const records = await db.contacts.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,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -9,7 +9,7 @@ const Utils = require('../utils');
|
||||
const Sequelize = db.Sequelize;
|
||||
const Op = Sequelize.Op;
|
||||
|
||||
module.exports = class LessonsDBApi {
|
||||
module.exports = class DealsDBApi {
|
||||
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ module.exports = class LessonsDBApi {
|
||||
const currentUser = (options && options.currentUser) || { id: null };
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const lessons = await db.lessons.create(
|
||||
const deals = await db.deals.create(
|
||||
{
|
||||
id: data.id || undefined,
|
||||
|
||||
@ -26,28 +26,33 @@ module.exports = class LessonsDBApi {
|
||||
null
|
||||
,
|
||||
|
||||
content: data.content
|
||||
deal_number: data.deal_number
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
order: data.order
|
||||
value: data.value
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
duration_minutes: data.duration_minutes
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
release_date: data.release_date
|
||||
currency: data.currency
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
status: data.status
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
close_date: data.close_date
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
description: data.description
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
@ -59,7 +64,15 @@ module.exports = class LessonsDBApi {
|
||||
);
|
||||
|
||||
|
||||
await lessons.setCourse( data.course || null, {
|
||||
await deals.setStage( data.stage || null, {
|
||||
transaction,
|
||||
});
|
||||
|
||||
await deals.setOwner( data.owner || null, {
|
||||
transaction,
|
||||
});
|
||||
|
||||
await deals.setPrimary_contact( data.primary_contact || null, {
|
||||
transaction,
|
||||
});
|
||||
|
||||
@ -67,28 +80,8 @@ module.exports = class LessonsDBApi {
|
||||
|
||||
|
||||
|
||||
await FileDBApi.replaceRelationFiles(
|
||||
{
|
||||
belongsTo: db.lessons.getTableName(),
|
||||
belongsToColumn: 'video_files',
|
||||
belongsToId: lessons.id,
|
||||
},
|
||||
data.video_files,
|
||||
options,
|
||||
);
|
||||
|
||||
await FileDBApi.replaceRelationFiles(
|
||||
{
|
||||
belongsTo: db.lessons.getTableName(),
|
||||
belongsToColumn: 'resources',
|
||||
belongsToId: lessons.id,
|
||||
},
|
||||
data.resources,
|
||||
options,
|
||||
);
|
||||
|
||||
|
||||
return lessons;
|
||||
return deals;
|
||||
}
|
||||
|
||||
|
||||
@ -97,7 +90,7 @@ module.exports = class LessonsDBApi {
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
// Prepare data - wrapping individual data transformations in a map() method
|
||||
const lessonsData = data.map((item, index) => ({
|
||||
const dealsData = data.map((item, index) => ({
|
||||
id: item.id || undefined,
|
||||
|
||||
title: item.title
|
||||
@ -105,22 +98,17 @@ module.exports = class LessonsDBApi {
|
||||
null
|
||||
,
|
||||
|
||||
content: item.content
|
||||
deal_number: item.deal_number
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
order: item.order
|
||||
value: item.value
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
duration_minutes: item.duration_minutes
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
release_date: item.release_date
|
||||
currency: item.currency
|
||||
||
|
||||
null
|
||||
,
|
||||
@ -128,6 +116,16 @@ module.exports = class LessonsDBApi {
|
||||
status: item.status
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
close_date: item.close_date
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
description: item.description
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
importHash: item.importHash || null,
|
||||
@ -137,36 +135,12 @@ module.exports = class LessonsDBApi {
|
||||
}));
|
||||
|
||||
// Bulk create items
|
||||
const lessons = await db.lessons.bulkCreate(lessonsData, { transaction });
|
||||
const deals = await db.deals.bulkCreate(dealsData, { transaction });
|
||||
|
||||
// For each item created, replace relation files
|
||||
|
||||
for (let i = 0; i < lessons.length; i++) {
|
||||
await FileDBApi.replaceRelationFiles(
|
||||
{
|
||||
belongsTo: db.lessons.getTableName(),
|
||||
belongsToColumn: 'video_files',
|
||||
belongsToId: lessons[i].id,
|
||||
},
|
||||
data[i].video_files,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
for (let i = 0; i < lessons.length; i++) {
|
||||
await FileDBApi.replaceRelationFiles(
|
||||
{
|
||||
belongsTo: db.lessons.getTableName(),
|
||||
belongsToColumn: 'resources',
|
||||
belongsToId: lessons[i].id,
|
||||
},
|
||||
data[i].resources,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return lessons;
|
||||
return deals;
|
||||
}
|
||||
|
||||
static async update(id, data, options) {
|
||||
@ -174,7 +148,7 @@ module.exports = class LessonsDBApi {
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
|
||||
const lessons = await db.lessons.findByPk(id, {}, {transaction});
|
||||
const deals = await db.deals.findByPk(id, {}, {transaction});
|
||||
|
||||
|
||||
|
||||
@ -184,31 +158,52 @@ module.exports = class LessonsDBApi {
|
||||
if (data.title !== undefined) updatePayload.title = data.title;
|
||||
|
||||
|
||||
if (data.content !== undefined) updatePayload.content = data.content;
|
||||
if (data.deal_number !== undefined) updatePayload.deal_number = data.deal_number;
|
||||
|
||||
|
||||
if (data.order !== undefined) updatePayload.order = data.order;
|
||||
if (data.value !== undefined) updatePayload.value = data.value;
|
||||
|
||||
|
||||
if (data.duration_minutes !== undefined) updatePayload.duration_minutes = data.duration_minutes;
|
||||
|
||||
|
||||
if (data.release_date !== undefined) updatePayload.release_date = data.release_date;
|
||||
if (data.currency !== undefined) updatePayload.currency = data.currency;
|
||||
|
||||
|
||||
if (data.status !== undefined) updatePayload.status = data.status;
|
||||
|
||||
|
||||
if (data.close_date !== undefined) updatePayload.close_date = data.close_date;
|
||||
|
||||
|
||||
if (data.description !== undefined) updatePayload.description = data.description;
|
||||
|
||||
|
||||
updatePayload.updatedById = currentUser.id;
|
||||
|
||||
await lessons.update(updatePayload, {transaction});
|
||||
await deals.update(updatePayload, {transaction});
|
||||
|
||||
|
||||
|
||||
if (data.course !== undefined) {
|
||||
await lessons.setCourse(
|
||||
if (data.stage !== undefined) {
|
||||
await deals.setStage(
|
||||
|
||||
data.course,
|
||||
data.stage,
|
||||
|
||||
{ transaction }
|
||||
);
|
||||
}
|
||||
|
||||
if (data.owner !== undefined) {
|
||||
await deals.setOwner(
|
||||
|
||||
data.owner,
|
||||
|
||||
{ transaction }
|
||||
);
|
||||
}
|
||||
|
||||
if (data.primary_contact !== undefined) {
|
||||
await deals.setPrimary_contact(
|
||||
|
||||
data.primary_contact,
|
||||
|
||||
{ transaction }
|
||||
);
|
||||
@ -219,35 +214,15 @@ module.exports = class LessonsDBApi {
|
||||
|
||||
|
||||
|
||||
await FileDBApi.replaceRelationFiles(
|
||||
{
|
||||
belongsTo: db.lessons.getTableName(),
|
||||
belongsToColumn: 'video_files',
|
||||
belongsToId: lessons.id,
|
||||
},
|
||||
data.video_files,
|
||||
options,
|
||||
);
|
||||
|
||||
await FileDBApi.replaceRelationFiles(
|
||||
{
|
||||
belongsTo: db.lessons.getTableName(),
|
||||
belongsToColumn: 'resources',
|
||||
belongsToId: lessons.id,
|
||||
},
|
||||
data.resources,
|
||||
options,
|
||||
);
|
||||
|
||||
|
||||
return lessons;
|
||||
return deals;
|
||||
}
|
||||
|
||||
static async deleteByIds(ids, options) {
|
||||
const currentUser = (options && options.currentUser) || { id: null };
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const lessons = await db.lessons.findAll({
|
||||
const deals = await db.deals.findAll({
|
||||
where: {
|
||||
id: {
|
||||
[Op.in]: ids,
|
||||
@ -257,53 +232,53 @@ module.exports = class LessonsDBApi {
|
||||
});
|
||||
|
||||
await db.sequelize.transaction(async (transaction) => {
|
||||
for (const record of lessons) {
|
||||
for (const record of deals) {
|
||||
await record.update(
|
||||
{deletedBy: currentUser.id},
|
||||
{transaction}
|
||||
);
|
||||
}
|
||||
for (const record of lessons) {
|
||||
for (const record of deals) {
|
||||
await record.destroy({transaction});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return lessons;
|
||||
return deals;
|
||||
}
|
||||
|
||||
static async remove(id, options) {
|
||||
const currentUser = (options && options.currentUser) || {id: null};
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const lessons = await db.lessons.findByPk(id, options);
|
||||
const deals = await db.deals.findByPk(id, options);
|
||||
|
||||
await lessons.update({
|
||||
await deals.update({
|
||||
deletedBy: currentUser.id
|
||||
}, {
|
||||
transaction,
|
||||
});
|
||||
|
||||
await lessons.destroy({
|
||||
await deals.destroy({
|
||||
transaction
|
||||
});
|
||||
|
||||
return lessons;
|
||||
return deals;
|
||||
}
|
||||
|
||||
static async findBy(where, options) {
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const lessons = await db.lessons.findOne(
|
||||
const deals = await db.deals.findOne(
|
||||
{ where },
|
||||
{ transaction },
|
||||
);
|
||||
|
||||
if (!lessons) {
|
||||
return lessons;
|
||||
if (!deals) {
|
||||
return deals;
|
||||
}
|
||||
|
||||
const output = lessons.get({plain: true});
|
||||
const output = deals.get({plain: true});
|
||||
|
||||
|
||||
|
||||
@ -312,23 +287,24 @@ module.exports = class LessonsDBApi {
|
||||
|
||||
|
||||
|
||||
output.progress_lesson = await lessons.getProgress_lesson({
|
||||
|
||||
output.activities_related_deal = await deals.getActivities_related_deal({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
|
||||
output.course = await lessons.getCourse({
|
||||
output.stage = await deals.getStage({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
output.video_files = await lessons.getVideo_files({
|
||||
output.owner = await deals.getOwner({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
output.resources = await lessons.getResources({
|
||||
output.primary_contact = await deals.getPrimary_contact({
|
||||
transaction
|
||||
});
|
||||
|
||||
@ -359,15 +335,49 @@ module.exports = class LessonsDBApi {
|
||||
let include = [
|
||||
|
||||
{
|
||||
model: db.courses,
|
||||
as: 'course',
|
||||
model: db.pipeline_stages,
|
||||
as: 'stage',
|
||||
|
||||
where: filter.course ? {
|
||||
where: filter.stage ? {
|
||||
[Op.or]: [
|
||||
{ id: { [Op.in]: filter.course.split('|').map(term => Utils.uuid(term)) } },
|
||||
{ id: { [Op.in]: filter.stage.split('|').map(term => Utils.uuid(term)) } },
|
||||
{
|
||||
title: {
|
||||
[Op.or]: filter.course.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
||||
[Op.or]: filter.stage.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
||||
}
|
||||
},
|
||||
]
|
||||
} : {},
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
model: db.users,
|
||||
as: 'owner',
|
||||
|
||||
where: filter.owner ? {
|
||||
[Op.or]: [
|
||||
{ id: { [Op.in]: filter.owner.split('|').map(term => Utils.uuid(term)) } },
|
||||
{
|
||||
firstName: {
|
||||
[Op.or]: filter.owner.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
||||
}
|
||||
},
|
||||
]
|
||||
} : {},
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
model: db.contacts,
|
||||
as: 'primary_contact',
|
||||
|
||||
where: filter.primary_contact ? {
|
||||
[Op.or]: [
|
||||
{ id: { [Op.in]: filter.primary_contact.split('|').map(term => Utils.uuid(term)) } },
|
||||
{
|
||||
name: {
|
||||
[Op.or]: filter.primary_contact.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
||||
}
|
||||
},
|
||||
]
|
||||
@ -377,16 +387,6 @@ module.exports = class LessonsDBApi {
|
||||
|
||||
|
||||
|
||||
{
|
||||
model: db.file,
|
||||
as: 'video_files',
|
||||
},
|
||||
|
||||
{
|
||||
model: db.file,
|
||||
as: 'resources',
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
if (filter) {
|
||||
@ -402,20 +402,42 @@ module.exports = class LessonsDBApi {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'lessons',
|
||||
'deals',
|
||||
'title',
|
||||
filter.title,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.content) {
|
||||
if (filter.deal_number) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'lessons',
|
||||
'content',
|
||||
filter.content,
|
||||
'deals',
|
||||
'deal_number',
|
||||
filter.deal_number,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.currency) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'deals',
|
||||
'currency',
|
||||
filter.currency,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.description) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'deals',
|
||||
'description',
|
||||
filter.description,
|
||||
),
|
||||
};
|
||||
}
|
||||
@ -425,14 +447,14 @@ module.exports = class LessonsDBApi {
|
||||
|
||||
|
||||
|
||||
if (filter.orderRange) {
|
||||
const [start, end] = filter.orderRange;
|
||||
if (filter.valueRange) {
|
||||
const [start, end] = filter.valueRange;
|
||||
|
||||
if (start !== undefined && start !== null && start !== '') {
|
||||
where = {
|
||||
...where,
|
||||
order: {
|
||||
...where.order,
|
||||
value: {
|
||||
...where.value,
|
||||
[Op.gte]: start,
|
||||
},
|
||||
};
|
||||
@ -441,22 +463,22 @@ module.exports = class LessonsDBApi {
|
||||
if (end !== undefined && end !== null && end !== '') {
|
||||
where = {
|
||||
...where,
|
||||
order: {
|
||||
...where.order,
|
||||
value: {
|
||||
...where.value,
|
||||
[Op.lte]: end,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (filter.duration_minutesRange) {
|
||||
const [start, end] = filter.duration_minutesRange;
|
||||
if (filter.close_dateRange) {
|
||||
const [start, end] = filter.close_dateRange;
|
||||
|
||||
if (start !== undefined && start !== null && start !== '') {
|
||||
where = {
|
||||
...where,
|
||||
duration_minutes: {
|
||||
...where.duration_minutes,
|
||||
close_date: {
|
||||
...where.close_date,
|
||||
[Op.gte]: start,
|
||||
},
|
||||
};
|
||||
@ -465,32 +487,8 @@ module.exports = class LessonsDBApi {
|
||||
if (end !== undefined && end !== null && end !== '') {
|
||||
where = {
|
||||
...where,
|
||||
duration_minutes: {
|
||||
...where.duration_minutes,
|
||||
[Op.lte]: end,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (filter.release_dateRange) {
|
||||
const [start, end] = filter.release_dateRange;
|
||||
|
||||
if (start !== undefined && start !== null && start !== '') {
|
||||
where = {
|
||||
...where,
|
||||
release_date: {
|
||||
...where.release_date,
|
||||
[Op.gte]: start,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (end !== undefined && end !== null && end !== '') {
|
||||
where = {
|
||||
...where,
|
||||
release_date: {
|
||||
...where.release_date,
|
||||
close_date: {
|
||||
...where.close_date,
|
||||
[Op.lte]: end,
|
||||
},
|
||||
};
|
||||
@ -517,6 +515,10 @@ module.exports = class LessonsDBApi {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (filter.createdAtRange) {
|
||||
@ -564,7 +566,7 @@ module.exports = class LessonsDBApi {
|
||||
}
|
||||
|
||||
try {
|
||||
const { rows, count } = await db.lessons.findAndCountAll(queryOptions);
|
||||
const { rows, count } = await db.deals.findAndCountAll(queryOptions);
|
||||
|
||||
return {
|
||||
rows: options?.countOnly ? [] : rows,
|
||||
@ -576,6 +578,21 @@ module.exports = class LessonsDBApi {
|
||||
}
|
||||
}
|
||||
|
||||
static async stats(options) {
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
const currentUser = (options && options.currentUser) || { id: null };
|
||||
|
||||
const result = await db.deals.findOne({
|
||||
attributes: [
|
||||
[db.Sequelize.fn('SUM', db.Sequelize.col('value')), 'totalValue'],
|
||||
[db.Sequelize.fn('COUNT', db.Sequelize.col('id')), 'count']
|
||||
],
|
||||
transaction,
|
||||
});
|
||||
|
||||
return result.get({ plain: true });
|
||||
}
|
||||
|
||||
static async findAllAutocomplete(query, limit, offset, ) {
|
||||
let where = {};
|
||||
|
||||
@ -586,7 +603,7 @@ module.exports = class LessonsDBApi {
|
||||
[Op.or]: [
|
||||
{ ['id']: Utils.uuid(query) },
|
||||
Utils.ilike(
|
||||
'lessons',
|
||||
'deals',
|
||||
'title',
|
||||
query,
|
||||
),
|
||||
@ -594,7 +611,7 @@ module.exports = class LessonsDBApi {
|
||||
};
|
||||
}
|
||||
|
||||
const records = await db.lessons.findAll({
|
||||
const records = await db.deals.findAll({
|
||||
attributes: [ 'id', 'title' ],
|
||||
where,
|
||||
limit: limit ? Number(limit) : undefined,
|
||||
@ -9,7 +9,7 @@ const Utils = require('../utils');
|
||||
const Sequelize = db.Sequelize;
|
||||
const Op = Sequelize.Op;
|
||||
|
||||
module.exports = class EnrollmentsDBApi {
|
||||
module.exports = class LeadsDBApi {
|
||||
|
||||
|
||||
|
||||
@ -17,16 +17,31 @@ module.exports = class EnrollmentsDBApi {
|
||||
const currentUser = (options && options.currentUser) || { id: null };
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const enrollments = await db.enrollments.create(
|
||||
const leads = await db.leads.create(
|
||||
{
|
||||
id: data.id || undefined,
|
||||
|
||||
enrollment_label: data.enrollment_label
|
||||
name: data.name
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
enrolled_at: data.enrolled_at
|
||||
company: data.company
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
email: data.email
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
phone: data.phone
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
source: data.source
|
||||
||
|
||||
null
|
||||
,
|
||||
@ -36,12 +51,12 @@ module.exports = class EnrollmentsDBApi {
|
||||
null
|
||||
,
|
||||
|
||||
progress_percent: data.progress_percent
|
||||
estimated_value: data.estimated_value
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
price_paid: data.price_paid
|
||||
notes: data.notes
|
||||
||
|
||||
null
|
||||
,
|
||||
@ -54,11 +69,7 @@ module.exports = class EnrollmentsDBApi {
|
||||
);
|
||||
|
||||
|
||||
await enrollments.setStudent( data.student || null, {
|
||||
transaction,
|
||||
});
|
||||
|
||||
await enrollments.setCourse( data.course || null, {
|
||||
await leads.setOwner( data.owner || null, {
|
||||
transaction,
|
||||
});
|
||||
|
||||
@ -67,7 +78,7 @@ module.exports = class EnrollmentsDBApi {
|
||||
|
||||
|
||||
|
||||
return enrollments;
|
||||
return leads;
|
||||
}
|
||||
|
||||
|
||||
@ -76,15 +87,30 @@ module.exports = class EnrollmentsDBApi {
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
// Prepare data - wrapping individual data transformations in a map() method
|
||||
const enrollmentsData = data.map((item, index) => ({
|
||||
const leadsData = data.map((item, index) => ({
|
||||
id: item.id || undefined,
|
||||
|
||||
enrollment_label: item.enrollment_label
|
||||
name: item.name
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
enrolled_at: item.enrolled_at
|
||||
company: item.company
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
email: item.email
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
phone: item.phone
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
source: item.source
|
||||
||
|
||||
null
|
||||
,
|
||||
@ -94,12 +120,12 @@ module.exports = class EnrollmentsDBApi {
|
||||
null
|
||||
,
|
||||
|
||||
progress_percent: item.progress_percent
|
||||
estimated_value: item.estimated_value
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
price_paid: item.price_paid
|
||||
notes: item.notes
|
||||
||
|
||||
null
|
||||
,
|
||||
@ -111,12 +137,12 @@ module.exports = class EnrollmentsDBApi {
|
||||
}));
|
||||
|
||||
// Bulk create items
|
||||
const enrollments = await db.enrollments.bulkCreate(enrollmentsData, { transaction });
|
||||
const leads = await db.leads.bulkCreate(leadsData, { transaction });
|
||||
|
||||
// For each item created, replace relation files
|
||||
|
||||
|
||||
return enrollments;
|
||||
return leads;
|
||||
}
|
||||
|
||||
static async update(id, data, options) {
|
||||
@ -124,47 +150,47 @@ module.exports = class EnrollmentsDBApi {
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
|
||||
const enrollments = await db.enrollments.findByPk(id, {}, {transaction});
|
||||
const leads = await db.leads.findByPk(id, {}, {transaction});
|
||||
|
||||
|
||||
|
||||
|
||||
const updatePayload = {};
|
||||
|
||||
if (data.enrollment_label !== undefined) updatePayload.enrollment_label = data.enrollment_label;
|
||||
if (data.name !== undefined) updatePayload.name = data.name;
|
||||
|
||||
|
||||
if (data.enrolled_at !== undefined) updatePayload.enrolled_at = data.enrolled_at;
|
||||
if (data.company !== undefined) updatePayload.company = data.company;
|
||||
|
||||
|
||||
if (data.email !== undefined) updatePayload.email = data.email;
|
||||
|
||||
|
||||
if (data.phone !== undefined) updatePayload.phone = data.phone;
|
||||
|
||||
|
||||
if (data.source !== undefined) updatePayload.source = data.source;
|
||||
|
||||
|
||||
if (data.status !== undefined) updatePayload.status = data.status;
|
||||
|
||||
|
||||
if (data.progress_percent !== undefined) updatePayload.progress_percent = data.progress_percent;
|
||||
if (data.estimated_value !== undefined) updatePayload.estimated_value = data.estimated_value;
|
||||
|
||||
|
||||
if (data.price_paid !== undefined) updatePayload.price_paid = data.price_paid;
|
||||
if (data.notes !== undefined) updatePayload.notes = data.notes;
|
||||
|
||||
|
||||
updatePayload.updatedById = currentUser.id;
|
||||
|
||||
await enrollments.update(updatePayload, {transaction});
|
||||
await leads.update(updatePayload, {transaction});
|
||||
|
||||
|
||||
|
||||
if (data.student !== undefined) {
|
||||
await enrollments.setStudent(
|
||||
if (data.owner !== undefined) {
|
||||
await leads.setOwner(
|
||||
|
||||
data.student,
|
||||
|
||||
{ transaction }
|
||||
);
|
||||
}
|
||||
|
||||
if (data.course !== undefined) {
|
||||
await enrollments.setCourse(
|
||||
|
||||
data.course,
|
||||
data.owner,
|
||||
|
||||
{ transaction }
|
||||
);
|
||||
@ -176,14 +202,14 @@ module.exports = class EnrollmentsDBApi {
|
||||
|
||||
|
||||
|
||||
return enrollments;
|
||||
return leads;
|
||||
}
|
||||
|
||||
static async deleteByIds(ids, options) {
|
||||
const currentUser = (options && options.currentUser) || { id: null };
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const enrollments = await db.enrollments.findAll({
|
||||
const leads = await db.leads.findAll({
|
||||
where: {
|
||||
id: {
|
||||
[Op.in]: ids,
|
||||
@ -193,53 +219,53 @@ module.exports = class EnrollmentsDBApi {
|
||||
});
|
||||
|
||||
await db.sequelize.transaction(async (transaction) => {
|
||||
for (const record of enrollments) {
|
||||
for (const record of leads) {
|
||||
await record.update(
|
||||
{deletedBy: currentUser.id},
|
||||
{transaction}
|
||||
);
|
||||
}
|
||||
for (const record of enrollments) {
|
||||
for (const record of leads) {
|
||||
await record.destroy({transaction});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return enrollments;
|
||||
return leads;
|
||||
}
|
||||
|
||||
static async remove(id, options) {
|
||||
const currentUser = (options && options.currentUser) || {id: null};
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const enrollments = await db.enrollments.findByPk(id, options);
|
||||
const leads = await db.leads.findByPk(id, options);
|
||||
|
||||
await enrollments.update({
|
||||
await leads.update({
|
||||
deletedBy: currentUser.id
|
||||
}, {
|
||||
transaction,
|
||||
});
|
||||
|
||||
await enrollments.destroy({
|
||||
await leads.destroy({
|
||||
transaction
|
||||
});
|
||||
|
||||
return enrollments;
|
||||
return leads;
|
||||
}
|
||||
|
||||
static async findBy(where, options) {
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const enrollments = await db.enrollments.findOne(
|
||||
const leads = await db.leads.findOne(
|
||||
{ where },
|
||||
{ transaction },
|
||||
);
|
||||
|
||||
if (!enrollments) {
|
||||
return enrollments;
|
||||
if (!leads) {
|
||||
return leads;
|
||||
}
|
||||
|
||||
const output = enrollments.get({plain: true});
|
||||
const output = leads.get({plain: true});
|
||||
|
||||
|
||||
|
||||
@ -248,18 +274,14 @@ module.exports = class EnrollmentsDBApi {
|
||||
|
||||
|
||||
|
||||
output.progress_enrollment = await enrollments.getProgress_enrollment({
|
||||
|
||||
output.activities_related_lead = await leads.getActivities_related_lead({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
|
||||
output.student = await enrollments.getStudent({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
output.course = await enrollments.getCourse({
|
||||
output.owner = await leads.getOwner({
|
||||
transaction
|
||||
});
|
||||
|
||||
@ -291,31 +313,14 @@ module.exports = class EnrollmentsDBApi {
|
||||
|
||||
{
|
||||
model: db.users,
|
||||
as: 'student',
|
||||
as: 'owner',
|
||||
|
||||
where: filter.student ? {
|
||||
where: filter.owner ? {
|
||||
[Op.or]: [
|
||||
{ id: { [Op.in]: filter.student.split('|').map(term => Utils.uuid(term)) } },
|
||||
{ id: { [Op.in]: filter.owner.split('|').map(term => Utils.uuid(term)) } },
|
||||
{
|
||||
firstName: {
|
||||
[Op.or]: filter.student.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
||||
}
|
||||
},
|
||||
]
|
||||
} : {},
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
model: db.courses,
|
||||
as: 'course',
|
||||
|
||||
where: filter.course ? {
|
||||
[Op.or]: [
|
||||
{ id: { [Op.in]: filter.course.split('|').map(term => Utils.uuid(term)) } },
|
||||
{
|
||||
title: {
|
||||
[Op.or]: filter.course.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
||||
[Op.or]: filter.owner.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
||||
}
|
||||
},
|
||||
]
|
||||
@ -336,13 +341,57 @@ module.exports = class EnrollmentsDBApi {
|
||||
}
|
||||
|
||||
|
||||
if (filter.enrollment_label) {
|
||||
if (filter.name) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'enrollments',
|
||||
'enrollment_label',
|
||||
filter.enrollment_label,
|
||||
'leads',
|
||||
'name',
|
||||
filter.name,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.company) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'leads',
|
||||
'company',
|
||||
filter.company,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.email) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'leads',
|
||||
'email',
|
||||
filter.email,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.phone) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'leads',
|
||||
'phone',
|
||||
filter.phone,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.notes) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'leads',
|
||||
'notes',
|
||||
filter.notes,
|
||||
),
|
||||
};
|
||||
}
|
||||
@ -352,14 +401,14 @@ module.exports = class EnrollmentsDBApi {
|
||||
|
||||
|
||||
|
||||
if (filter.enrolled_atRange) {
|
||||
const [start, end] = filter.enrolled_atRange;
|
||||
if (filter.estimated_valueRange) {
|
||||
const [start, end] = filter.estimated_valueRange;
|
||||
|
||||
if (start !== undefined && start !== null && start !== '') {
|
||||
where = {
|
||||
...where,
|
||||
enrolled_at: {
|
||||
...where.enrolled_at,
|
||||
estimated_value: {
|
||||
...where.estimated_value,
|
||||
[Op.gte]: start,
|
||||
},
|
||||
};
|
||||
@ -368,56 +417,8 @@ module.exports = class EnrollmentsDBApi {
|
||||
if (end !== undefined && end !== null && end !== '') {
|
||||
where = {
|
||||
...where,
|
||||
enrolled_at: {
|
||||
...where.enrolled_at,
|
||||
[Op.lte]: end,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (filter.progress_percentRange) {
|
||||
const [start, end] = filter.progress_percentRange;
|
||||
|
||||
if (start !== undefined && start !== null && start !== '') {
|
||||
where = {
|
||||
...where,
|
||||
progress_percent: {
|
||||
...where.progress_percent,
|
||||
[Op.gte]: start,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (end !== undefined && end !== null && end !== '') {
|
||||
where = {
|
||||
...where,
|
||||
progress_percent: {
|
||||
...where.progress_percent,
|
||||
[Op.lte]: end,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (filter.price_paidRange) {
|
||||
const [start, end] = filter.price_paidRange;
|
||||
|
||||
if (start !== undefined && start !== null && start !== '') {
|
||||
where = {
|
||||
...where,
|
||||
price_paid: {
|
||||
...where.price_paid,
|
||||
[Op.gte]: start,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (end !== undefined && end !== null && end !== '') {
|
||||
where = {
|
||||
...where,
|
||||
price_paid: {
|
||||
...where.price_paid,
|
||||
estimated_value: {
|
||||
...where.estimated_value,
|
||||
[Op.lte]: end,
|
||||
},
|
||||
};
|
||||
@ -433,6 +434,13 @@ module.exports = class EnrollmentsDBApi {
|
||||
}
|
||||
|
||||
|
||||
if (filter.source) {
|
||||
where = {
|
||||
...where,
|
||||
source: filter.source,
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.status) {
|
||||
where = {
|
||||
...where,
|
||||
@ -444,8 +452,6 @@ module.exports = class EnrollmentsDBApi {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (filter.createdAtRange) {
|
||||
@ -493,7 +499,7 @@ module.exports = class EnrollmentsDBApi {
|
||||
}
|
||||
|
||||
try {
|
||||
const { rows, count } = await db.enrollments.findAndCountAll(queryOptions);
|
||||
const { rows, count } = await db.leads.findAndCountAll(queryOptions);
|
||||
|
||||
return {
|
||||
rows: options?.countOnly ? [] : rows,
|
||||
@ -515,25 +521,25 @@ module.exports = class EnrollmentsDBApi {
|
||||
[Op.or]: [
|
||||
{ ['id']: Utils.uuid(query) },
|
||||
Utils.ilike(
|
||||
'enrollments',
|
||||
'enrollment_label',
|
||||
'leads',
|
||||
'name',
|
||||
query,
|
||||
),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const records = await db.enrollments.findAll({
|
||||
attributes: [ 'id', 'enrollment_label' ],
|
||||
const records = await db.leads.findAll({
|
||||
attributes: [ 'id', 'name' ],
|
||||
where,
|
||||
limit: limit ? Number(limit) : undefined,
|
||||
offset: offset ? Number(offset) : undefined,
|
||||
orderBy: [['enrollment_label', 'ASC']],
|
||||
orderBy: [['name', 'ASC']],
|
||||
});
|
||||
|
||||
return records.map((record) => ({
|
||||
id: record.id,
|
||||
label: record.enrollment_label,
|
||||
label: record.name,
|
||||
}));
|
||||
}
|
||||
|
||||
@ -172,6 +172,7 @@ module.exports = class PermissionsDBApi {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ const Utils = require('../utils');
|
||||
const Sequelize = db.Sequelize;
|
||||
const Op = Sequelize.Op;
|
||||
|
||||
module.exports = class CoursesDBApi {
|
||||
module.exports = class Pipeline_stagesDBApi {
|
||||
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ module.exports = class CoursesDBApi {
|
||||
const currentUser = (options && options.currentUser) || { id: null };
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const courses = await db.courses.create(
|
||||
const pipeline_stages = await db.pipeline_stages.create(
|
||||
{
|
||||
id: data.id || undefined,
|
||||
|
||||
@ -26,47 +26,22 @@ module.exports = class CoursesDBApi {
|
||||
null
|
||||
,
|
||||
|
||||
description: data.description
|
||||
order: data.order
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
category: data.category
|
||||
probability: data.probability
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
level: data.level
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
published: data.published
|
||||
is_default: data.is_default
|
||||
||
|
||||
false
|
||||
|
||||
,
|
||||
|
||||
start_date: data.start_date
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
end_date: data.end_date
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
price: data.price
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
language: data.language
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
importHash: data.importHash || null,
|
||||
createdById: currentUser.id,
|
||||
updatedById: currentUser.id,
|
||||
@ -75,26 +50,12 @@ module.exports = class CoursesDBApi {
|
||||
);
|
||||
|
||||
|
||||
await courses.setInstructor( data.instructor || null, {
|
||||
transaction,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
await FileDBApi.replaceRelationFiles(
|
||||
{
|
||||
belongsTo: db.courses.getTableName(),
|
||||
belongsToColumn: 'thumbnail',
|
||||
belongsToId: courses.id,
|
||||
},
|
||||
data.thumbnail,
|
||||
options,
|
||||
);
|
||||
|
||||
|
||||
return courses;
|
||||
return pipeline_stages;
|
||||
}
|
||||
|
||||
|
||||
@ -103,7 +64,7 @@ module.exports = class CoursesDBApi {
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
// Prepare data - wrapping individual data transformations in a map() method
|
||||
const coursesData = data.map((item, index) => ({
|
||||
const pipeline_stagesData = data.map((item, index) => ({
|
||||
id: item.id || undefined,
|
||||
|
||||
title: item.title
|
||||
@ -111,45 +72,20 @@ module.exports = class CoursesDBApi {
|
||||
null
|
||||
,
|
||||
|
||||
description: item.description
|
||||
order: item.order
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
category: item.category
|
||||
probability: item.probability
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
level: item.level
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
published: item.published
|
||||
is_default: item.is_default
|
||||
||
|
||||
false
|
||||
|
||||
,
|
||||
|
||||
start_date: item.start_date
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
end_date: item.end_date
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
price: item.price
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
language: item.language
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
importHash: item.importHash || null,
|
||||
@ -159,24 +95,12 @@ module.exports = class CoursesDBApi {
|
||||
}));
|
||||
|
||||
// Bulk create items
|
||||
const courses = await db.courses.bulkCreate(coursesData, { transaction });
|
||||
const pipeline_stages = await db.pipeline_stages.bulkCreate(pipeline_stagesData, { transaction });
|
||||
|
||||
// For each item created, replace relation files
|
||||
|
||||
for (let i = 0; i < courses.length; i++) {
|
||||
await FileDBApi.replaceRelationFiles(
|
||||
{
|
||||
belongsTo: db.courses.getTableName(),
|
||||
belongsToColumn: 'thumbnail',
|
||||
belongsToId: courses[i].id,
|
||||
},
|
||||
data[i].thumbnail,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return courses;
|
||||
return pipeline_stages;
|
||||
}
|
||||
|
||||
static async update(id, data, options) {
|
||||
@ -184,7 +108,7 @@ module.exports = class CoursesDBApi {
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
|
||||
const courses = await db.courses.findByPk(id, {}, {transaction});
|
||||
const pipeline_stages = await db.pipeline_stages.findByPk(id, {}, {transaction});
|
||||
|
||||
|
||||
|
||||
@ -194,69 +118,35 @@ module.exports = class CoursesDBApi {
|
||||
if (data.title !== undefined) updatePayload.title = data.title;
|
||||
|
||||
|
||||
if (data.description !== undefined) updatePayload.description = data.description;
|
||||
if (data.order !== undefined) updatePayload.order = data.order;
|
||||
|
||||
|
||||
if (data.category !== undefined) updatePayload.category = data.category;
|
||||
if (data.probability !== undefined) updatePayload.probability = data.probability;
|
||||
|
||||
|
||||
if (data.level !== undefined) updatePayload.level = data.level;
|
||||
|
||||
|
||||
if (data.published !== undefined) updatePayload.published = data.published;
|
||||
|
||||
|
||||
if (data.start_date !== undefined) updatePayload.start_date = data.start_date;
|
||||
|
||||
|
||||
if (data.end_date !== undefined) updatePayload.end_date = data.end_date;
|
||||
|
||||
|
||||
if (data.price !== undefined) updatePayload.price = data.price;
|
||||
|
||||
|
||||
if (data.language !== undefined) updatePayload.language = data.language;
|
||||
if (data.is_default !== undefined) updatePayload.is_default = data.is_default;
|
||||
|
||||
|
||||
updatePayload.updatedById = currentUser.id;
|
||||
|
||||
await courses.update(updatePayload, {transaction});
|
||||
await pipeline_stages.update(updatePayload, {transaction});
|
||||
|
||||
|
||||
|
||||
if (data.instructor !== undefined) {
|
||||
await courses.setInstructor(
|
||||
|
||||
data.instructor,
|
||||
|
||||
{ transaction }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
await FileDBApi.replaceRelationFiles(
|
||||
{
|
||||
belongsTo: db.courses.getTableName(),
|
||||
belongsToColumn: 'thumbnail',
|
||||
belongsToId: courses.id,
|
||||
},
|
||||
data.thumbnail,
|
||||
options,
|
||||
);
|
||||
|
||||
|
||||
return courses;
|
||||
return pipeline_stages;
|
||||
}
|
||||
|
||||
static async deleteByIds(ids, options) {
|
||||
const currentUser = (options && options.currentUser) || { id: null };
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const courses = await db.courses.findAll({
|
||||
const pipeline_stages = await db.pipeline_stages.findAll({
|
||||
where: {
|
||||
id: {
|
||||
[Op.in]: ids,
|
||||
@ -266,79 +156,66 @@ module.exports = class CoursesDBApi {
|
||||
});
|
||||
|
||||
await db.sequelize.transaction(async (transaction) => {
|
||||
for (const record of courses) {
|
||||
for (const record of pipeline_stages) {
|
||||
await record.update(
|
||||
{deletedBy: currentUser.id},
|
||||
{transaction}
|
||||
);
|
||||
}
|
||||
for (const record of courses) {
|
||||
for (const record of pipeline_stages) {
|
||||
await record.destroy({transaction});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return courses;
|
||||
return pipeline_stages;
|
||||
}
|
||||
|
||||
static async remove(id, options) {
|
||||
const currentUser = (options && options.currentUser) || {id: null};
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const courses = await db.courses.findByPk(id, options);
|
||||
const pipeline_stages = await db.pipeline_stages.findByPk(id, options);
|
||||
|
||||
await courses.update({
|
||||
await pipeline_stages.update({
|
||||
deletedBy: currentUser.id
|
||||
}, {
|
||||
transaction,
|
||||
});
|
||||
|
||||
await courses.destroy({
|
||||
await pipeline_stages.destroy({
|
||||
transaction
|
||||
});
|
||||
|
||||
return courses;
|
||||
return pipeline_stages;
|
||||
}
|
||||
|
||||
static async findBy(where, options) {
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const courses = await db.courses.findOne(
|
||||
const pipeline_stages = await db.pipeline_stages.findOne(
|
||||
{ where },
|
||||
{ transaction },
|
||||
);
|
||||
|
||||
if (!courses) {
|
||||
return courses;
|
||||
if (!pipeline_stages) {
|
||||
return pipeline_stages;
|
||||
}
|
||||
|
||||
const output = courses.get({plain: true});
|
||||
const output = pipeline_stages.get({plain: true});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
output.lessons_course = await courses.getLessons_course({
|
||||
|
||||
|
||||
output.deals_stage = await pipeline_stages.getDeals_stage({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
output.enrollments_course = await courses.getEnrollments_course({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
output.instructor = await courses.getInstructor({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
output.thumbnail = await courses.getThumbnail({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -366,30 +243,8 @@ module.exports = class CoursesDBApi {
|
||||
|
||||
let include = [
|
||||
|
||||
{
|
||||
model: db.users,
|
||||
as: 'instructor',
|
||||
|
||||
where: filter.instructor ? {
|
||||
[Op.or]: [
|
||||
{ id: { [Op.in]: filter.instructor.split('|').map(term => Utils.uuid(term)) } },
|
||||
{
|
||||
firstName: {
|
||||
[Op.or]: filter.instructor.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
||||
}
|
||||
},
|
||||
]
|
||||
} : {},
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
model: db.file,
|
||||
as: 'thumbnail',
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
if (filter) {
|
||||
@ -405,66 +260,26 @@ module.exports = class CoursesDBApi {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'courses',
|
||||
'pipeline_stages',
|
||||
'title',
|
||||
filter.title,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.description) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'courses',
|
||||
'description',
|
||||
filter.description,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.language) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'courses',
|
||||
'language',
|
||||
filter.language,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (filter.calendarStart && filter.calendarEnd) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.or]: [
|
||||
{
|
||||
start_date: {
|
||||
[Op.between]: [filter.calendarStart, filter.calendarEnd],
|
||||
},
|
||||
},
|
||||
{
|
||||
end_date: {
|
||||
[Op.between]: [filter.calendarStart, filter.calendarEnd],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (filter.start_dateRange) {
|
||||
const [start, end] = filter.start_dateRange;
|
||||
if (filter.orderRange) {
|
||||
const [start, end] = filter.orderRange;
|
||||
|
||||
if (start !== undefined && start !== null && start !== '') {
|
||||
where = {
|
||||
...where,
|
||||
start_date: {
|
||||
...where.start_date,
|
||||
order: {
|
||||
...where.order,
|
||||
[Op.gte]: start,
|
||||
},
|
||||
};
|
||||
@ -473,22 +288,22 @@ module.exports = class CoursesDBApi {
|
||||
if (end !== undefined && end !== null && end !== '') {
|
||||
where = {
|
||||
...where,
|
||||
start_date: {
|
||||
...where.start_date,
|
||||
order: {
|
||||
...where.order,
|
||||
[Op.lte]: end,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (filter.end_dateRange) {
|
||||
const [start, end] = filter.end_dateRange;
|
||||
if (filter.probabilityRange) {
|
||||
const [start, end] = filter.probabilityRange;
|
||||
|
||||
if (start !== undefined && start !== null && start !== '') {
|
||||
where = {
|
||||
...where,
|
||||
end_date: {
|
||||
...where.end_date,
|
||||
probability: {
|
||||
...where.probability,
|
||||
[Op.gte]: start,
|
||||
},
|
||||
};
|
||||
@ -497,32 +312,8 @@ module.exports = class CoursesDBApi {
|
||||
if (end !== undefined && end !== null && end !== '') {
|
||||
where = {
|
||||
...where,
|
||||
end_date: {
|
||||
...where.end_date,
|
||||
[Op.lte]: end,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (filter.priceRange) {
|
||||
const [start, end] = filter.priceRange;
|
||||
|
||||
if (start !== undefined && start !== null && start !== '') {
|
||||
where = {
|
||||
...where,
|
||||
price: {
|
||||
...where.price,
|
||||
[Op.gte]: start,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (end !== undefined && end !== null && end !== '') {
|
||||
where = {
|
||||
...where,
|
||||
price: {
|
||||
...where.price,
|
||||
probability: {
|
||||
...where.probability,
|
||||
[Op.lte]: end,
|
||||
},
|
||||
};
|
||||
@ -538,31 +329,15 @@ module.exports = class CoursesDBApi {
|
||||
}
|
||||
|
||||
|
||||
if (filter.category) {
|
||||
if (filter.is_default) {
|
||||
where = {
|
||||
...where,
|
||||
category: filter.category,
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.level) {
|
||||
where = {
|
||||
...where,
|
||||
level: filter.level,
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.published) {
|
||||
where = {
|
||||
...where,
|
||||
published: filter.published,
|
||||
is_default: filter.is_default,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (filter.createdAtRange) {
|
||||
@ -610,7 +385,7 @@ module.exports = class CoursesDBApi {
|
||||
}
|
||||
|
||||
try {
|
||||
const { rows, count } = await db.courses.findAndCountAll(queryOptions);
|
||||
const { rows, count } = await db.pipeline_stages.findAndCountAll(queryOptions);
|
||||
|
||||
return {
|
||||
rows: options?.countOnly ? [] : rows,
|
||||
@ -632,7 +407,7 @@ module.exports = class CoursesDBApi {
|
||||
[Op.or]: [
|
||||
{ ['id']: Utils.uuid(query) },
|
||||
Utils.ilike(
|
||||
'courses',
|
||||
'pipeline_stages',
|
||||
'title',
|
||||
query,
|
||||
),
|
||||
@ -640,7 +415,7 @@ module.exports = class CoursesDBApi {
|
||||
};
|
||||
}
|
||||
|
||||
const records = await db.courses.findAll({
|
||||
const records = await db.pipeline_stages.findAll({
|
||||
attributes: [ 'id', 'title' ],
|
||||
where,
|
||||
limit: limit ? Number(limit) : undefined,
|
||||
@ -197,6 +197,7 @@ module.exports = class RolesDBApi {
|
||||
|
||||
|
||||
|
||||
|
||||
output.permissions = await roles.getPermissions({
|
||||
transaction
|
||||
});
|
||||
|
||||
@ -403,17 +403,26 @@ module.exports = class UsersDBApi {
|
||||
|
||||
|
||||
|
||||
output.courses_instructor = await users.getCourses_instructor({
|
||||
|
||||
output.leads_owner = await users.getLeads_owner({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
|
||||
output.enrollments_student = await users.getEnrollments_student({
|
||||
output.contacts_owner = await users.getContacts_owner({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
output.deals_owner = await users.getDeals_owner({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
output.activities_owner = await users.getActivities_owner({
|
||||
transaction
|
||||
});
|
||||
|
||||
|
||||
|
||||
output.avatar = await users.getAvatar({
|
||||
|
||||
@ -15,7 +15,7 @@ module.exports = {
|
||||
username: 'postgres',
|
||||
dialect: 'postgres',
|
||||
password: '',
|
||||
database: 'db_instructor_student_lms',
|
||||
database: 'db_sales_pipeline_crm',
|
||||
host: process.env.DB_HOST || 'localhost',
|
||||
logging: console.log,
|
||||
seederStorage: 'sequelize',
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -5,8 +5,8 @@ const bcrypt = require('bcrypt');
|
||||
const moment = require('moment');
|
||||
|
||||
module.exports = function(sequelize, DataTypes) {
|
||||
const enrollments = sequelize.define(
|
||||
'enrollments',
|
||||
const activities = sequelize.define(
|
||||
'activities',
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
@ -14,48 +14,64 @@ module.exports = function(sequelize, DataTypes) {
|
||||
primaryKey: true,
|
||||
},
|
||||
|
||||
enrollment_label: {
|
||||
subject: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
enrolled_at: {
|
||||
type: DataTypes.DATE,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
status: {
|
||||
activity_type: {
|
||||
type: DataTypes.ENUM,
|
||||
|
||||
|
||||
|
||||
values: [
|
||||
|
||||
"active",
|
||||
"Call",
|
||||
|
||||
|
||||
"completed",
|
||||
"Meeting",
|
||||
|
||||
|
||||
"cancelled"
|
||||
"Email",
|
||||
|
||||
|
||||
"Task",
|
||||
|
||||
|
||||
"FollowUp"
|
||||
|
||||
],
|
||||
|
||||
},
|
||||
|
||||
progress_percent: {
|
||||
type: DataTypes.DECIMAL,
|
||||
start: {
|
||||
type: DataTypes.DATE,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
price_paid: {
|
||||
type: DataTypes.DECIMAL,
|
||||
end: {
|
||||
type: DataTypes.DATE,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
completed: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
|
||||
allowNull: false,
|
||||
defaultValue: false,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
notes: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
|
||||
@ -74,7 +90,7 @@ price_paid: {
|
||||
},
|
||||
);
|
||||
|
||||
enrollments.associate = (db) => {
|
||||
activities.associate = (db) => {
|
||||
|
||||
|
||||
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
||||
@ -86,13 +102,6 @@ price_paid: {
|
||||
|
||||
|
||||
|
||||
db.enrollments.hasMany(db.progress, {
|
||||
as: 'progress_enrollment',
|
||||
foreignKey: {
|
||||
name: 'enrollmentId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -100,18 +109,26 @@ price_paid: {
|
||||
|
||||
|
||||
|
||||
db.enrollments.belongsTo(db.users, {
|
||||
as: 'student',
|
||||
db.activities.belongsTo(db.users, {
|
||||
as: 'owner',
|
||||
foreignKey: {
|
||||
name: 'studentId',
|
||||
name: 'ownerId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
db.enrollments.belongsTo(db.courses, {
|
||||
as: 'course',
|
||||
db.activities.belongsTo(db.deals, {
|
||||
as: 'related_deal',
|
||||
foreignKey: {
|
||||
name: 'courseId',
|
||||
name: 'related_dealId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
db.activities.belongsTo(db.leads, {
|
||||
as: 'related_lead',
|
||||
foreignKey: {
|
||||
name: 'related_leadId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
@ -119,18 +136,18 @@ price_paid: {
|
||||
|
||||
|
||||
|
||||
db.enrollments.belongsTo(db.users, {
|
||||
db.activities.belongsTo(db.users, {
|
||||
as: 'createdBy',
|
||||
});
|
||||
|
||||
db.enrollments.belongsTo(db.users, {
|
||||
db.activities.belongsTo(db.users, {
|
||||
as: 'updatedBy',
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
return enrollments;
|
||||
return activities;
|
||||
};
|
||||
|
||||
|
||||
124
backend/src/db/models/contacts.js
Normal file
124
backend/src/db/models/contacts.js
Normal file
@ -0,0 +1,124 @@
|
||||
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 contacts = sequelize.define(
|
||||
'contacts',
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
primaryKey: true,
|
||||
},
|
||||
|
||||
name: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
email: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
phone: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
title: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
company: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
notes: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
importHash: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: true,
|
||||
unique: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
paranoid: true,
|
||||
freezeTableName: true,
|
||||
},
|
||||
);
|
||||
|
||||
contacts.associate = (db) => {
|
||||
|
||||
|
||||
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
db.contacts.hasMany(db.deals, {
|
||||
as: 'deals_primary_contact',
|
||||
foreignKey: {
|
||||
name: 'primary_contactId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
//end loop
|
||||
|
||||
|
||||
|
||||
db.contacts.belongsTo(db.users, {
|
||||
as: 'owner',
|
||||
foreignKey: {
|
||||
name: 'ownerId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
db.contacts.belongsTo(db.users, {
|
||||
as: 'createdBy',
|
||||
});
|
||||
|
||||
db.contacts.belongsTo(db.users, {
|
||||
as: 'updatedBy',
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
return contacts;
|
||||
};
|
||||
|
||||
|
||||
@ -5,8 +5,8 @@ const bcrypt = require('bcrypt');
|
||||
const moment = require('moment');
|
||||
|
||||
module.exports = function(sequelize, DataTypes) {
|
||||
const lessons = sequelize.define(
|
||||
'lessons',
|
||||
const deals = sequelize.define(
|
||||
'deals',
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
@ -21,29 +21,22 @@ title: {
|
||||
|
||||
},
|
||||
|
||||
content: {
|
||||
deal_number: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
order: {
|
||||
type: DataTypes.INTEGER,
|
||||
value: {
|
||||
type: DataTypes.DECIMAL,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
duration_minutes: {
|
||||
type: DataTypes.INTEGER,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
release_date: {
|
||||
type: DataTypes.DATE,
|
||||
currency: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
|
||||
@ -56,18 +49,32 @@ status: {
|
||||
|
||||
values: [
|
||||
|
||||
"draft",
|
||||
"Open",
|
||||
|
||||
|
||||
"published",
|
||||
"Won",
|
||||
|
||||
|
||||
"archived"
|
||||
"Lost"
|
||||
|
||||
],
|
||||
|
||||
},
|
||||
|
||||
close_date: {
|
||||
type: DataTypes.DATE,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
description: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
importHash: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: true,
|
||||
@ -81,7 +88,7 @@ status: {
|
||||
},
|
||||
);
|
||||
|
||||
lessons.associate = (db) => {
|
||||
deals.associate = (db) => {
|
||||
|
||||
|
||||
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
||||
@ -93,10 +100,11 @@ status: {
|
||||
|
||||
|
||||
|
||||
db.lessons.hasMany(db.progress, {
|
||||
as: 'progress_lesson',
|
||||
|
||||
db.deals.hasMany(db.activities, {
|
||||
as: 'activities_related_deal',
|
||||
foreignKey: {
|
||||
name: 'lessonId',
|
||||
name: 'related_dealId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
@ -107,49 +115,45 @@ status: {
|
||||
|
||||
|
||||
|
||||
db.lessons.belongsTo(db.courses, {
|
||||
as: 'course',
|
||||
db.deals.belongsTo(db.pipeline_stages, {
|
||||
as: 'stage',
|
||||
foreignKey: {
|
||||
name: 'courseId',
|
||||
name: 'stageId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
db.deals.belongsTo(db.users, {
|
||||
as: 'owner',
|
||||
foreignKey: {
|
||||
name: 'ownerId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
db.deals.belongsTo(db.contacts, {
|
||||
as: 'primary_contact',
|
||||
foreignKey: {
|
||||
name: 'primary_contactId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
|
||||
|
||||
db.lessons.hasMany(db.file, {
|
||||
as: 'video_files',
|
||||
foreignKey: 'belongsToId',
|
||||
constraints: false,
|
||||
scope: {
|
||||
belongsTo: db.lessons.getTableName(),
|
||||
belongsToColumn: 'video_files',
|
||||
},
|
||||
});
|
||||
|
||||
db.lessons.hasMany(db.file, {
|
||||
as: 'resources',
|
||||
foreignKey: 'belongsToId',
|
||||
constraints: false,
|
||||
scope: {
|
||||
belongsTo: db.lessons.getTableName(),
|
||||
belongsToColumn: 'resources',
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
db.lessons.belongsTo(db.users, {
|
||||
db.deals.belongsTo(db.users, {
|
||||
as: 'createdBy',
|
||||
});
|
||||
|
||||
db.lessons.belongsTo(db.users, {
|
||||
db.deals.belongsTo(db.users, {
|
||||
as: 'updatedBy',
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
return lessons;
|
||||
return deals;
|
||||
};
|
||||
|
||||
|
||||
@ -5,8 +5,8 @@ const bcrypt = require('bcrypt');
|
||||
const moment = require('moment');
|
||||
|
||||
module.exports = function(sequelize, DataTypes) {
|
||||
const courses = sequelize.define(
|
||||
'courses',
|
||||
const leads = sequelize.define(
|
||||
'leads',
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
@ -14,99 +14,89 @@ module.exports = function(sequelize, DataTypes) {
|
||||
primaryKey: true,
|
||||
},
|
||||
|
||||
title: {
|
||||
name: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
description: {
|
||||
company: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
category: {
|
||||
email: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
phone: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
source: {
|
||||
type: DataTypes.ENUM,
|
||||
|
||||
|
||||
|
||||
values: [
|
||||
|
||||
"Programming",
|
||||
"Website",
|
||||
|
||||
|
||||
"Design",
|
||||
"Referral",
|
||||
|
||||
|
||||
"Math",
|
||||
"Email",
|
||||
|
||||
|
||||
"Language",
|
||||
"ColdCall",
|
||||
|
||||
|
||||
"Business",
|
||||
|
||||
|
||||
"Other"
|
||||
"SocialMedia"
|
||||
|
||||
],
|
||||
|
||||
},
|
||||
|
||||
level: {
|
||||
status: {
|
||||
type: DataTypes.ENUM,
|
||||
|
||||
|
||||
|
||||
values: [
|
||||
|
||||
"Beginner",
|
||||
"New",
|
||||
|
||||
|
||||
"Intermediate",
|
||||
"Contacted",
|
||||
|
||||
|
||||
"Advanced"
|
||||
"Qualified",
|
||||
|
||||
|
||||
"Unqualified"
|
||||
|
||||
],
|
||||
|
||||
},
|
||||
|
||||
published: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
|
||||
allowNull: false,
|
||||
defaultValue: false,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
start_date: {
|
||||
type: DataTypes.DATE,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
end_date: {
|
||||
type: DataTypes.DATE,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
price: {
|
||||
estimated_value: {
|
||||
type: DataTypes.DECIMAL,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
language: {
|
||||
notes: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
@ -126,7 +116,7 @@ language: {
|
||||
},
|
||||
);
|
||||
|
||||
courses.associate = (db) => {
|
||||
leads.associate = (db) => {
|
||||
|
||||
|
||||
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
||||
@ -136,63 +126,46 @@ language: {
|
||||
|
||||
|
||||
|
||||
db.courses.hasMany(db.lessons, {
|
||||
as: 'lessons_course',
|
||||
|
||||
|
||||
|
||||
db.leads.hasMany(db.activities, {
|
||||
as: 'activities_related_lead',
|
||||
foreignKey: {
|
||||
name: 'courseId',
|
||||
name: 'related_leadId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
|
||||
db.courses.hasMany(db.enrollments, {
|
||||
as: 'enrollments_course',
|
||||
foreignKey: {
|
||||
name: 'courseId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
//end loop
|
||||
|
||||
|
||||
|
||||
db.courses.belongsTo(db.users, {
|
||||
as: 'instructor',
|
||||
db.leads.belongsTo(db.users, {
|
||||
as: 'owner',
|
||||
foreignKey: {
|
||||
name: 'instructorId',
|
||||
name: 'ownerId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
|
||||
|
||||
db.courses.hasMany(db.file, {
|
||||
as: 'thumbnail',
|
||||
foreignKey: 'belongsToId',
|
||||
constraints: false,
|
||||
scope: {
|
||||
belongsTo: db.courses.getTableName(),
|
||||
belongsToColumn: 'thumbnail',
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
db.courses.belongsTo(db.users, {
|
||||
db.leads.belongsTo(db.users, {
|
||||
as: 'createdBy',
|
||||
});
|
||||
|
||||
db.courses.belongsTo(db.users, {
|
||||
db.leads.belongsTo(db.users, {
|
||||
as: 'updatedBy',
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
return courses;
|
||||
return leads;
|
||||
};
|
||||
|
||||
|
||||
@ -48,6 +48,7 @@ name: {
|
||||
|
||||
|
||||
|
||||
|
||||
//end loop
|
||||
|
||||
|
||||
|
||||
@ -5,8 +5,8 @@ const bcrypt = require('bcrypt');
|
||||
const moment = require('moment');
|
||||
|
||||
module.exports = function(sequelize, DataTypes) {
|
||||
const progress = sequelize.define(
|
||||
'progress',
|
||||
const pipeline_stages = sequelize.define(
|
||||
'pipeline_stages',
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
@ -14,14 +14,28 @@ module.exports = function(sequelize, DataTypes) {
|
||||
primaryKey: true,
|
||||
},
|
||||
|
||||
note: {
|
||||
title: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
completed: {
|
||||
order: {
|
||||
type: DataTypes.INTEGER,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
probability: {
|
||||
type: DataTypes.INTEGER,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
is_default: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
|
||||
allowNull: false,
|
||||
@ -29,27 +43,6 @@ completed: {
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
completed_at: {
|
||||
type: DataTypes.DATE,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
score: {
|
||||
type: DataTypes.DECIMAL,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
attempts: {
|
||||
type: DataTypes.INTEGER,
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
importHash: {
|
||||
@ -65,7 +58,7 @@ attempts: {
|
||||
},
|
||||
);
|
||||
|
||||
progress.associate = (db) => {
|
||||
pipeline_stages.associate = (db) => {
|
||||
|
||||
|
||||
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
||||
@ -77,43 +70,36 @@ attempts: {
|
||||
|
||||
|
||||
|
||||
db.pipeline_stages.hasMany(db.deals, {
|
||||
as: 'deals_stage',
|
||||
foreignKey: {
|
||||
name: 'stageId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
//end loop
|
||||
|
||||
|
||||
|
||||
db.progress.belongsTo(db.enrollments, {
|
||||
as: 'enrollment',
|
||||
foreignKey: {
|
||||
name: 'enrollmentId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
db.progress.belongsTo(db.lessons, {
|
||||
as: 'lesson',
|
||||
foreignKey: {
|
||||
name: 'lessonId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
db.progress.belongsTo(db.users, {
|
||||
db.pipeline_stages.belongsTo(db.users, {
|
||||
as: 'createdBy',
|
||||
});
|
||||
|
||||
db.progress.belongsTo(db.users, {
|
||||
db.pipeline_stages.belongsTo(db.users, {
|
||||
as: 'updatedBy',
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
return progress;
|
||||
return pipeline_stages;
|
||||
};
|
||||
|
||||
|
||||
@ -81,6 +81,7 @@ role_customization: {
|
||||
|
||||
|
||||
|
||||
|
||||
//end loop
|
||||
|
||||
|
||||
|
||||
@ -144,25 +144,42 @@ provider: {
|
||||
|
||||
|
||||
|
||||
db.users.hasMany(db.courses, {
|
||||
as: 'courses_instructor',
|
||||
|
||||
db.users.hasMany(db.leads, {
|
||||
as: 'leads_owner',
|
||||
foreignKey: {
|
||||
name: 'instructorId',
|
||||
name: 'ownerId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
|
||||
|
||||
db.users.hasMany(db.enrollments, {
|
||||
as: 'enrollments_student',
|
||||
db.users.hasMany(db.contacts, {
|
||||
as: 'contacts_owner',
|
||||
foreignKey: {
|
||||
name: 'studentId',
|
||||
name: 'ownerId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
|
||||
db.users.hasMany(db.deals, {
|
||||
as: 'deals_owner',
|
||||
foreignKey: {
|
||||
name: 'ownerId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
|
||||
db.users.hasMany(db.activities, {
|
||||
as: 'activities_owner',
|
||||
foreignKey: {
|
||||
name: 'ownerId',
|
||||
},
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
|
||||
|
||||
//end loop
|
||||
|
||||
@ -33,15 +33,15 @@ module.exports = {
|
||||
|
||||
|
||||
|
||||
{ id: getId("PlatformManager"), name: "Platform Manager", createdAt, updatedAt },
|
||||
{ id: getId("OrganizationOwner"), name: "Organization Owner", createdAt, updatedAt },
|
||||
|
||||
{ id: getId("InstructorLead"), name: "Instructor Lead", createdAt, updatedAt },
|
||||
{ id: getId("SalesManager"), name: "Sales Manager", createdAt, updatedAt },
|
||||
|
||||
{ id: getId("Instructor"), name: "Instructor", createdAt, updatedAt },
|
||||
{ id: getId("SeniorSalesRep"), name: "Senior Sales Rep", createdAt, updatedAt },
|
||||
|
||||
{ id: getId("TeachingAssistant"), name: "Teaching Assistant", createdAt, updatedAt },
|
||||
{ id: getId("SalesRep"), name: "Sales Rep", createdAt, updatedAt },
|
||||
|
||||
{ id: getId("Student"), name: "Student", createdAt, updatedAt },
|
||||
{ id: getId("SupportSpecialist"), name: "Support Specialist", createdAt, updatedAt },
|
||||
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
const entities = [
|
||||
"users","roles","permissions","courses","lessons","enrollments","progress",,
|
||||
"users","roles","permissions","pipeline_stages","leads","contacts","deals","activities",,
|
||||
];
|
||||
await queryInterface.bulkInsert("permissions", entities.flatMap(createPermissions));
|
||||
await queryInterface.bulkInsert("permissions", [{ id: getId(`READ_API_DOCS`), createdAt, updatedAt, name: `READ_API_DOCS` }]);
|
||||
@ -90,19 +90,19 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('CREATE_USERS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('CREATE_USERS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('READ_USERS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('READ_USERS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('UPDATE_USERS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('UPDATE_USERS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('DELETE_USERS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('DELETE_USERS') },
|
||||
|
||||
|
||||
|
||||
@ -111,11 +111,11 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('CREATE_USERS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('CREATE_USERS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('READ_USERS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('READ_USERS') },
|
||||
|
||||
|
||||
|
||||
@ -130,7 +130,7 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_USERS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('READ_USERS') },
|
||||
|
||||
|
||||
|
||||
@ -145,7 +145,7 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("TeachingAssistant"), permissionId: getId('READ_USERS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('READ_USERS') },
|
||||
|
||||
|
||||
|
||||
@ -160,7 +160,7 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Student"), permissionId: getId('READ_USERS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('READ_USERS') },
|
||||
|
||||
|
||||
|
||||
@ -185,19 +185,19 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('CREATE_COURSES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('CREATE_PIPELINE_STAGES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('READ_COURSES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('READ_PIPELINE_STAGES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('UPDATE_COURSES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('UPDATE_PIPELINE_STAGES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('DELETE_COURSES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('DELETE_PIPELINE_STAGES') },
|
||||
|
||||
|
||||
|
||||
@ -206,38 +206,19 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('CREATE_COURSES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('CREATE_PIPELINE_STAGES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('READ_COURSES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('READ_PIPELINE_STAGES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('UPDATE_COURSES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('UPDATE_PIPELINE_STAGES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('DELETE_COURSES') },
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('CREATE_COURSES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_COURSES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_COURSES') },
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('DELETE_PIPELINE_STAGES') },
|
||||
|
||||
|
||||
|
||||
@ -248,7 +229,7 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("TeachingAssistant"), permissionId: getId('READ_COURSES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('READ_PIPELINE_STAGES') },
|
||||
|
||||
|
||||
|
||||
@ -263,7 +244,22 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Student"), permissionId: getId('READ_COURSES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('READ_PIPELINE_STAGES') },
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('READ_PIPELINE_STAGES') },
|
||||
|
||||
|
||||
|
||||
@ -286,19 +282,19 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('CREATE_LESSONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('CREATE_LEADS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('READ_LESSONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('READ_LEADS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('UPDATE_LESSONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('UPDATE_LEADS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('DELETE_LESSONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('DELETE_LEADS') },
|
||||
|
||||
|
||||
|
||||
@ -307,19 +303,19 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('CREATE_LESSONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('CREATE_LEADS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('READ_LESSONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('READ_LEADS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('UPDATE_LESSONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('UPDATE_LEADS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('DELETE_LESSONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('DELETE_LEADS') },
|
||||
|
||||
|
||||
|
||||
@ -328,15 +324,34 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('CREATE_LESSONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('CREATE_LEADS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_LESSONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('READ_LEADS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_LESSONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('UPDATE_LEADS') },
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('CREATE_LEADS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('READ_LEADS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('UPDATE_LEADS') },
|
||||
|
||||
|
||||
|
||||
@ -349,24 +364,7 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("TeachingAssistant"), permissionId: getId('READ_LESSONS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("TeachingAssistant"), permissionId: getId('UPDATE_LESSONS') },
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Student"), permissionId: getId('READ_LESSONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('READ_LEADS') },
|
||||
|
||||
|
||||
|
||||
@ -389,19 +387,19 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('CREATE_ENROLLMENTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('CREATE_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('READ_ENROLLMENTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('READ_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('UPDATE_ENROLLMENTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('UPDATE_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('DELETE_ENROLLMENTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('DELETE_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
@ -410,19 +408,19 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('CREATE_ENROLLMENTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('CREATE_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('READ_ENROLLMENTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('READ_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('UPDATE_ENROLLMENTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('UPDATE_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('DELETE_ENROLLMENTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('DELETE_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
@ -431,13 +429,141 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_ENROLLMENTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('CREATE_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_ENROLLMENTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('READ_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('UPDATE_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('CREATE_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('READ_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('UPDATE_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('CREATE_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('READ_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('UPDATE_CONTACTS') },
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('CREATE_DEALS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('READ_DEALS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('UPDATE_DEALS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('DELETE_DEALS') },
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('CREATE_DEALS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('READ_DEALS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('UPDATE_DEALS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('DELETE_DEALS') },
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('CREATE_DEALS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('READ_DEALS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('UPDATE_DEALS') },
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('CREATE_DEALS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('READ_DEALS') },
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -450,24 +576,7 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("TeachingAssistant"), permissionId: getId('READ_ENROLLMENTS') },
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Student"), permissionId: getId('CREATE_ENROLLMENTS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Student"), permissionId: getId('READ_ENROLLMENTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('READ_DEALS') },
|
||||
|
||||
|
||||
|
||||
@ -490,19 +599,19 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('CREATE_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('CREATE_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('READ_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('READ_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('UPDATE_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('UPDATE_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('DELETE_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('DELETE_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
@ -511,19 +620,19 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('CREATE_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('CREATE_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('READ_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('READ_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('UPDATE_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('UPDATE_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('DELETE_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('DELETE_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
@ -532,34 +641,15 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('CREATE_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('CREATE_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('READ_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_PROGRESS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('DELETE_PROGRESS') },
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("TeachingAssistant"), permissionId: getId('READ_PROGRESS') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("TeachingAssistant"), permissionId: getId('UPDATE_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('UPDATE_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
@ -570,15 +660,38 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Student"), permissionId: getId('CREATE_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('CREATE_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Student"), permissionId: getId('READ_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('READ_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('UPDATE_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('CREATE_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('READ_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('UPDATE_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('DELETE_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
@ -592,15 +705,15 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('CREATE_SEARCH') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('CREATE_SEARCH') },
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('CREATE_SEARCH') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('CREATE_SEARCH') },
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('CREATE_SEARCH') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('CREATE_SEARCH') },
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("TeachingAssistant"), permissionId: getId('CREATE_SEARCH') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('CREATE_SEARCH') },
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Student"), permissionId: getId('CREATE_SEARCH') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('CREATE_SEARCH') },
|
||||
|
||||
|
||||
|
||||
@ -620,25 +733,30 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_PERMISSIONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_PERMISSIONS') },
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_COURSES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_COURSES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_COURSES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_COURSES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_PIPELINE_STAGES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_PIPELINE_STAGES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_PIPELINE_STAGES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_PIPELINE_STAGES') },
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_LESSONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_LESSONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_LESSONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_LESSONS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_LEADS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_LEADS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_LEADS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_LEADS') },
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_ENROLLMENTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_ENROLLMENTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_ENROLLMENTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_ENROLLMENTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_CONTACTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_CONTACTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_CONTACTS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_CONTACTS') },
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_PROGRESS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_DEALS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_DEALS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_DEALS') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_DEALS') },
|
||||
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_ACTIVITIES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_ACTIVITIES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_ACTIVITIES') },
|
||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_ACTIVITIES') },
|
||||
|
||||
|
||||
|
||||
@ -655,8 +773,8 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
||||
|
||||
|
||||
|
||||
await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("PlatformManager")}' WHERE "email"='client@hello.com'`);
|
||||
await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("InstructorLead")}' WHERE "email"='john@doe.com'`);
|
||||
await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("OrganizationOwner")}' WHERE "email"='client@hello.com'`);
|
||||
await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("SalesManager")}' WHERE "email"='john@doe.com'`);
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -14,6 +14,7 @@ const swaggerJsDoc = require('swagger-jsdoc');
|
||||
const authRoutes = require('./routes/auth');
|
||||
const fileRoutes = require('./routes/file');
|
||||
const searchRoutes = require('./routes/search');
|
||||
const sqlRoutes = require('./routes/sql');
|
||||
const pexelsRoutes = require('./routes/pexels');
|
||||
|
||||
const openaiRoutes = require('./routes/openai');
|
||||
@ -26,13 +27,15 @@ const rolesRoutes = require('./routes/roles');
|
||||
|
||||
const permissionsRoutes = require('./routes/permissions');
|
||||
|
||||
const coursesRoutes = require('./routes/courses');
|
||||
const pipeline_stagesRoutes = require('./routes/pipeline_stages');
|
||||
|
||||
const lessonsRoutes = require('./routes/lessons');
|
||||
const leadsRoutes = require('./routes/leads');
|
||||
|
||||
const enrollmentsRoutes = require('./routes/enrollments');
|
||||
const contactsRoutes = require('./routes/contacts');
|
||||
|
||||
const progressRoutes = require('./routes/progress');
|
||||
const dealsRoutes = require('./routes/deals');
|
||||
|
||||
const activitiesRoutes = require('./routes/activities');
|
||||
|
||||
|
||||
const getBaseUrl = (url) => {
|
||||
@ -45,8 +48,8 @@ const options = {
|
||||
openapi: "3.0.0",
|
||||
info: {
|
||||
version: "1.0.0",
|
||||
title: "Instructor-Student LMS",
|
||||
description: "Instructor-Student LMS Online REST API for Testing and Prototyping application. You can perform all major operations with your entities - create, delete and etc.",
|
||||
title: "Sales Pipeline CRM",
|
||||
description: "Sales Pipeline CRM Online REST API for Testing and Prototyping application. You can perform all major operations with your entities - create, delete and etc.",
|
||||
},
|
||||
servers: [
|
||||
{
|
||||
@ -98,13 +101,15 @@ app.use('/api/roles', passport.authenticate('jwt', {session: false}), rolesRoute
|
||||
|
||||
app.use('/api/permissions', passport.authenticate('jwt', {session: false}), permissionsRoutes);
|
||||
|
||||
app.use('/api/courses', passport.authenticate('jwt', {session: false}), coursesRoutes);
|
||||
app.use('/api/pipeline_stages', passport.authenticate('jwt', {session: false}), pipeline_stagesRoutes);
|
||||
|
||||
app.use('/api/lessons', passport.authenticate('jwt', {session: false}), lessonsRoutes);
|
||||
app.use('/api/leads', passport.authenticate('jwt', {session: false}), leadsRoutes);
|
||||
|
||||
app.use('/api/enrollments', passport.authenticate('jwt', {session: false}), enrollmentsRoutes);
|
||||
app.use('/api/contacts', passport.authenticate('jwt', {session: false}), contactsRoutes);
|
||||
|
||||
app.use('/api/progress', passport.authenticate('jwt', {session: false}), progressRoutes);
|
||||
app.use('/api/deals', passport.authenticate('jwt', {session: false}), dealsRoutes);
|
||||
|
||||
app.use('/api/activities', passport.authenticate('jwt', {session: false}), activitiesRoutes);
|
||||
|
||||
app.use(
|
||||
'/api/openai',
|
||||
@ -121,6 +126,10 @@ app.use(
|
||||
'/api/search',
|
||||
passport.authenticate('jwt', { session: false }),
|
||||
searchRoutes);
|
||||
app.use(
|
||||
'/api/sql',
|
||||
passport.authenticate('jwt', { session: false }),
|
||||
sqlRoutes);
|
||||
|
||||
|
||||
const publicDir = path.join(
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
|
||||
const express = require('express');
|
||||
|
||||
const LessonsService = require('../services/lessons');
|
||||
const LessonsDBApi = require('../db/api/lessons');
|
||||
const ActivitiesService = require('../services/activities');
|
||||
const ActivitiesDBApi = require('../db/api/activities');
|
||||
const wrapAsync = require('../helpers').wrapAsync;
|
||||
|
||||
|
||||
@ -15,30 +15,24 @@ const {
|
||||
checkCrudPermissions,
|
||||
} = require('../middlewares/check-permissions');
|
||||
|
||||
router.use(checkCrudPermissions('lessons'));
|
||||
router.use(checkCrudPermissions('activities'));
|
||||
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* components:
|
||||
* schemas:
|
||||
* Lessons:
|
||||
* Activities:
|
||||
* type: object
|
||||
* properties:
|
||||
|
||||
* title:
|
||||
* subject:
|
||||
* type: string
|
||||
* default: title
|
||||
* content:
|
||||
* default: subject
|
||||
* notes:
|
||||
* type: string
|
||||
* default: content
|
||||
* default: notes
|
||||
|
||||
* order:
|
||||
* type: integer
|
||||
* format: int64
|
||||
* duration_minutes:
|
||||
* type: integer
|
||||
* format: int64
|
||||
|
||||
|
||||
*
|
||||
@ -47,17 +41,17 @@ router.use(checkCrudPermissions('lessons'));
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Lessons
|
||||
* description: The Lessons managing API
|
||||
* name: Activities
|
||||
* description: The Activities managing API
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/lessons:
|
||||
* /api/activities:
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Lessons]
|
||||
* tags: [Activities]
|
||||
* summary: Add new item
|
||||
* description: Add new item
|
||||
* requestBody:
|
||||
@ -69,14 +63,14 @@ router.use(checkCrudPermissions('lessons'));
|
||||
* data:
|
||||
* description: Data of the updated item
|
||||
* type: object
|
||||
* $ref: "#/components/schemas/Lessons"
|
||||
* $ref: "#/components/schemas/Activities"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: The item was successfully added
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Lessons"
|
||||
* $ref: "#/components/schemas/Activities"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 405:
|
||||
@ -87,7 +81,7 @@ router.use(checkCrudPermissions('lessons'));
|
||||
router.post('/', wrapAsync(async (req, res) => {
|
||||
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
||||
const link = new URL(referer);
|
||||
await LessonsService.create(req.body.data, req.currentUser, true, link.host);
|
||||
await ActivitiesService.create(req.body.data, req.currentUser, true, link.host);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
@ -98,7 +92,7 @@ router.post('/', wrapAsync(async (req, res) => {
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Lessons]
|
||||
* tags: [Activities]
|
||||
* summary: Bulk import items
|
||||
* description: Bulk import items
|
||||
* requestBody:
|
||||
@ -111,14 +105,14 @@ router.post('/', wrapAsync(async (req, res) => {
|
||||
* description: Data of the updated items
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Lessons"
|
||||
* $ref: "#/components/schemas/Activities"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: The items were successfully imported
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Lessons"
|
||||
* $ref: "#/components/schemas/Activities"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 405:
|
||||
@ -130,18 +124,18 @@ router.post('/', wrapAsync(async (req, res) => {
|
||||
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 LessonsService.bulkImport(req, res, true, link.host);
|
||||
await ActivitiesService.bulkImport(req, res, true, link.host);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/lessons/{id}:
|
||||
* /api/activities/{id}:
|
||||
* put:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Lessons]
|
||||
* tags: [Activities]
|
||||
* summary: Update the data of the selected item
|
||||
* description: Update the data of the selected item
|
||||
* parameters:
|
||||
@ -164,7 +158,7 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||
* data:
|
||||
* description: Data of the updated item
|
||||
* type: object
|
||||
* $ref: "#/components/schemas/Lessons"
|
||||
* $ref: "#/components/schemas/Activities"
|
||||
* required:
|
||||
* - id
|
||||
* responses:
|
||||
@ -173,7 +167,7 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Lessons"
|
||||
* $ref: "#/components/schemas/Activities"
|
||||
* 400:
|
||||
* description: Invalid ID supplied
|
||||
* 401:
|
||||
@ -184,18 +178,18 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.put('/:id', wrapAsync(async (req, res) => {
|
||||
await LessonsService.update(req.body.data, req.body.id, req.currentUser);
|
||||
await ActivitiesService.update(req.body.data, req.body.id, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/lessons/{id}:
|
||||
* /api/activities/{id}:
|
||||
* delete:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Lessons]
|
||||
* tags: [Activities]
|
||||
* summary: Delete the selected item
|
||||
* description: Delete the selected item
|
||||
* parameters:
|
||||
@ -211,7 +205,7 @@ router.put('/:id', wrapAsync(async (req, res) => {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Lessons"
|
||||
* $ref: "#/components/schemas/Activities"
|
||||
* 400:
|
||||
* description: Invalid ID supplied
|
||||
* 401:
|
||||
@ -222,18 +216,18 @@ router.put('/:id', wrapAsync(async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.delete('/:id', wrapAsync(async (req, res) => {
|
||||
await LessonsService.remove(req.params.id, req.currentUser);
|
||||
await ActivitiesService.remove(req.params.id, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/lessons/deleteByIds:
|
||||
* /api/activities/deleteByIds:
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Lessons]
|
||||
* tags: [Activities]
|
||||
* summary: Delete the selected item list
|
||||
* description: Delete the selected item list
|
||||
* requestBody:
|
||||
@ -251,7 +245,7 @@ router.delete('/:id', wrapAsync(async (req, res) => {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Lessons"
|
||||
* $ref: "#/components/schemas/Activities"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
@ -260,29 +254,29 @@ router.delete('/:id', wrapAsync(async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.post('/deleteByIds', wrapAsync(async (req, res) => {
|
||||
await LessonsService.deleteByIds(req.body.data, req.currentUser);
|
||||
await ActivitiesService.deleteByIds(req.body.data, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/lessons:
|
||||
* /api/activities:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Lessons]
|
||||
* summary: Get all lessons
|
||||
* description: Get all lessons
|
||||
* tags: [Activities]
|
||||
* summary: Get all activities
|
||||
* description: Get all activities
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Lessons list successfully received
|
||||
* description: Activities list successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Lessons"
|
||||
* $ref: "#/components/schemas/Activities"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
@ -294,14 +288,14 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
const filetype = req.query.filetype
|
||||
|
||||
const currentUser = req.currentUser;
|
||||
const payload = await LessonsDBApi.findAll(
|
||||
const payload = await ActivitiesDBApi.findAll(
|
||||
req.query, { currentUser }
|
||||
);
|
||||
if (filetype && filetype === 'csv') {
|
||||
const fields = ['id','title','content',
|
||||
'order','duration_minutes',
|
||||
const fields = ['id','subject','notes',
|
||||
|
||||
'release_date',
|
||||
|
||||
'start','end',
|
||||
];
|
||||
const opts = { fields };
|
||||
try {
|
||||
@ -320,22 +314,22 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/lessons/count:
|
||||
* /api/activities/count:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Lessons]
|
||||
* summary: Count all lessons
|
||||
* description: Count all lessons
|
||||
* tags: [Activities]
|
||||
* summary: Count all activities
|
||||
* description: Count all activities
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Lessons count successfully received
|
||||
* description: Activities count successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Lessons"
|
||||
* $ref: "#/components/schemas/Activities"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
@ -346,7 +340,7 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
router.get('/count', wrapAsync(async (req, res) => {
|
||||
|
||||
const currentUser = req.currentUser;
|
||||
const payload = await LessonsDBApi.findAll(
|
||||
const payload = await ActivitiesDBApi.findAll(
|
||||
req.query,
|
||||
null,
|
||||
{ countOnly: true, currentUser }
|
||||
@ -357,22 +351,22 @@ router.get('/count', wrapAsync(async (req, res) => {
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/lessons/autocomplete:
|
||||
* /api/activities/autocomplete:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Lessons]
|
||||
* summary: Find all lessons that match search criteria
|
||||
* description: Find all lessons that match search criteria
|
||||
* tags: [Activities]
|
||||
* summary: Find all activities that match search criteria
|
||||
* description: Find all activities that match search criteria
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Lessons list successfully received
|
||||
* description: Activities list successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Lessons"
|
||||
* $ref: "#/components/schemas/Activities"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
@ -382,7 +376,7 @@ router.get('/count', wrapAsync(async (req, res) => {
|
||||
*/
|
||||
router.get('/autocomplete', async (req, res) => {
|
||||
|
||||
const payload = await LessonsDBApi.findAllAutocomplete(
|
||||
const payload = await ActivitiesDBApi.findAllAutocomplete(
|
||||
req.query.query,
|
||||
req.query.limit,
|
||||
req.query.offset,
|
||||
@ -394,11 +388,11 @@ router.get('/autocomplete', async (req, res) => {
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/lessons/{id}:
|
||||
* /api/activities/{id}:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Lessons]
|
||||
* tags: [Activities]
|
||||
* summary: Get selected item
|
||||
* description: Get selected item
|
||||
* parameters:
|
||||
@ -414,7 +408,7 @@ router.get('/autocomplete', async (req, res) => {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Lessons"
|
||||
* $ref: "#/components/schemas/Activities"
|
||||
* 400:
|
||||
* description: Invalid ID supplied
|
||||
* 401:
|
||||
@ -425,7 +419,7 @@ router.get('/autocomplete', async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.get('/:id', wrapAsync(async (req, res) => {
|
||||
const payload = await LessonsDBApi.findBy(
|
||||
const payload = await ActivitiesDBApi.findBy(
|
||||
{ id: req.params.id },
|
||||
);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
|
||||
const express = require('express');
|
||||
|
||||
const ProgressService = require('../services/progress');
|
||||
const ProgressDBApi = require('../db/api/progress');
|
||||
const ContactsService = require('../services/contacts');
|
||||
const ContactsDBApi = require('../db/api/contacts');
|
||||
const wrapAsync = require('../helpers').wrapAsync;
|
||||
|
||||
|
||||
@ -15,45 +15,54 @@ const {
|
||||
checkCrudPermissions,
|
||||
} = require('../middlewares/check-permissions');
|
||||
|
||||
router.use(checkCrudPermissions('progress'));
|
||||
router.use(checkCrudPermissions('contacts'));
|
||||
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* components:
|
||||
* schemas:
|
||||
* Progress:
|
||||
* Contacts:
|
||||
* type: object
|
||||
* properties:
|
||||
|
||||
* note:
|
||||
* name:
|
||||
* type: string
|
||||
* default: note
|
||||
* default: name
|
||||
* email:
|
||||
* type: string
|
||||
* default: email
|
||||
* phone:
|
||||
* type: string
|
||||
* default: phone
|
||||
* title:
|
||||
* type: string
|
||||
* default: title
|
||||
* company:
|
||||
* type: string
|
||||
* default: company
|
||||
* notes:
|
||||
* type: string
|
||||
* default: notes
|
||||
|
||||
* attempts:
|
||||
* type: integer
|
||||
* format: int64
|
||||
|
||||
* score:
|
||||
* type: integer
|
||||
* format: int64
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Progress
|
||||
* description: The Progress managing API
|
||||
* name: Contacts
|
||||
* description: The Contacts managing API
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/progress:
|
||||
* /api/contacts:
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Progress]
|
||||
* tags: [Contacts]
|
||||
* summary: Add new item
|
||||
* description: Add new item
|
||||
* requestBody:
|
||||
@ -65,14 +74,14 @@ router.use(checkCrudPermissions('progress'));
|
||||
* data:
|
||||
* description: Data of the updated item
|
||||
* type: object
|
||||
* $ref: "#/components/schemas/Progress"
|
||||
* $ref: "#/components/schemas/Contacts"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: The item was successfully added
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Progress"
|
||||
* $ref: "#/components/schemas/Contacts"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 405:
|
||||
@ -83,7 +92,7 @@ router.use(checkCrudPermissions('progress'));
|
||||
router.post('/', wrapAsync(async (req, res) => {
|
||||
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
||||
const link = new URL(referer);
|
||||
await ProgressService.create(req.body.data, req.currentUser, true, link.host);
|
||||
await ContactsService.create(req.body.data, req.currentUser, true, link.host);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
@ -94,7 +103,7 @@ router.post('/', wrapAsync(async (req, res) => {
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Progress]
|
||||
* tags: [Contacts]
|
||||
* summary: Bulk import items
|
||||
* description: Bulk import items
|
||||
* requestBody:
|
||||
@ -107,14 +116,14 @@ router.post('/', wrapAsync(async (req, res) => {
|
||||
* description: Data of the updated items
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Progress"
|
||||
* $ref: "#/components/schemas/Contacts"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: The items were successfully imported
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Progress"
|
||||
* $ref: "#/components/schemas/Contacts"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 405:
|
||||
@ -126,18 +135,18 @@ router.post('/', wrapAsync(async (req, res) => {
|
||||
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 ProgressService.bulkImport(req, res, true, link.host);
|
||||
await ContactsService.bulkImport(req, res, true, link.host);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/progress/{id}:
|
||||
* /api/contacts/{id}:
|
||||
* put:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Progress]
|
||||
* tags: [Contacts]
|
||||
* summary: Update the data of the selected item
|
||||
* description: Update the data of the selected item
|
||||
* parameters:
|
||||
@ -160,7 +169,7 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||
* data:
|
||||
* description: Data of the updated item
|
||||
* type: object
|
||||
* $ref: "#/components/schemas/Progress"
|
||||
* $ref: "#/components/schemas/Contacts"
|
||||
* required:
|
||||
* - id
|
||||
* responses:
|
||||
@ -169,7 +178,7 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Progress"
|
||||
* $ref: "#/components/schemas/Contacts"
|
||||
* 400:
|
||||
* description: Invalid ID supplied
|
||||
* 401:
|
||||
@ -180,18 +189,18 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.put('/:id', wrapAsync(async (req, res) => {
|
||||
await ProgressService.update(req.body.data, req.body.id, req.currentUser);
|
||||
await ContactsService.update(req.body.data, req.body.id, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/progress/{id}:
|
||||
* /api/contacts/{id}:
|
||||
* delete:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Progress]
|
||||
* tags: [Contacts]
|
||||
* summary: Delete the selected item
|
||||
* description: Delete the selected item
|
||||
* parameters:
|
||||
@ -207,7 +216,7 @@ router.put('/:id', wrapAsync(async (req, res) => {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Progress"
|
||||
* $ref: "#/components/schemas/Contacts"
|
||||
* 400:
|
||||
* description: Invalid ID supplied
|
||||
* 401:
|
||||
@ -218,18 +227,18 @@ router.put('/:id', wrapAsync(async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.delete('/:id', wrapAsync(async (req, res) => {
|
||||
await ProgressService.remove(req.params.id, req.currentUser);
|
||||
await ContactsService.remove(req.params.id, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/progress/deleteByIds:
|
||||
* /api/contacts/deleteByIds:
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Progress]
|
||||
* tags: [Contacts]
|
||||
* summary: Delete the selected item list
|
||||
* description: Delete the selected item list
|
||||
* requestBody:
|
||||
@ -247,7 +256,7 @@ router.delete('/:id', wrapAsync(async (req, res) => {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Progress"
|
||||
* $ref: "#/components/schemas/Contacts"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
@ -256,29 +265,29 @@ router.delete('/:id', wrapAsync(async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.post('/deleteByIds', wrapAsync(async (req, res) => {
|
||||
await ProgressService.deleteByIds(req.body.data, req.currentUser);
|
||||
await ContactsService.deleteByIds(req.body.data, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/progress:
|
||||
* /api/contacts:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Progress]
|
||||
* summary: Get all progress
|
||||
* description: Get all progress
|
||||
* tags: [Contacts]
|
||||
* summary: Get all contacts
|
||||
* description: Get all contacts
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Progress list successfully received
|
||||
* description: Contacts list successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Progress"
|
||||
* $ref: "#/components/schemas/Contacts"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
@ -290,14 +299,14 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
const filetype = req.query.filetype
|
||||
|
||||
const currentUser = req.currentUser;
|
||||
const payload = await ProgressDBApi.findAll(
|
||||
const payload = await ContactsDBApi.findAll(
|
||||
req.query, { currentUser }
|
||||
);
|
||||
if (filetype && filetype === 'csv') {
|
||||
const fields = ['id','note',
|
||||
'attempts',
|
||||
'score',
|
||||
'completed_at',
|
||||
const fields = ['id','name','email','phone','title','company','notes',
|
||||
|
||||
|
||||
|
||||
];
|
||||
const opts = { fields };
|
||||
try {
|
||||
@ -316,22 +325,22 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/progress/count:
|
||||
* /api/contacts/count:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Progress]
|
||||
* summary: Count all progress
|
||||
* description: Count all progress
|
||||
* tags: [Contacts]
|
||||
* summary: Count all contacts
|
||||
* description: Count all contacts
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Progress count successfully received
|
||||
* description: Contacts count successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Progress"
|
||||
* $ref: "#/components/schemas/Contacts"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
@ -342,7 +351,7 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
router.get('/count', wrapAsync(async (req, res) => {
|
||||
|
||||
const currentUser = req.currentUser;
|
||||
const payload = await ProgressDBApi.findAll(
|
||||
const payload = await ContactsDBApi.findAll(
|
||||
req.query,
|
||||
null,
|
||||
{ countOnly: true, currentUser }
|
||||
@ -353,22 +362,22 @@ router.get('/count', wrapAsync(async (req, res) => {
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/progress/autocomplete:
|
||||
* /api/contacts/autocomplete:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Progress]
|
||||
* summary: Find all progress that match search criteria
|
||||
* description: Find all progress that match search criteria
|
||||
* tags: [Contacts]
|
||||
* summary: Find all contacts that match search criteria
|
||||
* description: Find all contacts that match search criteria
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Progress list successfully received
|
||||
* description: Contacts list successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Progress"
|
||||
* $ref: "#/components/schemas/Contacts"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
@ -378,7 +387,7 @@ router.get('/count', wrapAsync(async (req, res) => {
|
||||
*/
|
||||
router.get('/autocomplete', async (req, res) => {
|
||||
|
||||
const payload = await ProgressDBApi.findAllAutocomplete(
|
||||
const payload = await ContactsDBApi.findAllAutocomplete(
|
||||
req.query.query,
|
||||
req.query.limit,
|
||||
req.query.offset,
|
||||
@ -390,11 +399,11 @@ router.get('/autocomplete', async (req, res) => {
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/progress/{id}:
|
||||
* /api/contacts/{id}:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Progress]
|
||||
* tags: [Contacts]
|
||||
* summary: Get selected item
|
||||
* description: Get selected item
|
||||
* parameters:
|
||||
@ -410,7 +419,7 @@ router.get('/autocomplete', async (req, res) => {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Progress"
|
||||
* $ref: "#/components/schemas/Contacts"
|
||||
* 400:
|
||||
* description: Invalid ID supplied
|
||||
* 401:
|
||||
@ -421,7 +430,7 @@ router.get('/autocomplete', async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.get('/:id', wrapAsync(async (req, res) => {
|
||||
const payload = await ProgressDBApi.findBy(
|
||||
const payload = await ContactsDBApi.findBy(
|
||||
{ id: req.params.id },
|
||||
);
|
||||
|
||||
461
backend/src/routes/deals.js
Normal file
461
backend/src/routes/deals.js
Normal file
@ -0,0 +1,461 @@
|
||||
|
||||
const express = require('express');
|
||||
|
||||
const DealsService = require('../services/deals');
|
||||
const DealsDBApi = require('../db/api/deals');
|
||||
const wrapAsync = require('../helpers').wrapAsync;
|
||||
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const { parse } = require('json2csv');
|
||||
|
||||
|
||||
const {
|
||||
checkCrudPermissions,
|
||||
} = require('../middlewares/check-permissions');
|
||||
|
||||
router.use(checkCrudPermissions('deals'));
|
||||
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* components:
|
||||
* schemas:
|
||||
* Deals:
|
||||
* type: object
|
||||
* properties:
|
||||
|
||||
* title:
|
||||
* type: string
|
||||
* default: title
|
||||
* deal_number:
|
||||
* type: string
|
||||
* default: deal_number
|
||||
* currency:
|
||||
* type: string
|
||||
* default: currency
|
||||
* description:
|
||||
* type: string
|
||||
* default: description
|
||||
|
||||
|
||||
* value:
|
||||
* type: integer
|
||||
* format: int64
|
||||
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Deals
|
||||
* description: The Deals managing API
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/deals:
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Deals]
|
||||
* 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/Deals"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: The item was successfully added
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Deals"
|
||||
* 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 DealsService.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: [Deals]
|
||||
* 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/Deals"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: The items were successfully imported
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Deals"
|
||||
* 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 DealsService.bulkImport(req, res, true, link.host);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/deals/{id}:
|
||||
* put:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Deals]
|
||||
* 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/Deals"
|
||||
* required:
|
||||
* - id
|
||||
* responses:
|
||||
* 200:
|
||||
* description: The item data was successfully updated
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Deals"
|
||||
* 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 DealsService.update(req.body.data, req.body.id, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/deals/{id}:
|
||||
* delete:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Deals]
|
||||
* 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/Deals"
|
||||
* 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 DealsService.remove(req.params.id, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/deals/deleteByIds:
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Deals]
|
||||
* 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/Deals"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
* description: Items not found
|
||||
* 500:
|
||||
* description: Some server error
|
||||
*/
|
||||
router.post('/deleteByIds', wrapAsync(async (req, res) => {
|
||||
await DealsService.deleteByIds(req.body.data, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/deals:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Deals]
|
||||
* summary: Get all deals
|
||||
* description: Get all deals
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Deals list successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Deals"
|
||||
* 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 currentUser = req.currentUser;
|
||||
const payload = await DealsDBApi.findAll(
|
||||
req.query, { currentUser }
|
||||
);
|
||||
if (filetype && filetype === 'csv') {
|
||||
const fields = ['id','title','deal_number','currency','description',
|
||||
|
||||
'value',
|
||||
'close_date',
|
||||
];
|
||||
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/deals/count:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Deals]
|
||||
* summary: Count all deals
|
||||
* description: Count all deals
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Deals count successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Deals"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
* description: Data not found
|
||||
* 500:
|
||||
* description: Some server error
|
||||
*/
|
||||
/**
|
||||
* @swagger
|
||||
* /api/deals/stats:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Deals]
|
||||
* summary: Get deals stats
|
||||
* description: Get deals stats
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Deals stats successfully received
|
||||
*/
|
||||
router.get('/stats', wrapAsync(async (req, res) => {
|
||||
const currentUser = req.currentUser;
|
||||
const payload = await DealsDBApi.stats({ currentUser });
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
router.get('/count', wrapAsync(async (req, res) => {
|
||||
|
||||
const currentUser = req.currentUser;
|
||||
const payload = await DealsDBApi.findAll(
|
||||
req.query,
|
||||
null,
|
||||
{ countOnly: true, currentUser }
|
||||
);
|
||||
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/deals/autocomplete:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Deals]
|
||||
* summary: Find all deals that match search criteria
|
||||
* description: Find all deals that match search criteria
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Deals list successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Deals"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
* description: Data not found
|
||||
* 500:
|
||||
* description: Some server error
|
||||
*/
|
||||
router.get('/autocomplete', async (req, res) => {
|
||||
|
||||
const payload = await DealsDBApi.findAllAutocomplete(
|
||||
req.query.query,
|
||||
req.query.limit,
|
||||
req.query.offset,
|
||||
|
||||
);
|
||||
|
||||
res.status(200).send(payload);
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/deals/{id}:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Deals]
|
||||
* 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/Deals"
|
||||
* 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 DealsDBApi.findBy(
|
||||
{ id: req.params.id },
|
||||
);
|
||||
|
||||
|
||||
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
router.use('/', require('../helpers').commonErrorHandler);
|
||||
|
||||
module.exports = router;
|
||||
@ -1,8 +1,8 @@
|
||||
|
||||
const express = require('express');
|
||||
|
||||
const CoursesService = require('../services/courses');
|
||||
const CoursesDBApi = require('../db/api/courses');
|
||||
const LeadsService = require('../services/leads');
|
||||
const LeadsDBApi = require('../db/api/leads');
|
||||
const wrapAsync = require('../helpers').wrapAsync;
|
||||
|
||||
|
||||
@ -15,29 +15,35 @@ const {
|
||||
checkCrudPermissions,
|
||||
} = require('../middlewares/check-permissions');
|
||||
|
||||
router.use(checkCrudPermissions('courses'));
|
||||
router.use(checkCrudPermissions('leads'));
|
||||
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* components:
|
||||
* schemas:
|
||||
* Courses:
|
||||
* Leads:
|
||||
* type: object
|
||||
* properties:
|
||||
|
||||
* title:
|
||||
* name:
|
||||
* type: string
|
||||
* default: title
|
||||
* description:
|
||||
* default: name
|
||||
* company:
|
||||
* type: string
|
||||
* default: description
|
||||
* language:
|
||||
* default: company
|
||||
* email:
|
||||
* type: string
|
||||
* default: language
|
||||
* default: email
|
||||
* phone:
|
||||
* type: string
|
||||
* default: phone
|
||||
* notes:
|
||||
* type: string
|
||||
* default: notes
|
||||
|
||||
|
||||
* price:
|
||||
* estimated_value:
|
||||
* type: integer
|
||||
* format: int64
|
||||
|
||||
@ -48,17 +54,17 @@ router.use(checkCrudPermissions('courses'));
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Courses
|
||||
* description: The Courses managing API
|
||||
* name: Leads
|
||||
* description: The Leads managing API
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/courses:
|
||||
* /api/leads:
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Courses]
|
||||
* tags: [Leads]
|
||||
* summary: Add new item
|
||||
* description: Add new item
|
||||
* requestBody:
|
||||
@ -70,14 +76,14 @@ router.use(checkCrudPermissions('courses'));
|
||||
* data:
|
||||
* description: Data of the updated item
|
||||
* type: object
|
||||
* $ref: "#/components/schemas/Courses"
|
||||
* $ref: "#/components/schemas/Leads"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: The item was successfully added
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Courses"
|
||||
* $ref: "#/components/schemas/Leads"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 405:
|
||||
@ -88,7 +94,7 @@ router.use(checkCrudPermissions('courses'));
|
||||
router.post('/', wrapAsync(async (req, res) => {
|
||||
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
||||
const link = new URL(referer);
|
||||
await CoursesService.create(req.body.data, req.currentUser, true, link.host);
|
||||
await LeadsService.create(req.body.data, req.currentUser, true, link.host);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
@ -99,7 +105,7 @@ router.post('/', wrapAsync(async (req, res) => {
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Courses]
|
||||
* tags: [Leads]
|
||||
* summary: Bulk import items
|
||||
* description: Bulk import items
|
||||
* requestBody:
|
||||
@ -112,14 +118,14 @@ router.post('/', wrapAsync(async (req, res) => {
|
||||
* description: Data of the updated items
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Courses"
|
||||
* $ref: "#/components/schemas/Leads"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: The items were successfully imported
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Courses"
|
||||
* $ref: "#/components/schemas/Leads"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 405:
|
||||
@ -131,18 +137,18 @@ router.post('/', wrapAsync(async (req, res) => {
|
||||
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 CoursesService.bulkImport(req, res, true, link.host);
|
||||
await LeadsService.bulkImport(req, res, true, link.host);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/courses/{id}:
|
||||
* /api/leads/{id}:
|
||||
* put:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Courses]
|
||||
* tags: [Leads]
|
||||
* summary: Update the data of the selected item
|
||||
* description: Update the data of the selected item
|
||||
* parameters:
|
||||
@ -165,7 +171,7 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||
* data:
|
||||
* description: Data of the updated item
|
||||
* type: object
|
||||
* $ref: "#/components/schemas/Courses"
|
||||
* $ref: "#/components/schemas/Leads"
|
||||
* required:
|
||||
* - id
|
||||
* responses:
|
||||
@ -174,7 +180,7 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Courses"
|
||||
* $ref: "#/components/schemas/Leads"
|
||||
* 400:
|
||||
* description: Invalid ID supplied
|
||||
* 401:
|
||||
@ -185,18 +191,18 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.put('/:id', wrapAsync(async (req, res) => {
|
||||
await CoursesService.update(req.body.data, req.body.id, req.currentUser);
|
||||
await LeadsService.update(req.body.data, req.body.id, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/courses/{id}:
|
||||
* /api/leads/{id}:
|
||||
* delete:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Courses]
|
||||
* tags: [Leads]
|
||||
* summary: Delete the selected item
|
||||
* description: Delete the selected item
|
||||
* parameters:
|
||||
@ -212,7 +218,7 @@ router.put('/:id', wrapAsync(async (req, res) => {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Courses"
|
||||
* $ref: "#/components/schemas/Leads"
|
||||
* 400:
|
||||
* description: Invalid ID supplied
|
||||
* 401:
|
||||
@ -223,18 +229,18 @@ router.put('/:id', wrapAsync(async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.delete('/:id', wrapAsync(async (req, res) => {
|
||||
await CoursesService.remove(req.params.id, req.currentUser);
|
||||
await LeadsService.remove(req.params.id, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/courses/deleteByIds:
|
||||
* /api/leads/deleteByIds:
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Courses]
|
||||
* tags: [Leads]
|
||||
* summary: Delete the selected item list
|
||||
* description: Delete the selected item list
|
||||
* requestBody:
|
||||
@ -252,7 +258,7 @@ router.delete('/:id', wrapAsync(async (req, res) => {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Courses"
|
||||
* $ref: "#/components/schemas/Leads"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
@ -261,29 +267,29 @@ router.delete('/:id', wrapAsync(async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.post('/deleteByIds', wrapAsync(async (req, res) => {
|
||||
await CoursesService.deleteByIds(req.body.data, req.currentUser);
|
||||
await LeadsService.deleteByIds(req.body.data, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/courses:
|
||||
* /api/leads:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Courses]
|
||||
* summary: Get all courses
|
||||
* description: Get all courses
|
||||
* tags: [Leads]
|
||||
* summary: Get all leads
|
||||
* description: Get all leads
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Courses list successfully received
|
||||
* description: Leads list successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Courses"
|
||||
* $ref: "#/components/schemas/Leads"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
@ -295,14 +301,14 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
const filetype = req.query.filetype
|
||||
|
||||
const currentUser = req.currentUser;
|
||||
const payload = await CoursesDBApi.findAll(
|
||||
const payload = await LeadsDBApi.findAll(
|
||||
req.query, { currentUser }
|
||||
);
|
||||
if (filetype && filetype === 'csv') {
|
||||
const fields = ['id','title','description','language',
|
||||
const fields = ['id','name','company','email','phone','notes',
|
||||
|
||||
'price',
|
||||
'start_date','end_date',
|
||||
'estimated_value',
|
||||
|
||||
];
|
||||
const opts = { fields };
|
||||
try {
|
||||
@ -321,22 +327,22 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/courses/count:
|
||||
* /api/leads/count:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Courses]
|
||||
* summary: Count all courses
|
||||
* description: Count all courses
|
||||
* tags: [Leads]
|
||||
* summary: Count all leads
|
||||
* description: Count all leads
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Courses count successfully received
|
||||
* description: Leads count successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Courses"
|
||||
* $ref: "#/components/schemas/Leads"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
@ -347,7 +353,7 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
router.get('/count', wrapAsync(async (req, res) => {
|
||||
|
||||
const currentUser = req.currentUser;
|
||||
const payload = await CoursesDBApi.findAll(
|
||||
const payload = await LeadsDBApi.findAll(
|
||||
req.query,
|
||||
null,
|
||||
{ countOnly: true, currentUser }
|
||||
@ -358,22 +364,22 @@ router.get('/count', wrapAsync(async (req, res) => {
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/courses/autocomplete:
|
||||
* /api/leads/autocomplete:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Courses]
|
||||
* summary: Find all courses that match search criteria
|
||||
* description: Find all courses that match search criteria
|
||||
* tags: [Leads]
|
||||
* summary: Find all leads that match search criteria
|
||||
* description: Find all leads that match search criteria
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Courses list successfully received
|
||||
* description: Leads list successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Courses"
|
||||
* $ref: "#/components/schemas/Leads"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
@ -383,7 +389,7 @@ router.get('/count', wrapAsync(async (req, res) => {
|
||||
*/
|
||||
router.get('/autocomplete', async (req, res) => {
|
||||
|
||||
const payload = await CoursesDBApi.findAllAutocomplete(
|
||||
const payload = await LeadsDBApi.findAllAutocomplete(
|
||||
req.query.query,
|
||||
req.query.limit,
|
||||
req.query.offset,
|
||||
@ -395,11 +401,11 @@ router.get('/autocomplete', async (req, res) => {
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/courses/{id}:
|
||||
* /api/leads/{id}:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Courses]
|
||||
* tags: [Leads]
|
||||
* summary: Get selected item
|
||||
* description: Get selected item
|
||||
* parameters:
|
||||
@ -415,7 +421,7 @@ router.get('/autocomplete', async (req, res) => {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Courses"
|
||||
* $ref: "#/components/schemas/Leads"
|
||||
* 400:
|
||||
* description: Invalid ID supplied
|
||||
* 401:
|
||||
@ -426,7 +432,7 @@ router.get('/autocomplete', async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.get('/:id', wrapAsync(async (req, res) => {
|
||||
const payload = await CoursesDBApi.findBy(
|
||||
const payload = await LeadsDBApi.findBy(
|
||||
{ id: req.params.id },
|
||||
);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
|
||||
const express = require('express');
|
||||
|
||||
const EnrollmentsService = require('../services/enrollments');
|
||||
const EnrollmentsDBApi = require('../db/api/enrollments');
|
||||
const Pipeline_stagesService = require('../services/pipeline_stages');
|
||||
const Pipeline_stagesDBApi = require('../db/api/pipeline_stages');
|
||||
const wrapAsync = require('../helpers').wrapAsync;
|
||||
|
||||
|
||||
@ -15,46 +15,45 @@ const {
|
||||
checkCrudPermissions,
|
||||
} = require('../middlewares/check-permissions');
|
||||
|
||||
router.use(checkCrudPermissions('enrollments'));
|
||||
router.use(checkCrudPermissions('pipeline_stages'));
|
||||
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* components:
|
||||
* schemas:
|
||||
* Enrollments:
|
||||
* Pipeline_stages:
|
||||
* type: object
|
||||
* properties:
|
||||
|
||||
* enrollment_label:
|
||||
* title:
|
||||
* type: string
|
||||
* default: enrollment_label
|
||||
* default: title
|
||||
|
||||
|
||||
* progress_percent:
|
||||
* order:
|
||||
* type: integer
|
||||
* format: int64
|
||||
* price_paid:
|
||||
* probability:
|
||||
* type: integer
|
||||
* format: int64
|
||||
|
||||
*
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Enrollments
|
||||
* description: The Enrollments managing API
|
||||
* name: Pipeline_stages
|
||||
* description: The Pipeline_stages managing API
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/enrollments:
|
||||
* /api/pipeline_stages:
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Enrollments]
|
||||
* tags: [Pipeline_stages]
|
||||
* summary: Add new item
|
||||
* description: Add new item
|
||||
* requestBody:
|
||||
@ -66,14 +65,14 @@ router.use(checkCrudPermissions('enrollments'));
|
||||
* data:
|
||||
* description: Data of the updated item
|
||||
* type: object
|
||||
* $ref: "#/components/schemas/Enrollments"
|
||||
* $ref: "#/components/schemas/Pipeline_stages"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: The item was successfully added
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Enrollments"
|
||||
* $ref: "#/components/schemas/Pipeline_stages"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 405:
|
||||
@ -84,7 +83,7 @@ router.use(checkCrudPermissions('enrollments'));
|
||||
router.post('/', wrapAsync(async (req, res) => {
|
||||
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
||||
const link = new URL(referer);
|
||||
await EnrollmentsService.create(req.body.data, req.currentUser, true, link.host);
|
||||
await Pipeline_stagesService.create(req.body.data, req.currentUser, true, link.host);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
@ -95,7 +94,7 @@ router.post('/', wrapAsync(async (req, res) => {
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Enrollments]
|
||||
* tags: [Pipeline_stages]
|
||||
* summary: Bulk import items
|
||||
* description: Bulk import items
|
||||
* requestBody:
|
||||
@ -108,14 +107,14 @@ router.post('/', wrapAsync(async (req, res) => {
|
||||
* description: Data of the updated items
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Enrollments"
|
||||
* $ref: "#/components/schemas/Pipeline_stages"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: The items were successfully imported
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Enrollments"
|
||||
* $ref: "#/components/schemas/Pipeline_stages"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 405:
|
||||
@ -127,18 +126,18 @@ router.post('/', wrapAsync(async (req, res) => {
|
||||
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 EnrollmentsService.bulkImport(req, res, true, link.host);
|
||||
await Pipeline_stagesService.bulkImport(req, res, true, link.host);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/enrollments/{id}:
|
||||
* /api/pipeline_stages/{id}:
|
||||
* put:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Enrollments]
|
||||
* tags: [Pipeline_stages]
|
||||
* summary: Update the data of the selected item
|
||||
* description: Update the data of the selected item
|
||||
* parameters:
|
||||
@ -161,7 +160,7 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||
* data:
|
||||
* description: Data of the updated item
|
||||
* type: object
|
||||
* $ref: "#/components/schemas/Enrollments"
|
||||
* $ref: "#/components/schemas/Pipeline_stages"
|
||||
* required:
|
||||
* - id
|
||||
* responses:
|
||||
@ -170,7 +169,7 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Enrollments"
|
||||
* $ref: "#/components/schemas/Pipeline_stages"
|
||||
* 400:
|
||||
* description: Invalid ID supplied
|
||||
* 401:
|
||||
@ -181,18 +180,18 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.put('/:id', wrapAsync(async (req, res) => {
|
||||
await EnrollmentsService.update(req.body.data, req.body.id, req.currentUser);
|
||||
await Pipeline_stagesService.update(req.body.data, req.body.id, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/enrollments/{id}:
|
||||
* /api/pipeline_stages/{id}:
|
||||
* delete:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Enrollments]
|
||||
* tags: [Pipeline_stages]
|
||||
* summary: Delete the selected item
|
||||
* description: Delete the selected item
|
||||
* parameters:
|
||||
@ -208,7 +207,7 @@ router.put('/:id', wrapAsync(async (req, res) => {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Enrollments"
|
||||
* $ref: "#/components/schemas/Pipeline_stages"
|
||||
* 400:
|
||||
* description: Invalid ID supplied
|
||||
* 401:
|
||||
@ -219,18 +218,18 @@ router.put('/:id', wrapAsync(async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.delete('/:id', wrapAsync(async (req, res) => {
|
||||
await EnrollmentsService.remove(req.params.id, req.currentUser);
|
||||
await Pipeline_stagesService.remove(req.params.id, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/enrollments/deleteByIds:
|
||||
* /api/pipeline_stages/deleteByIds:
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Enrollments]
|
||||
* tags: [Pipeline_stages]
|
||||
* summary: Delete the selected item list
|
||||
* description: Delete the selected item list
|
||||
* requestBody:
|
||||
@ -248,7 +247,7 @@ router.delete('/:id', wrapAsync(async (req, res) => {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Enrollments"
|
||||
* $ref: "#/components/schemas/Pipeline_stages"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
@ -257,29 +256,29 @@ router.delete('/:id', wrapAsync(async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.post('/deleteByIds', wrapAsync(async (req, res) => {
|
||||
await EnrollmentsService.deleteByIds(req.body.data, req.currentUser);
|
||||
await Pipeline_stagesService.deleteByIds(req.body.data, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/enrollments:
|
||||
* /api/pipeline_stages:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Enrollments]
|
||||
* summary: Get all enrollments
|
||||
* description: Get all enrollments
|
||||
* tags: [Pipeline_stages]
|
||||
* summary: Get all pipeline_stages
|
||||
* description: Get all pipeline_stages
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Enrollments list successfully received
|
||||
* description: Pipeline_stages list successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Enrollments"
|
||||
* $ref: "#/components/schemas/Pipeline_stages"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
@ -291,14 +290,14 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
const filetype = req.query.filetype
|
||||
|
||||
const currentUser = req.currentUser;
|
||||
const payload = await EnrollmentsDBApi.findAll(
|
||||
const payload = await Pipeline_stagesDBApi.findAll(
|
||||
req.query, { currentUser }
|
||||
);
|
||||
if (filetype && filetype === 'csv') {
|
||||
const fields = ['id','enrollment_label',
|
||||
const fields = ['id','title',
|
||||
'order','probability',
|
||||
|
||||
'progress_percent','price_paid',
|
||||
'enrolled_at',
|
||||
|
||||
];
|
||||
const opts = { fields };
|
||||
try {
|
||||
@ -317,22 +316,22 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/enrollments/count:
|
||||
* /api/pipeline_stages/count:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Enrollments]
|
||||
* summary: Count all enrollments
|
||||
* description: Count all enrollments
|
||||
* tags: [Pipeline_stages]
|
||||
* summary: Count all pipeline_stages
|
||||
* description: Count all pipeline_stages
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Enrollments count successfully received
|
||||
* description: Pipeline_stages count successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Enrollments"
|
||||
* $ref: "#/components/schemas/Pipeline_stages"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
@ -343,7 +342,7 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
router.get('/count', wrapAsync(async (req, res) => {
|
||||
|
||||
const currentUser = req.currentUser;
|
||||
const payload = await EnrollmentsDBApi.findAll(
|
||||
const payload = await Pipeline_stagesDBApi.findAll(
|
||||
req.query,
|
||||
null,
|
||||
{ countOnly: true, currentUser }
|
||||
@ -354,22 +353,22 @@ router.get('/count', wrapAsync(async (req, res) => {
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/enrollments/autocomplete:
|
||||
* /api/pipeline_stages/autocomplete:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Enrollments]
|
||||
* summary: Find all enrollments that match search criteria
|
||||
* description: Find all enrollments that match search criteria
|
||||
* tags: [Pipeline_stages]
|
||||
* summary: Find all pipeline_stages that match search criteria
|
||||
* description: Find all pipeline_stages that match search criteria
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Enrollments list successfully received
|
||||
* description: Pipeline_stages list successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Enrollments"
|
||||
* $ref: "#/components/schemas/Pipeline_stages"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
@ -379,7 +378,7 @@ router.get('/count', wrapAsync(async (req, res) => {
|
||||
*/
|
||||
router.get('/autocomplete', async (req, res) => {
|
||||
|
||||
const payload = await EnrollmentsDBApi.findAllAutocomplete(
|
||||
const payload = await Pipeline_stagesDBApi.findAllAutocomplete(
|
||||
req.query.query,
|
||||
req.query.limit,
|
||||
req.query.offset,
|
||||
@ -391,11 +390,11 @@ router.get('/autocomplete', async (req, res) => {
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/enrollments/{id}:
|
||||
* /api/pipeline_stages/{id}:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Enrollments]
|
||||
* tags: [Pipeline_stages]
|
||||
* summary: Get selected item
|
||||
* description: Get selected item
|
||||
* parameters:
|
||||
@ -411,7 +410,7 @@ router.get('/autocomplete', async (req, res) => {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Enrollments"
|
||||
* $ref: "#/components/schemas/Pipeline_stages"
|
||||
* 400:
|
||||
* description: Invalid ID supplied
|
||||
* 401:
|
||||
@ -422,7 +421,7 @@ router.get('/autocomplete', async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.get('/:id', wrapAsync(async (req, res) => {
|
||||
const payload = await EnrollmentsDBApi.findBy(
|
||||
const payload = await Pipeline_stagesDBApi.findBy(
|
||||
{ id: req.params.id },
|
||||
);
|
||||
|
||||
61
backend/src/routes/sql.js
Normal file
61
backend/src/routes/sql.js
Normal file
@ -0,0 +1,61 @@
|
||||
const express = require('express');
|
||||
const db = require('../db/models');
|
||||
const wrapAsync = require('../helpers').wrapAsync;
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/sql:
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* summary: Execute a SELECT-only SQL query
|
||||
* description: Executes a read-only SQL query and returns rows.
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* sql:
|
||||
* type: string
|
||||
* required:
|
||||
* - sql
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Query result
|
||||
* 400:
|
||||
* description: Invalid SQL
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 500:
|
||||
* description: Internal server error
|
||||
*/
|
||||
router.post(
|
||||
'/',
|
||||
wrapAsync(async (req, res) => {
|
||||
const { sql } = req.body;
|
||||
if (typeof sql !== 'string' || !sql.trim()) {
|
||||
return res.status(400).json({ error: 'SQL is required' });
|
||||
}
|
||||
|
||||
const normalized = sql.trim().replace(/;+\s*$/, '');
|
||||
if (!/^select\b/i.test(normalized)) {
|
||||
return res.status(400).json({ error: 'Only SELECT statements are allowed' });
|
||||
}
|
||||
|
||||
if (normalized.includes(';')) {
|
||||
return res.status(400).json({ error: 'Only a single SELECT statement is allowed' });
|
||||
}
|
||||
|
||||
const rows = await db.sequelize.query(normalized, {
|
||||
type: db.Sequelize.QueryTypes.SELECT,
|
||||
});
|
||||
|
||||
return res.status(200).json({ rows });
|
||||
}),
|
||||
);
|
||||
|
||||
module.exports = router;
|
||||
@ -1,5 +1,5 @@
|
||||
const db = require('../db/models');
|
||||
const EnrollmentsDBApi = require('../db/api/enrollments');
|
||||
const ActivitiesDBApi = require('../db/api/activities');
|
||||
const processFile = require("../middlewares/upload");
|
||||
const ValidationError = require('./notifications/errors/validation');
|
||||
const csv = require('csv-parser');
|
||||
@ -11,11 +11,11 @@ const stream = require('stream');
|
||||
|
||||
|
||||
|
||||
module.exports = class EnrollmentsService {
|
||||
module.exports = class ActivitiesService {
|
||||
static async create(data, currentUser) {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
try {
|
||||
await EnrollmentsDBApi.create(
|
||||
await ActivitiesDBApi.create(
|
||||
data,
|
||||
{
|
||||
currentUser,
|
||||
@ -51,7 +51,7 @@ module.exports = class EnrollmentsService {
|
||||
.on('error', (error) => reject(error));
|
||||
})
|
||||
|
||||
await EnrollmentsDBApi.bulkImport(results, {
|
||||
await ActivitiesDBApi.bulkImport(results, {
|
||||
transaction,
|
||||
ignoreDuplicates: true,
|
||||
validate: true,
|
||||
@ -68,18 +68,18 @@ module.exports = class EnrollmentsService {
|
||||
static async update(data, id, currentUser) {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
try {
|
||||
let enrollments = await EnrollmentsDBApi.findBy(
|
||||
let activities = await ActivitiesDBApi.findBy(
|
||||
{id},
|
||||
{transaction},
|
||||
);
|
||||
|
||||
if (!enrollments) {
|
||||
if (!activities) {
|
||||
throw new ValidationError(
|
||||
'enrollmentsNotFound',
|
||||
'activitiesNotFound',
|
||||
);
|
||||
}
|
||||
|
||||
const updatedEnrollments = await EnrollmentsDBApi.update(
|
||||
const updatedActivities = await ActivitiesDBApi.update(
|
||||
id,
|
||||
data,
|
||||
{
|
||||
@ -89,7 +89,7 @@ module.exports = class EnrollmentsService {
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
return updatedEnrollments;
|
||||
return updatedActivities;
|
||||
|
||||
} catch (error) {
|
||||
await transaction.rollback();
|
||||
@ -101,7 +101,7 @@ module.exports = class EnrollmentsService {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
|
||||
try {
|
||||
await EnrollmentsDBApi.deleteByIds(ids, {
|
||||
await ActivitiesDBApi.deleteByIds(ids, {
|
||||
currentUser,
|
||||
transaction,
|
||||
});
|
||||
@ -117,7 +117,7 @@ module.exports = class EnrollmentsService {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
|
||||
try {
|
||||
await EnrollmentsDBApi.remove(
|
||||
await ActivitiesDBApi.remove(
|
||||
id,
|
||||
{
|
||||
currentUser,
|
||||
@ -1,5 +1,5 @@
|
||||
const db = require('../db/models');
|
||||
const ProgressDBApi = require('../db/api/progress');
|
||||
const ContactsDBApi = require('../db/api/contacts');
|
||||
const processFile = require("../middlewares/upload");
|
||||
const ValidationError = require('./notifications/errors/validation');
|
||||
const csv = require('csv-parser');
|
||||
@ -11,11 +11,11 @@ const stream = require('stream');
|
||||
|
||||
|
||||
|
||||
module.exports = class ProgressService {
|
||||
module.exports = class ContactsService {
|
||||
static async create(data, currentUser) {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
try {
|
||||
await ProgressDBApi.create(
|
||||
await ContactsDBApi.create(
|
||||
data,
|
||||
{
|
||||
currentUser,
|
||||
@ -51,7 +51,7 @@ module.exports = class ProgressService {
|
||||
.on('error', (error) => reject(error));
|
||||
})
|
||||
|
||||
await ProgressDBApi.bulkImport(results, {
|
||||
await ContactsDBApi.bulkImport(results, {
|
||||
transaction,
|
||||
ignoreDuplicates: true,
|
||||
validate: true,
|
||||
@ -68,18 +68,18 @@ module.exports = class ProgressService {
|
||||
static async update(data, id, currentUser) {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
try {
|
||||
let progress = await ProgressDBApi.findBy(
|
||||
let contacts = await ContactsDBApi.findBy(
|
||||
{id},
|
||||
{transaction},
|
||||
);
|
||||
|
||||
if (!progress) {
|
||||
if (!contacts) {
|
||||
throw new ValidationError(
|
||||
'progressNotFound',
|
||||
'contactsNotFound',
|
||||
);
|
||||
}
|
||||
|
||||
const updatedProgress = await ProgressDBApi.update(
|
||||
const updatedContacts = await ContactsDBApi.update(
|
||||
id,
|
||||
data,
|
||||
{
|
||||
@ -89,7 +89,7 @@ module.exports = class ProgressService {
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
return updatedProgress;
|
||||
return updatedContacts;
|
||||
|
||||
} catch (error) {
|
||||
await transaction.rollback();
|
||||
@ -101,7 +101,7 @@ module.exports = class ProgressService {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
|
||||
try {
|
||||
await ProgressDBApi.deleteByIds(ids, {
|
||||
await ContactsDBApi.deleteByIds(ids, {
|
||||
currentUser,
|
||||
transaction,
|
||||
});
|
||||
@ -117,7 +117,7 @@ module.exports = class ProgressService {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
|
||||
try {
|
||||
await ProgressDBApi.remove(
|
||||
await ContactsDBApi.remove(
|
||||
id,
|
||||
{
|
||||
currentUser,
|
||||
@ -1,5 +1,5 @@
|
||||
const db = require('../db/models');
|
||||
const CoursesDBApi = require('../db/api/courses');
|
||||
const DealsDBApi = require('../db/api/deals');
|
||||
const processFile = require("../middlewares/upload");
|
||||
const ValidationError = require('./notifications/errors/validation');
|
||||
const csv = require('csv-parser');
|
||||
@ -11,11 +11,11 @@ const stream = require('stream');
|
||||
|
||||
|
||||
|
||||
module.exports = class CoursesService {
|
||||
module.exports = class DealsService {
|
||||
static async create(data, currentUser) {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
try {
|
||||
await CoursesDBApi.create(
|
||||
await DealsDBApi.create(
|
||||
data,
|
||||
{
|
||||
currentUser,
|
||||
@ -51,7 +51,7 @@ module.exports = class CoursesService {
|
||||
.on('error', (error) => reject(error));
|
||||
})
|
||||
|
||||
await CoursesDBApi.bulkImport(results, {
|
||||
await DealsDBApi.bulkImport(results, {
|
||||
transaction,
|
||||
ignoreDuplicates: true,
|
||||
validate: true,
|
||||
@ -68,18 +68,18 @@ module.exports = class CoursesService {
|
||||
static async update(data, id, currentUser) {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
try {
|
||||
let courses = await CoursesDBApi.findBy(
|
||||
let deals = await DealsDBApi.findBy(
|
||||
{id},
|
||||
{transaction},
|
||||
);
|
||||
|
||||
if (!courses) {
|
||||
if (!deals) {
|
||||
throw new ValidationError(
|
||||
'coursesNotFound',
|
||||
'dealsNotFound',
|
||||
);
|
||||
}
|
||||
|
||||
const updatedCourses = await CoursesDBApi.update(
|
||||
const updatedDeals = await DealsDBApi.update(
|
||||
id,
|
||||
data,
|
||||
{
|
||||
@ -89,7 +89,7 @@ module.exports = class CoursesService {
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
return updatedCourses;
|
||||
return updatedDeals;
|
||||
|
||||
} catch (error) {
|
||||
await transaction.rollback();
|
||||
@ -101,7 +101,7 @@ module.exports = class CoursesService {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
|
||||
try {
|
||||
await CoursesDBApi.deleteByIds(ids, {
|
||||
await DealsDBApi.deleteByIds(ids, {
|
||||
currentUser,
|
||||
transaction,
|
||||
});
|
||||
@ -117,7 +117,7 @@ module.exports = class CoursesService {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
|
||||
try {
|
||||
await CoursesDBApi.remove(
|
||||
await DealsDBApi.remove(
|
||||
id,
|
||||
{
|
||||
currentUser,
|
||||
@ -1,5 +1,5 @@
|
||||
const db = require('../db/models');
|
||||
const LessonsDBApi = require('../db/api/lessons');
|
||||
const LeadsDBApi = require('../db/api/leads');
|
||||
const processFile = require("../middlewares/upload");
|
||||
const ValidationError = require('./notifications/errors/validation');
|
||||
const csv = require('csv-parser');
|
||||
@ -11,11 +11,11 @@ const stream = require('stream');
|
||||
|
||||
|
||||
|
||||
module.exports = class LessonsService {
|
||||
module.exports = class LeadsService {
|
||||
static async create(data, currentUser) {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
try {
|
||||
await LessonsDBApi.create(
|
||||
await LeadsDBApi.create(
|
||||
data,
|
||||
{
|
||||
currentUser,
|
||||
@ -51,7 +51,7 @@ module.exports = class LessonsService {
|
||||
.on('error', (error) => reject(error));
|
||||
})
|
||||
|
||||
await LessonsDBApi.bulkImport(results, {
|
||||
await LeadsDBApi.bulkImport(results, {
|
||||
transaction,
|
||||
ignoreDuplicates: true,
|
||||
validate: true,
|
||||
@ -68,18 +68,18 @@ module.exports = class LessonsService {
|
||||
static async update(data, id, currentUser) {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
try {
|
||||
let lessons = await LessonsDBApi.findBy(
|
||||
let leads = await LeadsDBApi.findBy(
|
||||
{id},
|
||||
{transaction},
|
||||
);
|
||||
|
||||
if (!lessons) {
|
||||
if (!leads) {
|
||||
throw new ValidationError(
|
||||
'lessonsNotFound',
|
||||
'leadsNotFound',
|
||||
);
|
||||
}
|
||||
|
||||
const updatedLessons = await LessonsDBApi.update(
|
||||
const updatedLeads = await LeadsDBApi.update(
|
||||
id,
|
||||
data,
|
||||
{
|
||||
@ -89,7 +89,7 @@ module.exports = class LessonsService {
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
return updatedLessons;
|
||||
return updatedLeads;
|
||||
|
||||
} catch (error) {
|
||||
await transaction.rollback();
|
||||
@ -101,7 +101,7 @@ module.exports = class LessonsService {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
|
||||
try {
|
||||
await LessonsDBApi.deleteByIds(ids, {
|
||||
await LeadsDBApi.deleteByIds(ids, {
|
||||
currentUser,
|
||||
transaction,
|
||||
});
|
||||
@ -117,7 +117,7 @@ module.exports = class LessonsService {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
|
||||
try {
|
||||
await LessonsDBApi.remove(
|
||||
await LeadsDBApi.remove(
|
||||
id,
|
||||
{
|
||||
currentUser,
|
||||
@ -1,6 +1,6 @@
|
||||
const errors = {
|
||||
app: {
|
||||
title: 'Instructor-Student LMS',
|
||||
title: 'Sales Pipeline CRM',
|
||||
},
|
||||
|
||||
auth: {
|
||||
|
||||
138
backend/src/services/pipeline_stages.js
Normal file
138
backend/src/services/pipeline_stages.js
Normal file
@ -0,0 +1,138 @@
|
||||
const db = require('../db/models');
|
||||
const Pipeline_stagesDBApi = require('../db/api/pipeline_stages');
|
||||
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 Pipeline_stagesService {
|
||||
static async create(data, currentUser) {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
try {
|
||||
await Pipeline_stagesDBApi.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 Pipeline_stagesDBApi.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 pipeline_stages = await Pipeline_stagesDBApi.findBy(
|
||||
{id},
|
||||
{transaction},
|
||||
);
|
||||
|
||||
if (!pipeline_stages) {
|
||||
throw new ValidationError(
|
||||
'pipeline_stagesNotFound',
|
||||
);
|
||||
}
|
||||
|
||||
const updatedPipeline_stages = await Pipeline_stagesDBApi.update(
|
||||
id,
|
||||
data,
|
||||
{
|
||||
currentUser,
|
||||
transaction,
|
||||
},
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
return updatedPipeline_stages;
|
||||
|
||||
} catch (error) {
|
||||
await transaction.rollback();
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
static async deleteByIds(ids, currentUser) {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
|
||||
try {
|
||||
await Pipeline_stagesDBApi.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 Pipeline_stagesDBApi.remove(
|
||||
id,
|
||||
{
|
||||
currentUser,
|
||||
transaction,
|
||||
},
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (error) {
|
||||
await transaction.rollback();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -66,14 +66,67 @@ module.exports = class SearchService {
|
||||
|
||||
|
||||
|
||||
"courses": [
|
||||
"pipeline_stages": [
|
||||
|
||||
"title",
|
||||
|
||||
],
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"leads": [
|
||||
|
||||
"name",
|
||||
|
||||
"company",
|
||||
|
||||
"email",
|
||||
|
||||
"phone",
|
||||
|
||||
"notes",
|
||||
|
||||
],
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"contacts": [
|
||||
|
||||
"name",
|
||||
|
||||
"email",
|
||||
|
||||
"phone",
|
||||
|
||||
"title",
|
||||
|
||||
"company",
|
||||
|
||||
"notes",
|
||||
|
||||
],
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"deals": [
|
||||
|
||||
"title",
|
||||
|
||||
"deal_number",
|
||||
|
||||
"currency",
|
||||
|
||||
"description",
|
||||
|
||||
"language",
|
||||
|
||||
],
|
||||
|
||||
|
||||
@ -81,33 +134,11 @@ module.exports = class SearchService {
|
||||
|
||||
|
||||
|
||||
"lessons": [
|
||||
"activities": [
|
||||
|
||||
"title",
|
||||
"subject",
|
||||
|
||||
"content",
|
||||
|
||||
],
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"enrollments": [
|
||||
|
||||
"enrollment_label",
|
||||
|
||||
],
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"progress": [
|
||||
|
||||
"note",
|
||||
"notes",
|
||||
|
||||
],
|
||||
|
||||
@ -124,21 +155,11 @@ module.exports = class SearchService {
|
||||
|
||||
|
||||
|
||||
"courses": [
|
||||
|
||||
"price",
|
||||
|
||||
],
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"lessons": [
|
||||
"pipeline_stages": [
|
||||
|
||||
"order",
|
||||
|
||||
"duration_minutes",
|
||||
"probability",
|
||||
|
||||
],
|
||||
|
||||
@ -146,11 +167,9 @@ module.exports = class SearchService {
|
||||
|
||||
|
||||
|
||||
"enrollments": [
|
||||
"leads": [
|
||||
|
||||
"progress_percent",
|
||||
|
||||
"price_paid",
|
||||
"estimated_value",
|
||||
|
||||
],
|
||||
|
||||
@ -158,15 +177,21 @@ module.exports = class SearchService {
|
||||
|
||||
|
||||
|
||||
"progress": [
|
||||
|
||||
|
||||
|
||||
|
||||
"deals": [
|
||||
|
||||
"score",
|
||||
|
||||
"attempts",
|
||||
"value",
|
||||
|
||||
],
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
let allFoundRecords = [];
|
||||
|
||||
@ -25,7 +25,7 @@ services:
|
||||
- ./data/db:/var/lib/postgresql/data
|
||||
environment:
|
||||
- POSTGRES_HOST_AUTH_METHOD=trust
|
||||
- POSTGRES_DB=db_instructor_student_lms
|
||||
- POSTGRES_DB=db_sales_pipeline_crm
|
||||
ports:
|
||||
- "5432:5432"
|
||||
logging:
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
# Instructor-Student LMS
|
||||
# Sales Pipeline CRM
|
||||
|
||||
## This project was generated by Flatlogic Platform.
|
||||
## Install
|
||||
|
||||
@ -12,7 +12,7 @@ import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
type Props = {
|
||||
courses: any[];
|
||||
activities: any[];
|
||||
loading: boolean;
|
||||
onDelete: (id: string) => void;
|
||||
currentPage: number;
|
||||
@ -20,8 +20,8 @@ type Props = {
|
||||
onPageChange: (page: number) => void;
|
||||
};
|
||||
|
||||
const CardCourses = ({
|
||||
courses,
|
||||
const CardActivities = ({
|
||||
activities,
|
||||
loading,
|
||||
onDelete,
|
||||
currentPage,
|
||||
@ -37,7 +37,7 @@ const CardCourses = ({
|
||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||
|
||||
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_COURSES')
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_ACTIVITIES')
|
||||
|
||||
|
||||
return (
|
||||
@ -47,7 +47,7 @@ const CardCourses = ({
|
||||
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 && courses.map((item, index) => (
|
||||
{!loading && activities.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 ${
|
||||
@ -55,28 +55,19 @@ const CardCourses = ({
|
||||
}`}
|
||||
>
|
||||
|
||||
<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`}>
|
||||
<div className={`flex items-center ${bgColor} p-6 gap-x-4 border-b border-gray-900/5 bg-gray-50 dark:bg-dark-800 relative`}>
|
||||
|
||||
<Link
|
||||
href={`/courses/courses-view/?id=${item.id}`}
|
||||
className={'cursor-pointer'}
|
||||
>
|
||||
<ImageField
|
||||
name={'Avatar'}
|
||||
image={item.thumbnail}
|
||||
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.title}</p>
|
||||
<Link href={`/activities/activities-view/?id=${item.id}`} className='text-lg font-bold leading-6 line-clamp-1'>
|
||||
{item.subject}
|
||||
</Link>
|
||||
|
||||
|
||||
<div className='ml-auto md:absolute md:top-0 md:right-0 '>
|
||||
<div className='ml-auto '>
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={item.id}
|
||||
pathEdit={`/courses/courses-edit/?id=${item.id}`}
|
||||
pathView={`/courses/courses-view/?id=${item.id}`}
|
||||
pathEdit={`/activities/activities-edit/?id=${item.id}`}
|
||||
pathView={`/activities/activities-view/?id=${item.id}`}
|
||||
|
||||
hasUpdatePermission={hasUpdatePermission}
|
||||
|
||||
@ -87,10 +78,10 @@ const CardCourses = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Title</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Subject</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.title }
|
||||
{ item.subject }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -99,10 +90,10 @@ const CardCourses = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Description</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>ActivityType</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.description }
|
||||
{ item.activity_type }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -111,10 +102,10 @@ const CardCourses = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Instructor</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Start</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.usersOneListFormatter(item.instructor) }
|
||||
{ dataFormatter.dateTimeFormatter(item.start) }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -123,10 +114,10 @@ const CardCourses = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Category</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>End</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.category }
|
||||
{ dataFormatter.dateTimeFormatter(item.end) }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -135,10 +126,10 @@ const CardCourses = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Level</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Completed</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.level }
|
||||
{ dataFormatter.booleanFormatter(item.completed) }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -147,14 +138,10 @@ const CardCourses = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Thumbnail</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Owner</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium'>
|
||||
<ImageField
|
||||
name={'Avatar'}
|
||||
image={item.thumbnail}
|
||||
className='mx-auto w-8 h-8'
|
||||
/>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.usersOneListFormatter(item.owner) }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -163,10 +150,10 @@ const CardCourses = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Published</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>RelatedDeal</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.booleanFormatter(item.published) }
|
||||
{ dataFormatter.dealsOneListFormatter(item.related_deal) }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -175,10 +162,10 @@ const CardCourses = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>StartDate</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>RelatedLead</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.dateTimeFormatter(item.start_date) }
|
||||
{ dataFormatter.leadsOneListFormatter(item.related_lead) }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -187,34 +174,10 @@ const CardCourses = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>EndDate</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Notes</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.dateTimeFormatter(item.end_date) }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Price</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.price }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Language</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.language }
|
||||
{ item.notes }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -224,7 +187,7 @@ const CardCourses = ({
|
||||
</dl>
|
||||
</li>
|
||||
))}
|
||||
{!loading && courses.length === 0 && (
|
||||
{!loading && activities.length === 0 && (
|
||||
<div className='col-span-full flex items-center justify-center h-40'>
|
||||
<p className=''>No data to display</p>
|
||||
</div>
|
||||
@ -241,4 +204,4 @@ const CardCourses = ({
|
||||
);
|
||||
};
|
||||
|
||||
export default CardCourses;
|
||||
export default CardActivities;
|
||||
@ -13,7 +13,7 @@ import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
type Props = {
|
||||
lessons: any[];
|
||||
activities: any[];
|
||||
loading: boolean;
|
||||
onDelete: (id: string) => void;
|
||||
currentPage: number;
|
||||
@ -21,10 +21,10 @@ type Props = {
|
||||
onPageChange: (page: number) => void;
|
||||
};
|
||||
|
||||
const ListLessons = ({ lessons, loading, onDelete, currentPage, numPages, onPageChange }: Props) => {
|
||||
const ListActivities = ({ activities, loading, onDelete, currentPage, numPages, onPageChange }: Props) => {
|
||||
|
||||
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_LESSONS')
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_ACTIVITIES')
|
||||
|
||||
const corners = useAppSelector((state) => state.style.corners);
|
||||
const bgColor = useAppSelector((state) => state.style.cardsColor);
|
||||
@ -34,13 +34,13 @@ const ListLessons = ({ lessons, loading, onDelete, currentPage, numPages, onPage
|
||||
<>
|
||||
<div className='relative overflow-x-auto p-4 space-y-4'>
|
||||
{loading && <LoadingSpinner />}
|
||||
{!loading && lessons.map((item) => (
|
||||
{!loading && activities.map((item) => (
|
||||
<div key={item.id}>
|
||||
<CardBox hasTable isList className={'rounded shadow-none'}>
|
||||
<div className={`flex rounded dark:bg-dark-900 border border-stone-300 items-center overflow-hidden`}>
|
||||
|
||||
<Link
|
||||
href={`/lessons/lessons-view/?id=${item.id}`}
|
||||
href={`/activities/activities-view/?id=${item.id}`}
|
||||
className={
|
||||
'flex-1 px-4 py-6 h-24 flex divide-x-2 divide-stone-300 items-center overflow-hidden`}> dark:divide-dark-700 overflow-x-auto'
|
||||
}
|
||||
@ -48,86 +48,72 @@ const ListLessons = ({ lessons, loading, onDelete, currentPage, numPages, onPage
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Title</p>
|
||||
<p className={'line-clamp-2'}>{ item.title }</p>
|
||||
<p className={'text-xs text-gray-500 '}>Subject</p>
|
||||
<p className={'line-clamp-2'}>{ item.subject }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Content</p>
|
||||
<p className={'line-clamp-2'}>{ item.content }</p>
|
||||
<p className={'text-xs text-gray-500 '}>ActivityType</p>
|
||||
<p className={'line-clamp-2'}>{ item.activity_type }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Course</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.coursesOneListFormatter(item.course) }</p>
|
||||
<p className={'text-xs text-gray-500 '}>Start</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.dateTimeFormatter(item.start) }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Order</p>
|
||||
<p className={'line-clamp-2'}>{ item.order }</p>
|
||||
<p className={'text-xs text-gray-500 '}>End</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.dateTimeFormatter(item.end) }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Duration(minutes)</p>
|
||||
<p className={'line-clamp-2'}>{ item.duration_minutes }</p>
|
||||
<p className={'text-xs text-gray-500 '}>Completed</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.booleanFormatter(item.completed) }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>VideoFiles</p>
|
||||
{dataFormatter.filesFormatter(item.video_files).map(link => (
|
||||
<button
|
||||
key={link.publicUrl}
|
||||
onClick={(e) => saveFile(e, link.publicUrl, link.name)}
|
||||
>
|
||||
{link.name}
|
||||
</button>
|
||||
))}
|
||||
<p className={'text-xs text-gray-500 '}>Owner</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.usersOneListFormatter(item.owner) }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Resources</p>
|
||||
{dataFormatter.filesFormatter(item.resources).map(link => (
|
||||
<button
|
||||
key={link.publicUrl}
|
||||
onClick={(e) => saveFile(e, link.publicUrl, link.name)}
|
||||
>
|
||||
{link.name}
|
||||
</button>
|
||||
))}
|
||||
<p className={'text-xs text-gray-500 '}>RelatedDeal</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.dealsOneListFormatter(item.related_deal) }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>ReleaseDate</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.dateTimeFormatter(item.release_date) }</p>
|
||||
<p className={'text-xs text-gray-500 '}>RelatedLead</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.leadsOneListFormatter(item.related_lead) }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Status</p>
|
||||
<p className={'line-clamp-2'}>{ item.status }</p>
|
||||
<p className={'text-xs text-gray-500 '}>Notes</p>
|
||||
<p className={'line-clamp-2'}>{ item.notes }</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -136,8 +122,8 @@ const ListLessons = ({ lessons, loading, onDelete, currentPage, numPages, onPage
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={item.id}
|
||||
pathEdit={`/lessons/lessons-edit/?id=${item.id}`}
|
||||
pathView={`/lessons/lessons-view/?id=${item.id}`}
|
||||
pathEdit={`/activities/activities-edit/?id=${item.id}`}
|
||||
pathView={`/activities/activities-view/?id=${item.id}`}
|
||||
|
||||
hasUpdatePermission={hasUpdatePermission}
|
||||
|
||||
@ -146,7 +132,7 @@ const ListLessons = ({ lessons, loading, onDelete, currentPage, numPages, onPage
|
||||
</CardBox>
|
||||
</div>
|
||||
))}
|
||||
{!loading && lessons.length === 0 && (
|
||||
{!loading && activities.length === 0 && (
|
||||
<div className='col-span-full flex items-center justify-center h-40'>
|
||||
<p className=''>No data to display</p>
|
||||
</div>
|
||||
@ -163,4 +149,4 @@ const ListLessons = ({ lessons, loading, onDelete, currentPage, numPages, onPage
|
||||
)
|
||||
};
|
||||
|
||||
export default ListLessons
|
||||
export default ListActivities
|
||||
@ -4,7 +4,7 @@ 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/courses/coursesSlice'
|
||||
import { fetch, update, deleteItem, setRefetch, deleteItemsByIds } from '../../stores/activities/activitiesSlice'
|
||||
import { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import { Field, Form, Formik } from "formik";
|
||||
@ -12,7 +12,7 @@ import {
|
||||
DataGrid,
|
||||
GridColDef,
|
||||
} from '@mui/x-data-grid';
|
||||
import {loadColumns} from "./configureCoursesCols";
|
||||
import {loadColumns} from "./configureActivitiesCols";
|
||||
import _ from 'lodash';
|
||||
import dataFormatter from '../../helpers/dataFormatter'
|
||||
import {dataGridStyles} from "../../styles";
|
||||
@ -24,7 +24,7 @@ import { SlotInfo } from 'react-big-calendar';
|
||||
|
||||
const perPage = 100
|
||||
|
||||
const TableSampleCourses = ({ filterItems, setFilterItems, filters, showGrid }) => {
|
||||
const TableSampleActivities = ({ filterItems, setFilterItems, filters, showGrid }) => {
|
||||
const notify = (type, msg) => toast( msg, {type, position: "bottom-center"});
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
@ -43,7 +43,7 @@ const TableSampleCourses = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
},
|
||||
]);
|
||||
|
||||
const { courses, loading, count, notify: coursesNotify, refetch } = useAppSelector((state) => state.courses)
|
||||
const { activities, loading, count, notify: activitiesNotify, refetch } = useAppSelector((state) => state.activities)
|
||||
const { currentUser } = useAppSelector((state) => state.auth);
|
||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
||||
@ -63,10 +63,10 @@ const TableSampleCourses = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (coursesNotify.showNotification) {
|
||||
notify(coursesNotify.typeNotification, coursesNotify.textNotification);
|
||||
if (activitiesNotify.showNotification) {
|
||||
notify(activitiesNotify.typeNotification, activitiesNotify.textNotification);
|
||||
}
|
||||
}, [coursesNotify.showNotification]);
|
||||
}, [activitiesNotify.showNotification]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentUser) return;
|
||||
@ -93,7 +93,7 @@ const TableSampleCourses = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
|
||||
const handleCreateEventAction = ({ start, end }: SlotInfo) => {
|
||||
router.push(
|
||||
`/courses/courses-new?dateRangeStart=${start.toISOString()}&dateRangeEnd=${end.toISOString()}`,
|
||||
`/activities/activities-new?dateRangeStart=${start.toISOString()}&dateRangeEnd=${end.toISOString()}`,
|
||||
);
|
||||
};
|
||||
|
||||
@ -186,7 +186,7 @@ const TableSampleCourses = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
|
||||
loadColumns(
|
||||
handleDeleteModalAction,
|
||||
`courses`,
|
||||
`activities`,
|
||||
currentUser,
|
||||
).then((newCols) => setColumns(newCols));
|
||||
}, [currentUser]);
|
||||
@ -224,7 +224,7 @@ const TableSampleCourses = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
sx={dataGridStyles}
|
||||
className={'datagrid--table'}
|
||||
getRowClassName={() => `datagrid--row`}
|
||||
rows={courses ?? []}
|
||||
rows={activities ?? []}
|
||||
columns={columns}
|
||||
initialState={{
|
||||
pagination: {
|
||||
@ -451,18 +451,18 @@ const TableSampleCourses = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
|
||||
{!showGrid && (
|
||||
<BigCalendar
|
||||
events={courses}
|
||||
showField={'title'}
|
||||
start-data-key={'start_date'}
|
||||
end-data-key={'end_date'}
|
||||
events={activities}
|
||||
showField={'subject'}
|
||||
start-data-key={'start'}
|
||||
end-data-key={'end'}
|
||||
handleDeleteAction={handleDeleteModalAction}
|
||||
pathEdit={`/courses/courses-edit/?id=`}
|
||||
pathView={`/courses/courses-view/?id=`}
|
||||
pathEdit={`/activities/activities-edit/?id=`}
|
||||
pathView={`/activities/activities-view/?id=`}
|
||||
handleCreateEventAction={handleCreateEventAction}
|
||||
onDateRangeChange={(range) => {
|
||||
loadData(0,`&calendarStart=${range.start}&calendarEnd=${range.end}`);
|
||||
}}
|
||||
entityName={'courses'}
|
||||
entityName={'activities'}
|
||||
/>
|
||||
)}
|
||||
|
||||
@ -486,4 +486,4 @@ const TableSampleCourses = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
)
|
||||
}
|
||||
|
||||
export default TableSampleCourses
|
||||
export default TableSampleActivities
|
||||
@ -37,13 +37,13 @@ export const loadColumns = async (
|
||||
}
|
||||
}
|
||||
|
||||
const hasUpdatePermission = hasPermission(user, 'UPDATE_LESSONS')
|
||||
const hasUpdatePermission = hasPermission(user, 'UPDATE_ACTIVITIES')
|
||||
|
||||
return [
|
||||
|
||||
{
|
||||
field: 'title',
|
||||
headerName: 'Title',
|
||||
field: 'subject',
|
||||
headerName: 'Subject',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
@ -57,8 +57,8 @@ export const loadColumns = async (
|
||||
},
|
||||
|
||||
{
|
||||
field: 'content',
|
||||
headerName: 'Content',
|
||||
field: 'activity_type',
|
||||
headerName: 'ActivityType',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
@ -72,8 +72,60 @@ export const loadColumns = async (
|
||||
},
|
||||
|
||||
{
|
||||
field: 'course',
|
||||
headerName: 'Course',
|
||||
field: 'start',
|
||||
headerName: 'Start',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'dateTime',
|
||||
valueGetter: (params: GridValueGetterParams) =>
|
||||
new Date(params.row.start),
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'end',
|
||||
headerName: 'End',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'dateTime',
|
||||
valueGetter: (params: GridValueGetterParams) =>
|
||||
new Date(params.row.end),
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'completed',
|
||||
headerName: 'Completed',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'boolean',
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'owner',
|
||||
headerName: 'Owner',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
@ -87,15 +139,15 @@ export const loadColumns = async (
|
||||
type: 'singleSelect',
|
||||
getOptionValue: (value: any) => value?.id,
|
||||
getOptionLabel: (value: any) => value?.label,
|
||||
valueOptions: await callOptionsApi('courses'),
|
||||
valueOptions: await callOptionsApi('users'),
|
||||
valueGetter: (params: GridValueGetterParams) =>
|
||||
params?.value?.id ?? params?.value,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'order',
|
||||
headerName: 'Order',
|
||||
field: 'related_deal',
|
||||
headerName: 'RelatedDeal',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
@ -105,99 +157,41 @@ export const loadColumns = async (
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'number',
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'duration_minutes',
|
||||
headerName: 'Duration(minutes)',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'number',
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'video_files',
|
||||
headerName: 'VideoFiles',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: false,
|
||||
sortable: false,
|
||||
renderCell: (params: GridValueGetterParams) => (
|
||||
<>
|
||||
{dataFormatter.filesFormatter(params.row.video_files).map(link => (
|
||||
<button
|
||||
key={link.publicUrl}
|
||||
onClick={(e) => saveFile(e, link.publicUrl, link.name)}
|
||||
>
|
||||
{link.name}
|
||||
</button>
|
||||
))}
|
||||
</>
|
||||
),
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'resources',
|
||||
headerName: 'Resources',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: false,
|
||||
sortable: false,
|
||||
renderCell: (params: GridValueGetterParams) => (
|
||||
<>
|
||||
{dataFormatter.filesFormatter(params.row.resources).map(link => (
|
||||
<button
|
||||
key={link.publicUrl}
|
||||
onClick={(e) => saveFile(e, link.publicUrl, link.name)}
|
||||
>
|
||||
{link.name}
|
||||
</button>
|
||||
))}
|
||||
</>
|
||||
),
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'release_date',
|
||||
headerName: 'ReleaseDate',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'dateTime',
|
||||
type: 'singleSelect',
|
||||
getOptionValue: (value: any) => value?.id,
|
||||
getOptionLabel: (value: any) => value?.label,
|
||||
valueOptions: await callOptionsApi('deals'),
|
||||
valueGetter: (params: GridValueGetterParams) =>
|
||||
new Date(params.row.release_date),
|
||||
params?.value?.id ?? params?.value,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'status',
|
||||
headerName: 'Status',
|
||||
field: 'related_lead',
|
||||
headerName: 'RelatedLead',
|
||||
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('leads'),
|
||||
valueGetter: (params: GridValueGetterParams) =>
|
||||
params?.value?.id ?? params?.value,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'notes',
|
||||
headerName: 'Notes',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
@ -223,8 +217,8 @@ export const loadColumns = async (
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={params?.row?.id}
|
||||
pathEdit={`/lessons/lessons-edit/?id=${params?.row?.id}`}
|
||||
pathView={`/lessons/lessons-view/?id=${params?.row?.id}`}
|
||||
pathEdit={`/activities/activities-edit/?id=${params?.row?.id}`}
|
||||
pathView={`/activities/activities-view/?id=${params?.row?.id}`}
|
||||
|
||||
hasUpdatePermission={hasUpdatePermission}
|
||||
|
||||
@ -39,7 +39,7 @@ export default function AsideMenuLayer({ menu, className = '', ...props }: Props
|
||||
>
|
||||
<div className="text-center flex-1 lg:text-left lg:pl-6 xl:text-center xl:pl-0">
|
||||
|
||||
<b className="font-black">Instructor-Student LMS</b>
|
||||
<b className="font-black">Sales Pipeline CRM</b>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@ -12,7 +12,7 @@ import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
type Props = {
|
||||
progress: any[];
|
||||
contacts: any[];
|
||||
loading: boolean;
|
||||
onDelete: (id: string) => void;
|
||||
currentPage: number;
|
||||
@ -20,8 +20,8 @@ type Props = {
|
||||
onPageChange: (page: number) => void;
|
||||
};
|
||||
|
||||
const CardProgress = ({
|
||||
progress,
|
||||
const CardContacts = ({
|
||||
contacts,
|
||||
loading,
|
||||
onDelete,
|
||||
currentPage,
|
||||
@ -37,7 +37,7 @@ const CardProgress = ({
|
||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||
|
||||
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_PROGRESS')
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_CONTACTS')
|
||||
|
||||
|
||||
return (
|
||||
@ -47,7 +47,7 @@ const CardProgress = ({
|
||||
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 && progress.map((item, index) => (
|
||||
{!loading && contacts.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 ${
|
||||
@ -57,8 +57,8 @@ const CardProgress = ({
|
||||
|
||||
<div className={`flex items-center ${bgColor} p-6 gap-x-4 border-b border-gray-900/5 bg-gray-50 dark:bg-dark-800 relative`}>
|
||||
|
||||
<Link href={`/progress/progress-view/?id=${item.id}`} className='text-lg font-bold leading-6 line-clamp-1'>
|
||||
{item.note}
|
||||
<Link href={`/contacts/contacts-view/?id=${item.id}`} className='text-lg font-bold leading-6 line-clamp-1'>
|
||||
{item.name}
|
||||
</Link>
|
||||
|
||||
|
||||
@ -66,8 +66,8 @@ const CardProgress = ({
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={item.id}
|
||||
pathEdit={`/progress/progress-edit/?id=${item.id}`}
|
||||
pathView={`/progress/progress-view/?id=${item.id}`}
|
||||
pathEdit={`/contacts/contacts-edit/?id=${item.id}`}
|
||||
pathView={`/contacts/contacts-view/?id=${item.id}`}
|
||||
|
||||
hasUpdatePermission={hasUpdatePermission}
|
||||
|
||||
@ -78,10 +78,10 @@ const CardProgress = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Note</dt>
|
||||
<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.note }
|
||||
{ item.name }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -90,10 +90,10 @@ const CardProgress = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Enrollment</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Email</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.enrollmentsOneListFormatter(item.enrollment) }
|
||||
{ item.email }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -102,10 +102,10 @@ const CardProgress = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Lesson</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Phone</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.lessonsOneListFormatter(item.lesson) }
|
||||
{ item.phone }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -114,10 +114,10 @@ const CardProgress = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Completed</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>JobTitle</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.booleanFormatter(item.completed) }
|
||||
{ item.title }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -126,10 +126,10 @@ const CardProgress = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>CompletedAt</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Company</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.dateTimeFormatter(item.completed_at) }
|
||||
{ item.company }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -138,10 +138,10 @@ const CardProgress = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Score</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Owner</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.score }
|
||||
{ dataFormatter.usersOneListFormatter(item.owner) }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -150,10 +150,10 @@ const CardProgress = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Attempts</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Notes</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.attempts }
|
||||
{ item.notes }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -163,7 +163,7 @@ const CardProgress = ({
|
||||
</dl>
|
||||
</li>
|
||||
))}
|
||||
{!loading && progress.length === 0 && (
|
||||
{!loading && contacts.length === 0 && (
|
||||
<div className='col-span-full flex items-center justify-center h-40'>
|
||||
<p className=''>No data to display</p>
|
||||
</div>
|
||||
@ -180,4 +180,4 @@ const CardProgress = ({
|
||||
);
|
||||
};
|
||||
|
||||
export default CardProgress;
|
||||
export default CardContacts;
|
||||
@ -13,7 +13,7 @@ import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
type Props = {
|
||||
progress: any[];
|
||||
contacts: any[];
|
||||
loading: boolean;
|
||||
onDelete: (id: string) => void;
|
||||
currentPage: number;
|
||||
@ -21,10 +21,10 @@ type Props = {
|
||||
onPageChange: (page: number) => void;
|
||||
};
|
||||
|
||||
const ListProgress = ({ progress, loading, onDelete, currentPage, numPages, onPageChange }: Props) => {
|
||||
const ListContacts = ({ contacts, loading, onDelete, currentPage, numPages, onPageChange }: Props) => {
|
||||
|
||||
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_PROGRESS')
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_CONTACTS')
|
||||
|
||||
const corners = useAppSelector((state) => state.style.corners);
|
||||
const bgColor = useAppSelector((state) => state.style.cardsColor);
|
||||
@ -34,13 +34,13 @@ const ListProgress = ({ progress, loading, onDelete, currentPage, numPages, onPa
|
||||
<>
|
||||
<div className='relative overflow-x-auto p-4 space-y-4'>
|
||||
{loading && <LoadingSpinner />}
|
||||
{!loading && progress.map((item) => (
|
||||
{!loading && contacts.map((item) => (
|
||||
<div key={item.id}>
|
||||
<CardBox hasTable isList className={'rounded shadow-none'}>
|
||||
<div className={`flex rounded dark:bg-dark-900 border border-stone-300 items-center overflow-hidden`}>
|
||||
|
||||
<Link
|
||||
href={`/progress/progress-view/?id=${item.id}`}
|
||||
href={`/contacts/contacts-view/?id=${item.id}`}
|
||||
className={
|
||||
'flex-1 px-4 py-6 h-24 flex divide-x-2 divide-stone-300 items-center overflow-hidden`}> dark:divide-dark-700 overflow-x-auto'
|
||||
}
|
||||
@ -48,56 +48,56 @@ const ListProgress = ({ progress, loading, onDelete, currentPage, numPages, onPa
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Note</p>
|
||||
<p className={'line-clamp-2'}>{ item.note }</p>
|
||||
<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 '}>Enrollment</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.enrollmentsOneListFormatter(item.enrollment) }</p>
|
||||
<p className={'text-xs text-gray-500 '}>Email</p>
|
||||
<p className={'line-clamp-2'}>{ item.email }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Lesson</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.lessonsOneListFormatter(item.lesson) }</p>
|
||||
<p className={'text-xs text-gray-500 '}>Phone</p>
|
||||
<p className={'line-clamp-2'}>{ item.phone }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Completed</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.booleanFormatter(item.completed) }</p>
|
||||
<p className={'text-xs text-gray-500 '}>JobTitle</p>
|
||||
<p className={'line-clamp-2'}>{ item.title }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>CompletedAt</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.dateTimeFormatter(item.completed_at) }</p>
|
||||
<p className={'text-xs text-gray-500 '}>Company</p>
|
||||
<p className={'line-clamp-2'}>{ item.company }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Score</p>
|
||||
<p className={'line-clamp-2'}>{ item.score }</p>
|
||||
<p className={'text-xs text-gray-500 '}>Owner</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.usersOneListFormatter(item.owner) }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Attempts</p>
|
||||
<p className={'line-clamp-2'}>{ item.attempts }</p>
|
||||
<p className={'text-xs text-gray-500 '}>Notes</p>
|
||||
<p className={'line-clamp-2'}>{ item.notes }</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -106,8 +106,8 @@ const ListProgress = ({ progress, loading, onDelete, currentPage, numPages, onPa
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={item.id}
|
||||
pathEdit={`/progress/progress-edit/?id=${item.id}`}
|
||||
pathView={`/progress/progress-view/?id=${item.id}`}
|
||||
pathEdit={`/contacts/contacts-edit/?id=${item.id}`}
|
||||
pathView={`/contacts/contacts-view/?id=${item.id}`}
|
||||
|
||||
hasUpdatePermission={hasUpdatePermission}
|
||||
|
||||
@ -116,7 +116,7 @@ const ListProgress = ({ progress, loading, onDelete, currentPage, numPages, onPa
|
||||
</CardBox>
|
||||
</div>
|
||||
))}
|
||||
{!loading && progress.length === 0 && (
|
||||
{!loading && contacts.length === 0 && (
|
||||
<div className='col-span-full flex items-center justify-center h-40'>
|
||||
<p className=''>No data to display</p>
|
||||
</div>
|
||||
@ -133,4 +133,4 @@ const ListProgress = ({ progress, loading, onDelete, currentPage, numPages, onPa
|
||||
)
|
||||
};
|
||||
|
||||
export default ListProgress
|
||||
export default ListContacts
|
||||
@ -4,7 +4,7 @@ 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/progress/progressSlice'
|
||||
import { fetch, update, deleteItem, setRefetch, deleteItemsByIds } from '../../stores/contacts/contactsSlice'
|
||||
import { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import { Field, Form, Formik } from "formik";
|
||||
@ -12,18 +12,18 @@ import {
|
||||
DataGrid,
|
||||
GridColDef,
|
||||
} from '@mui/x-data-grid';
|
||||
import {loadColumns} from "./configureProgressCols";
|
||||
import {loadColumns} from "./configureContactsCols";
|
||||
import _ from 'lodash';
|
||||
import dataFormatter from '../../helpers/dataFormatter'
|
||||
import {dataGridStyles} from "../../styles";
|
||||
|
||||
|
||||
import ListProgress from './ListProgress';
|
||||
import ListContacts from './ListContacts';
|
||||
|
||||
|
||||
const perPage = 10
|
||||
|
||||
const TableSampleProgress = ({ filterItems, setFilterItems, filters, showGrid }) => {
|
||||
const TableSampleContacts = ({ filterItems, setFilterItems, filters, showGrid }) => {
|
||||
const notify = (type, msg) => toast( msg, {type, position: "bottom-center"});
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
@ -42,7 +42,7 @@ const TableSampleProgress = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
},
|
||||
]);
|
||||
|
||||
const { progress, loading, count, notify: progressNotify, refetch } = useAppSelector((state) => state.progress)
|
||||
const { contacts, loading, count, notify: contactsNotify, refetch } = useAppSelector((state) => state.contacts)
|
||||
const { currentUser } = useAppSelector((state) => state.auth);
|
||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
||||
@ -62,10 +62,10 @@ const TableSampleProgress = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (progressNotify.showNotification) {
|
||||
notify(progressNotify.typeNotification, progressNotify.textNotification);
|
||||
if (contactsNotify.showNotification) {
|
||||
notify(contactsNotify.typeNotification, contactsNotify.textNotification);
|
||||
}
|
||||
}, [progressNotify.showNotification]);
|
||||
}, [contactsNotify.showNotification]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentUser) return;
|
||||
@ -179,7 +179,7 @@ const TableSampleProgress = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
|
||||
loadColumns(
|
||||
handleDeleteModalAction,
|
||||
`progress`,
|
||||
`contacts`,
|
||||
currentUser,
|
||||
).then((newCols) => setColumns(newCols));
|
||||
}, [currentUser]);
|
||||
@ -217,7 +217,7 @@ const TableSampleProgress = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
sx={dataGridStyles}
|
||||
className={'datagrid--table'}
|
||||
getRowClassName={() => `datagrid--row`}
|
||||
rows={progress ?? []}
|
||||
rows={contacts ?? []}
|
||||
columns={columns}
|
||||
initialState={{
|
||||
pagination: {
|
||||
@ -442,9 +442,9 @@ const TableSampleProgress = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
</CardBoxModal>
|
||||
|
||||
|
||||
{progress && Array.isArray(progress) && !showGrid && (
|
||||
<ListProgress
|
||||
progress={progress}
|
||||
{contacts && Array.isArray(contacts) && !showGrid && (
|
||||
<ListContacts
|
||||
contacts={contacts}
|
||||
loading={loading}
|
||||
onDelete={handleDeleteModalAction}
|
||||
currentPage={currentPage}
|
||||
@ -473,4 +473,4 @@ const TableSampleProgress = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
)
|
||||
}
|
||||
|
||||
export default TableSampleProgress
|
||||
export default TableSampleContacts
|
||||
@ -37,13 +37,13 @@ export const loadColumns = async (
|
||||
}
|
||||
}
|
||||
|
||||
const hasUpdatePermission = hasPermission(user, 'UPDATE_PROGRESS')
|
||||
const hasUpdatePermission = hasPermission(user, 'UPDATE_CONTACTS')
|
||||
|
||||
return [
|
||||
|
||||
{
|
||||
field: 'note',
|
||||
headerName: 'Note',
|
||||
field: 'name',
|
||||
headerName: 'Name',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
@ -57,8 +57,68 @@ export const loadColumns = async (
|
||||
},
|
||||
|
||||
{
|
||||
field: 'enrollment',
|
||||
headerName: 'Enrollment',
|
||||
field: 'email',
|
||||
headerName: 'Email',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'phone',
|
||||
headerName: 'Phone',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'title',
|
||||
headerName: 'JobTitle',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'company',
|
||||
headerName: 'Company',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'owner',
|
||||
headerName: 'Owner',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
@ -72,15 +132,15 @@ export const loadColumns = async (
|
||||
type: 'singleSelect',
|
||||
getOptionValue: (value: any) => value?.id,
|
||||
getOptionLabel: (value: any) => value?.label,
|
||||
valueOptions: await callOptionsApi('enrollments'),
|
||||
valueOptions: await callOptionsApi('users'),
|
||||
valueGetter: (params: GridValueGetterParams) =>
|
||||
params?.value?.id ?? params?.value,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'lesson',
|
||||
headerName: 'Lesson',
|
||||
field: 'notes',
|
||||
headerName: 'Notes',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
@ -90,80 +150,7 @@ export const loadColumns = async (
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
sortable: false,
|
||||
type: 'singleSelect',
|
||||
getOptionValue: (value: any) => value?.id,
|
||||
getOptionLabel: (value: any) => value?.label,
|
||||
valueOptions: await callOptionsApi('lessons'),
|
||||
valueGetter: (params: GridValueGetterParams) =>
|
||||
params?.value?.id ?? params?.value,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'completed',
|
||||
headerName: 'Completed',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'boolean',
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'completed_at',
|
||||
headerName: 'CompletedAt',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'dateTime',
|
||||
valueGetter: (params: GridValueGetterParams) =>
|
||||
new Date(params.row.completed_at),
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'score',
|
||||
headerName: 'Score',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'number',
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'attempts',
|
||||
headerName: 'Attempts',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'number',
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
@ -179,8 +166,8 @@ export const loadColumns = async (
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={params?.row?.id}
|
||||
pathEdit={`/progress/progress-edit/?id=${params?.row?.id}`}
|
||||
pathView={`/progress/progress-view/?id=${params?.row?.id}`}
|
||||
pathEdit={`/contacts/contacts-edit/?id=${params?.row?.id}`}
|
||||
pathView={`/contacts/contacts-view/?id=${params?.row?.id}`}
|
||||
|
||||
hasUpdatePermission={hasUpdatePermission}
|
||||
|
||||
@ -12,7 +12,7 @@ import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
type Props = {
|
||||
lessons: any[];
|
||||
deals: any[];
|
||||
loading: boolean;
|
||||
onDelete: (id: string) => void;
|
||||
currentPage: number;
|
||||
@ -20,8 +20,8 @@ type Props = {
|
||||
onPageChange: (page: number) => void;
|
||||
};
|
||||
|
||||
const CardLessons = ({
|
||||
lessons,
|
||||
const CardDeals = ({
|
||||
deals,
|
||||
loading,
|
||||
onDelete,
|
||||
currentPage,
|
||||
@ -37,7 +37,7 @@ const CardLessons = ({
|
||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||
|
||||
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_LESSONS')
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_DEALS')
|
||||
|
||||
|
||||
return (
|
||||
@ -47,7 +47,7 @@ const CardLessons = ({
|
||||
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 && lessons.map((item, index) => (
|
||||
{!loading && deals.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 ${
|
||||
@ -57,7 +57,7 @@ const CardLessons = ({
|
||||
|
||||
<div className={`flex items-center ${bgColor} p-6 gap-x-4 border-b border-gray-900/5 bg-gray-50 dark:bg-dark-800 relative`}>
|
||||
|
||||
<Link href={`/lessons/lessons-view/?id=${item.id}`} className='text-lg font-bold leading-6 line-clamp-1'>
|
||||
<Link href={`/deals/deals-view/?id=${item.id}`} className='text-lg font-bold leading-6 line-clamp-1'>
|
||||
{item.title}
|
||||
</Link>
|
||||
|
||||
@ -66,8 +66,8 @@ const CardLessons = ({
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={item.id}
|
||||
pathEdit={`/lessons/lessons-edit/?id=${item.id}`}
|
||||
pathView={`/lessons/lessons-view/?id=${item.id}`}
|
||||
pathEdit={`/deals/deals-edit/?id=${item.id}`}
|
||||
pathView={`/deals/deals-view/?id=${item.id}`}
|
||||
|
||||
hasUpdatePermission={hasUpdatePermission}
|
||||
|
||||
@ -90,10 +90,10 @@ const CardLessons = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Content</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>DealNumber</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.content }
|
||||
{ item.deal_number }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -102,10 +102,10 @@ const CardLessons = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Course</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Value</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.coursesOneListFormatter(item.course) }
|
||||
{ item.value }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -114,10 +114,10 @@ const CardLessons = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Order</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Currency</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.order }
|
||||
{ item.currency }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -126,60 +126,10 @@ const CardLessons = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Duration(minutes)</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Stage</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.duration_minutes }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>VideoFiles</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium'>
|
||||
{dataFormatter.filesFormatter(item.video_files).map(link => (
|
||||
<button
|
||||
key={link.publicUrl}
|
||||
onClick={(e) => saveFile(e, link.publicUrl, link.name)}
|
||||
>
|
||||
{link.name}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Resources</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium'>
|
||||
{dataFormatter.filesFormatter(item.resources).map(link => (
|
||||
<button
|
||||
key={link.publicUrl}
|
||||
onClick={(e) => saveFile(e, link.publicUrl, link.name)}
|
||||
>
|
||||
{link.name}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>ReleaseDate</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.dateTimeFormatter(item.release_date) }
|
||||
{ dataFormatter.pipeline_stagesOneListFormatter(item.stage) }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -198,10 +148,58 @@ const CardLessons = ({
|
||||
|
||||
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>CloseDate</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.dateTimeFormatter(item.close_date) }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Owner</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.usersOneListFormatter(item.owner) }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>PrimaryContact</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.contactsOneListFormatter(item.primary_contact) }
|
||||
</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>
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
</li>
|
||||
))}
|
||||
{!loading && lessons.length === 0 && (
|
||||
{!loading && deals.length === 0 && (
|
||||
<div className='col-span-full flex items-center justify-center h-40'>
|
||||
<p className=''>No data to display</p>
|
||||
</div>
|
||||
@ -218,4 +216,4 @@ const CardLessons = ({
|
||||
);
|
||||
};
|
||||
|
||||
export default CardLessons;
|
||||
export default CardDeals;
|
||||
@ -13,7 +13,7 @@ import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
type Props = {
|
||||
courses: any[];
|
||||
deals: any[];
|
||||
loading: boolean;
|
||||
onDelete: (id: string) => void;
|
||||
currentPage: number;
|
||||
@ -21,10 +21,10 @@ type Props = {
|
||||
onPageChange: (page: number) => void;
|
||||
};
|
||||
|
||||
const ListCourses = ({ courses, loading, onDelete, currentPage, numPages, onPageChange }: Props) => {
|
||||
const ListDeals = ({ deals, loading, onDelete, currentPage, numPages, onPageChange }: Props) => {
|
||||
|
||||
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_COURSES')
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_DEALS')
|
||||
|
||||
const corners = useAppSelector((state) => state.style.corners);
|
||||
const bgColor = useAppSelector((state) => state.style.cardsColor);
|
||||
@ -34,20 +34,13 @@ const ListCourses = ({ courses, loading, onDelete, currentPage, numPages, onPage
|
||||
<>
|
||||
<div className='relative overflow-x-auto p-4 space-y-4'>
|
||||
{loading && <LoadingSpinner />}
|
||||
{!loading && courses.map((item) => (
|
||||
{!loading && deals.map((item) => (
|
||||
<div key={item.id}>
|
||||
<CardBox hasTable isList className={'rounded shadow-none'}>
|
||||
<div className={`flex rounded dark:bg-dark-900 border border-stone-300 items-center overflow-hidden`}>
|
||||
|
||||
<ImageField
|
||||
name={'Avatar'}
|
||||
image={item.thumbnail}
|
||||
className='w-24 h-24 rounded-l overflow-hidden hidden md:block'
|
||||
imageClassName={'rounded-l rounded-r-none h-full object-cover'}
|
||||
/>
|
||||
|
||||
<Link
|
||||
href={`/courses/courses-view/?id=${item.id}`}
|
||||
href={`/deals/deals-view/?id=${item.id}`}
|
||||
className={
|
||||
'flex-1 px-4 py-6 h-24 flex divide-x-2 divide-stone-300 items-center overflow-hidden`}> dark:divide-dark-700 overflow-x-auto'
|
||||
}
|
||||
@ -62,6 +55,70 @@ const ListCourses = ({ courses, loading, onDelete, currentPage, numPages, onPage
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>DealNumber</p>
|
||||
<p className={'line-clamp-2'}>{ item.deal_number }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Value</p>
|
||||
<p className={'line-clamp-2'}>{ item.value }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Currency</p>
|
||||
<p className={'line-clamp-2'}>{ item.currency }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Stage</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.pipeline_stagesOneListFormatter(item.stage) }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Status</p>
|
||||
<p className={'line-clamp-2'}>{ item.status }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>CloseDate</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.dateTimeFormatter(item.close_date) }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Owner</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.usersOneListFormatter(item.owner) }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>PrimaryContact</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.contactsOneListFormatter(item.primary_contact) }</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>
|
||||
@ -69,88 +126,12 @@ const ListCourses = ({ courses, loading, onDelete, currentPage, numPages, onPage
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Instructor</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.usersOneListFormatter(item.instructor) }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Category</p>
|
||||
<p className={'line-clamp-2'}>{ item.category }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Level</p>
|
||||
<p className={'line-clamp-2'}>{ item.level }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Thumbnail</p>
|
||||
<ImageField
|
||||
name={'Avatar'}
|
||||
image={item.thumbnail}
|
||||
className='mx-auto w-8 h-8'
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Published</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.booleanFormatter(item.published) }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>StartDate</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.dateTimeFormatter(item.start_date) }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>EndDate</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.dateTimeFormatter(item.end_date) }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Price</p>
|
||||
<p className={'line-clamp-2'}>{ item.price }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Language</p>
|
||||
<p className={'line-clamp-2'}>{ item.language }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</Link>
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={item.id}
|
||||
pathEdit={`/courses/courses-edit/?id=${item.id}`}
|
||||
pathView={`/courses/courses-view/?id=${item.id}`}
|
||||
pathEdit={`/deals/deals-edit/?id=${item.id}`}
|
||||
pathView={`/deals/deals-view/?id=${item.id}`}
|
||||
|
||||
hasUpdatePermission={hasUpdatePermission}
|
||||
|
||||
@ -159,7 +140,7 @@ const ListCourses = ({ courses, loading, onDelete, currentPage, numPages, onPage
|
||||
</CardBox>
|
||||
</div>
|
||||
))}
|
||||
{!loading && courses.length === 0 && (
|
||||
{!loading && deals.length === 0 && (
|
||||
<div className='col-span-full flex items-center justify-center h-40'>
|
||||
<p className=''>No data to display</p>
|
||||
</div>
|
||||
@ -176,4 +157,4 @@ const ListCourses = ({ courses, loading, onDelete, currentPage, numPages, onPage
|
||||
)
|
||||
};
|
||||
|
||||
export default ListCourses
|
||||
export default ListDeals
|
||||
@ -4,7 +4,7 @@ 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/lessons/lessonsSlice'
|
||||
import { fetch, update, deleteItem, setRefetch, deleteItemsByIds } from '../../stores/deals/dealsSlice'
|
||||
import { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import { Field, Form, Formik } from "formik";
|
||||
@ -12,7 +12,7 @@ import {
|
||||
DataGrid,
|
||||
GridColDef,
|
||||
} from '@mui/x-data-grid';
|
||||
import {loadColumns} from "./configureLessonsCols";
|
||||
import {loadColumns} from "./configureDealsCols";
|
||||
import _ from 'lodash';
|
||||
import dataFormatter from '../../helpers/dataFormatter'
|
||||
import {dataGridStyles} from "../../styles";
|
||||
@ -24,7 +24,7 @@ import axios from 'axios';
|
||||
|
||||
const perPage = 10
|
||||
|
||||
const TableSampleLessons = ({ filterItems, setFilterItems, filters, showGrid }) => {
|
||||
const TableSampleDeals = ({ filterItems, setFilterItems, filters, showGrid }) => {
|
||||
const notify = (type, msg) => toast( msg, {type, position: "bottom-center"});
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
@ -46,7 +46,7 @@ const TableSampleLessons = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
const [kanbanColumns, setKanbanColumns] = useState<Array<{id: string, label: string}> | null>(null);
|
||||
const [kanbanFilters, setKanbanFilters] = useState('');
|
||||
|
||||
const { lessons, loading, count, notify: lessonsNotify, refetch } = useAppSelector((state) => state.lessons)
|
||||
const { deals, loading, count, notify: dealsNotify, refetch } = useAppSelector((state) => state.deals)
|
||||
const { currentUser } = useAppSelector((state) => state.auth);
|
||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
||||
@ -66,10 +66,10 @@ const TableSampleLessons = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (lessonsNotify.showNotification) {
|
||||
notify(lessonsNotify.typeNotification, lessonsNotify.textNotification);
|
||||
if (dealsNotify.showNotification) {
|
||||
notify(dealsNotify.typeNotification, dealsNotify.textNotification);
|
||||
}
|
||||
}, [lessonsNotify.showNotification]);
|
||||
}, [dealsNotify.showNotification]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentUser) return;
|
||||
@ -94,17 +94,18 @@ const TableSampleLessons = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
|
||||
|
||||
setKanbanColumns([
|
||||
|
||||
{ id: "draft", label: "draft" },
|
||||
|
||||
{ id: "published", label: "published" },
|
||||
|
||||
{ id: "archived", label: "archived" },
|
||||
|
||||
]);
|
||||
|
||||
|
||||
|
||||
axios.get('/pipeline_stages/autocomplete?limit=100')
|
||||
.then((res) => {
|
||||
setKanbanColumns(res.data);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('Error fetching kanban columns:', err);
|
||||
});
|
||||
|
||||
|
||||
|
||||
}, []);
|
||||
@ -206,7 +207,7 @@ const TableSampleLessons = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
|
||||
loadColumns(
|
||||
handleDeleteModalAction,
|
||||
`lessons`,
|
||||
`deals`,
|
||||
currentUser,
|
||||
).then((newCols) => setColumns(newCols));
|
||||
}, [currentUser]);
|
||||
@ -244,7 +245,7 @@ const TableSampleLessons = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
sx={dataGridStyles}
|
||||
className={'datagrid--table'}
|
||||
getRowClassName={() => `datagrid--row`}
|
||||
rows={lessons ?? []}
|
||||
rows={deals ?? []}
|
||||
columns={columns}
|
||||
initialState={{
|
||||
pagination: {
|
||||
@ -472,9 +473,9 @@ const TableSampleLessons = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
|
||||
{!showGrid && kanbanColumns && (
|
||||
<KanbanBoard
|
||||
columnFieldName={'status'}
|
||||
columnFieldName={'stage'}
|
||||
showFieldName={'title'}
|
||||
entityName={'lessons'}
|
||||
entityName={'deals'}
|
||||
filtersQuery={kanbanFilters}
|
||||
deleteThunk={deleteItem}
|
||||
updateThunk={update}
|
||||
@ -502,4 +503,4 @@ const TableSampleLessons = ({ filterItems, setFilterItems, filters, showGrid })
|
||||
)
|
||||
}
|
||||
|
||||
export default TableSampleLessons
|
||||
export default TableSampleDeals
|
||||
@ -37,7 +37,7 @@ export const loadColumns = async (
|
||||
}
|
||||
}
|
||||
|
||||
const hasUpdatePermission = hasPermission(user, 'UPDATE_COURSES')
|
||||
const hasUpdatePermission = hasPermission(user, 'UPDATE_DEALS')
|
||||
|
||||
return [
|
||||
|
||||
@ -57,8 +57,8 @@ export const loadColumns = async (
|
||||
},
|
||||
|
||||
{
|
||||
field: 'description',
|
||||
headerName: 'Description',
|
||||
field: 'deal_number',
|
||||
headerName: 'DealNumber',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
@ -72,8 +72,94 @@ export const loadColumns = async (
|
||||
},
|
||||
|
||||
{
|
||||
field: 'instructor',
|
||||
headerName: 'Instructor',
|
||||
field: 'value',
|
||||
headerName: 'Value',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'number',
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'currency',
|
||||
headerName: 'Currency',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'stage',
|
||||
headerName: 'Stage',
|
||||
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('pipeline_stages'),
|
||||
valueGetter: (params: GridValueGetterParams) =>
|
||||
params?.value?.id ?? params?.value,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'status',
|
||||
headerName: 'Status',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'close_date',
|
||||
headerName: 'CloseDate',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'dateTime',
|
||||
valueGetter: (params: GridValueGetterParams) =>
|
||||
new Date(params.row.close_date),
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'owner',
|
||||
headerName: 'Owner',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
@ -94,8 +180,8 @@ export const loadColumns = async (
|
||||
},
|
||||
|
||||
{
|
||||
field: 'category',
|
||||
headerName: 'Category',
|
||||
field: 'primary_contact',
|
||||
headerName: 'PrimaryContact',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
@ -105,116 +191,19 @@ export const loadColumns = async (
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'level',
|
||||
headerName: 'Level',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'thumbnail',
|
||||
headerName: 'Thumbnail',
|
||||
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?.thumbnail}
|
||||
className='w-24 h-24 mx-auto lg:w-6 lg:h-6'
|
||||
/>
|
||||
),
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'published',
|
||||
headerName: 'Published',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'boolean',
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'start_date',
|
||||
headerName: 'StartDate',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'dateTime',
|
||||
type: 'singleSelect',
|
||||
getOptionValue: (value: any) => value?.id,
|
||||
getOptionLabel: (value: any) => value?.label,
|
||||
valueOptions: await callOptionsApi('contacts'),
|
||||
valueGetter: (params: GridValueGetterParams) =>
|
||||
new Date(params.row.start_date),
|
||||
params?.value?.id ?? params?.value,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'end_date',
|
||||
headerName: 'EndDate',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'dateTime',
|
||||
valueGetter: (params: GridValueGetterParams) =>
|
||||
new Date(params.row.end_date),
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'price',
|
||||
headerName: 'Price',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'number',
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'language',
|
||||
headerName: 'Language',
|
||||
field: 'description',
|
||||
headerName: 'Description',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
@ -240,8 +229,8 @@ export const loadColumns = async (
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={params?.row?.id}
|
||||
pathEdit={`/courses/courses-edit/?id=${params?.row?.id}`}
|
||||
pathView={`/courses/courses-view/?id=${params?.row?.id}`}
|
||||
pathEdit={`/deals/deals-edit/?id=${params?.row?.id}`}
|
||||
pathView={`/deals/deals-view/?id=${params?.row?.id}`}
|
||||
|
||||
hasUpdatePermission={hasUpdatePermission}
|
||||
|
||||
@ -12,7 +12,7 @@ import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
type Props = {
|
||||
enrollments: any[];
|
||||
leads: any[];
|
||||
loading: boolean;
|
||||
onDelete: (id: string) => void;
|
||||
currentPage: number;
|
||||
@ -20,8 +20,8 @@ type Props = {
|
||||
onPageChange: (page: number) => void;
|
||||
};
|
||||
|
||||
const CardEnrollments = ({
|
||||
enrollments,
|
||||
const CardLeads = ({
|
||||
leads,
|
||||
loading,
|
||||
onDelete,
|
||||
currentPage,
|
||||
@ -37,7 +37,7 @@ const CardEnrollments = ({
|
||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||
|
||||
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_ENROLLMENTS')
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_LEADS')
|
||||
|
||||
|
||||
return (
|
||||
@ -47,7 +47,7 @@ const CardEnrollments = ({
|
||||
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 && enrollments.map((item, index) => (
|
||||
{!loading && leads.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 ${
|
||||
@ -57,8 +57,8 @@ const CardEnrollments = ({
|
||||
|
||||
<div className={`flex items-center ${bgColor} p-6 gap-x-4 border-b border-gray-900/5 bg-gray-50 dark:bg-dark-800 relative`}>
|
||||
|
||||
<Link href={`/enrollments/enrollments-view/?id=${item.id}`} className='text-lg font-bold leading-6 line-clamp-1'>
|
||||
{item.enrollment_label}
|
||||
<Link href={`/leads/leads-view/?id=${item.id}`} className='text-lg font-bold leading-6 line-clamp-1'>
|
||||
{item.name}
|
||||
</Link>
|
||||
|
||||
|
||||
@ -66,8 +66,8 @@ const CardEnrollments = ({
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={item.id}
|
||||
pathEdit={`/enrollments/enrollments-edit/?id=${item.id}`}
|
||||
pathView={`/enrollments/enrollments-view/?id=${item.id}`}
|
||||
pathEdit={`/leads/leads-edit/?id=${item.id}`}
|
||||
pathView={`/leads/leads-view/?id=${item.id}`}
|
||||
|
||||
hasUpdatePermission={hasUpdatePermission}
|
||||
|
||||
@ -78,10 +78,10 @@ const CardEnrollments = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>EnrollmentLabel</dt>
|
||||
<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.enrollment_label }
|
||||
{ item.name }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -90,10 +90,10 @@ const CardEnrollments = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Student</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Company</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.usersOneListFormatter(item.student) }
|
||||
{ item.company }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -102,10 +102,10 @@ const CardEnrollments = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Course</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Email</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.coursesOneListFormatter(item.course) }
|
||||
{ item.email }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -114,10 +114,22 @@ const CardEnrollments = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>EnrolledAt</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Phone</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.dateTimeFormatter(item.enrolled_at) }
|
||||
{ item.phone }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Source</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.source }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -138,10 +150,10 @@ const CardEnrollments = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>ProgressPercent</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Owner</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.progress_percent }
|
||||
{ dataFormatter.usersOneListFormatter(item.owner) }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -150,10 +162,22 @@ const CardEnrollments = ({
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>PricePaid</dt>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>EstimatedValue</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.price_paid }
|
||||
{ item.estimated_value }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Notes</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.notes }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
@ -163,7 +187,7 @@ const CardEnrollments = ({
|
||||
</dl>
|
||||
</li>
|
||||
))}
|
||||
{!loading && enrollments.length === 0 && (
|
||||
{!loading && leads.length === 0 && (
|
||||
<div className='col-span-full flex items-center justify-center h-40'>
|
||||
<p className=''>No data to display</p>
|
||||
</div>
|
||||
@ -180,4 +204,4 @@ const CardEnrollments = ({
|
||||
);
|
||||
};
|
||||
|
||||
export default CardEnrollments;
|
||||
export default CardLeads;
|
||||
@ -13,7 +13,7 @@ import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
type Props = {
|
||||
enrollments: any[];
|
||||
leads: any[];
|
||||
loading: boolean;
|
||||
onDelete: (id: string) => void;
|
||||
currentPage: number;
|
||||
@ -21,10 +21,10 @@ type Props = {
|
||||
onPageChange: (page: number) => void;
|
||||
};
|
||||
|
||||
const ListEnrollments = ({ enrollments, loading, onDelete, currentPage, numPages, onPageChange }: Props) => {
|
||||
const ListLeads = ({ leads, loading, onDelete, currentPage, numPages, onPageChange }: Props) => {
|
||||
|
||||
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_ENROLLMENTS')
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_LEADS')
|
||||
|
||||
const corners = useAppSelector((state) => state.style.corners);
|
||||
const bgColor = useAppSelector((state) => state.style.cardsColor);
|
||||
@ -34,13 +34,13 @@ const ListEnrollments = ({ enrollments, loading, onDelete, currentPage, numPages
|
||||
<>
|
||||
<div className='relative overflow-x-auto p-4 space-y-4'>
|
||||
{loading && <LoadingSpinner />}
|
||||
{!loading && enrollments.map((item) => (
|
||||
{!loading && leads.map((item) => (
|
||||
<div key={item.id}>
|
||||
<CardBox hasTable isList className={'rounded shadow-none'}>
|
||||
<div className={`flex rounded dark:bg-dark-900 border border-stone-300 items-center overflow-hidden`}>
|
||||
|
||||
<Link
|
||||
href={`/enrollments/enrollments-view/?id=${item.id}`}
|
||||
href={`/leads/leads-view/?id=${item.id}`}
|
||||
className={
|
||||
'flex-1 px-4 py-6 h-24 flex divide-x-2 divide-stone-300 items-center overflow-hidden`}> dark:divide-dark-700 overflow-x-auto'
|
||||
}
|
||||
@ -48,32 +48,40 @@ const ListEnrollments = ({ enrollments, loading, onDelete, currentPage, numPages
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>EnrollmentLabel</p>
|
||||
<p className={'line-clamp-2'}>{ item.enrollment_label }</p>
|
||||
<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 '}>Student</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.usersOneListFormatter(item.student) }</p>
|
||||
<p className={'text-xs text-gray-500 '}>Company</p>
|
||||
<p className={'line-clamp-2'}>{ item.company }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Course</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.coursesOneListFormatter(item.course) }</p>
|
||||
<p className={'text-xs text-gray-500 '}>Email</p>
|
||||
<p className={'line-clamp-2'}>{ item.email }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>EnrolledAt</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.dateTimeFormatter(item.enrolled_at) }</p>
|
||||
<p className={'text-xs text-gray-500 '}>Phone</p>
|
||||
<p className={'line-clamp-2'}>{ item.phone }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Source</p>
|
||||
<p className={'line-clamp-2'}>{ item.source }</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -88,16 +96,24 @@ const ListEnrollments = ({ enrollments, loading, onDelete, currentPage, numPages
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>ProgressPercent</p>
|
||||
<p className={'line-clamp-2'}>{ item.progress_percent }</p>
|
||||
<p className={'text-xs text-gray-500 '}>Owner</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.usersOneListFormatter(item.owner) }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>PricePaid</p>
|
||||
<p className={'line-clamp-2'}>{ item.price_paid }</p>
|
||||
<p className={'text-xs text-gray-500 '}>EstimatedValue</p>
|
||||
<p className={'line-clamp-2'}>{ item.estimated_value }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Notes</p>
|
||||
<p className={'line-clamp-2'}>{ item.notes }</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -106,8 +122,8 @@ const ListEnrollments = ({ enrollments, loading, onDelete, currentPage, numPages
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={item.id}
|
||||
pathEdit={`/enrollments/enrollments-edit/?id=${item.id}`}
|
||||
pathView={`/enrollments/enrollments-view/?id=${item.id}`}
|
||||
pathEdit={`/leads/leads-edit/?id=${item.id}`}
|
||||
pathView={`/leads/leads-view/?id=${item.id}`}
|
||||
|
||||
hasUpdatePermission={hasUpdatePermission}
|
||||
|
||||
@ -116,7 +132,7 @@ const ListEnrollments = ({ enrollments, loading, onDelete, currentPage, numPages
|
||||
</CardBox>
|
||||
</div>
|
||||
))}
|
||||
{!loading && enrollments.length === 0 && (
|
||||
{!loading && leads.length === 0 && (
|
||||
<div className='col-span-full flex items-center justify-center h-40'>
|
||||
<p className=''>No data to display</p>
|
||||
</div>
|
||||
@ -133,4 +149,4 @@ const ListEnrollments = ({ enrollments, loading, onDelete, currentPage, numPages
|
||||
)
|
||||
};
|
||||
|
||||
export default ListEnrollments
|
||||
export default ListLeads
|
||||
@ -4,7 +4,7 @@ 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/enrollments/enrollmentsSlice'
|
||||
import { fetch, update, deleteItem, setRefetch, deleteItemsByIds } from '../../stores/leads/leadsSlice'
|
||||
import { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import { Field, Form, Formik } from "formik";
|
||||
@ -12,7 +12,7 @@ import {
|
||||
DataGrid,
|
||||
GridColDef,
|
||||
} from '@mui/x-data-grid';
|
||||
import {loadColumns} from "./configureEnrollmentsCols";
|
||||
import {loadColumns} from "./configureLeadsCols";
|
||||
import _ from 'lodash';
|
||||
import dataFormatter from '../../helpers/dataFormatter'
|
||||
import {dataGridStyles} from "../../styles";
|
||||
@ -21,7 +21,7 @@ import {dataGridStyles} from "../../styles";
|
||||
|
||||
const perPage = 10
|
||||
|
||||
const TableSampleEnrollments = ({ filterItems, setFilterItems, filters, showGrid }) => {
|
||||
const TableSampleLeads = ({ filterItems, setFilterItems, filters, showGrid }) => {
|
||||
const notify = (type, msg) => toast( msg, {type, position: "bottom-center"});
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
@ -40,7 +40,7 @@ const TableSampleEnrollments = ({ filterItems, setFilterItems, filters, showGrid
|
||||
},
|
||||
]);
|
||||
|
||||
const { enrollments, loading, count, notify: enrollmentsNotify, refetch } = useAppSelector((state) => state.enrollments)
|
||||
const { leads, loading, count, notify: leadsNotify, refetch } = useAppSelector((state) => state.leads)
|
||||
const { currentUser } = useAppSelector((state) => state.auth);
|
||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
||||
@ -60,10 +60,10 @@ const TableSampleEnrollments = ({ filterItems, setFilterItems, filters, showGrid
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (enrollmentsNotify.showNotification) {
|
||||
notify(enrollmentsNotify.typeNotification, enrollmentsNotify.textNotification);
|
||||
if (leadsNotify.showNotification) {
|
||||
notify(leadsNotify.typeNotification, leadsNotify.textNotification);
|
||||
}
|
||||
}, [enrollmentsNotify.showNotification]);
|
||||
}, [leadsNotify.showNotification]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentUser) return;
|
||||
@ -177,7 +177,7 @@ const TableSampleEnrollments = ({ filterItems, setFilterItems, filters, showGrid
|
||||
|
||||
loadColumns(
|
||||
handleDeleteModalAction,
|
||||
`enrollments`,
|
||||
`leads`,
|
||||
currentUser,
|
||||
).then((newCols) => setColumns(newCols));
|
||||
}, [currentUser]);
|
||||
@ -215,7 +215,7 @@ const TableSampleEnrollments = ({ filterItems, setFilterItems, filters, showGrid
|
||||
sx={dataGridStyles}
|
||||
className={'datagrid--table'}
|
||||
getRowClassName={() => `datagrid--row`}
|
||||
rows={enrollments ?? []}
|
||||
rows={leads ?? []}
|
||||
columns={columns}
|
||||
initialState={{
|
||||
pagination: {
|
||||
@ -460,4 +460,4 @@ const TableSampleEnrollments = ({ filterItems, setFilterItems, filters, showGrid
|
||||
)
|
||||
}
|
||||
|
||||
export default TableSampleEnrollments
|
||||
export default TableSampleLeads
|
||||
@ -37,13 +37,13 @@ export const loadColumns = async (
|
||||
}
|
||||
}
|
||||
|
||||
const hasUpdatePermission = hasPermission(user, 'UPDATE_ENROLLMENTS')
|
||||
const hasUpdatePermission = hasPermission(user, 'UPDATE_LEADS')
|
||||
|
||||
return [
|
||||
|
||||
{
|
||||
field: 'enrollment_label',
|
||||
headerName: 'EnrollmentLabel',
|
||||
field: 'name',
|
||||
headerName: 'Name',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
@ -57,8 +57,83 @@ export const loadColumns = async (
|
||||
},
|
||||
|
||||
{
|
||||
field: 'student',
|
||||
headerName: 'Student',
|
||||
field: 'company',
|
||||
headerName: 'Company',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'email',
|
||||
headerName: 'Email',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'phone',
|
||||
headerName: 'Phone',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'source',
|
||||
headerName: 'Source',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'status',
|
||||
headerName: 'Status',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'owner',
|
||||
headerName: 'Owner',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
@ -79,63 +154,8 @@ export const loadColumns = async (
|
||||
},
|
||||
|
||||
{
|
||||
field: 'course',
|
||||
headerName: 'Course',
|
||||
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('courses'),
|
||||
valueGetter: (params: GridValueGetterParams) =>
|
||||
params?.value?.id ?? params?.value,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'enrolled_at',
|
||||
headerName: 'EnrolledAt',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'dateTime',
|
||||
valueGetter: (params: GridValueGetterParams) =>
|
||||
new Date(params.row.enrolled_at),
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'status',
|
||||
headerName: 'Status',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'progress_percent',
|
||||
headerName: 'ProgressPercent',
|
||||
field: 'estimated_value',
|
||||
headerName: 'EstimatedValue',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
@ -150,8 +170,8 @@ export const loadColumns = async (
|
||||
},
|
||||
|
||||
{
|
||||
field: 'price_paid',
|
||||
headerName: 'PricePaid',
|
||||
field: 'notes',
|
||||
headerName: 'Notes',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
@ -161,8 +181,7 @@ export const loadColumns = async (
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'number',
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
@ -178,8 +197,8 @@ export const loadColumns = async (
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={params?.row?.id}
|
||||
pathEdit={`/enrollments/enrollments-edit/?id=${params?.row?.id}`}
|
||||
pathView={`/enrollments/enrollments-view/?id=${params?.row?.id}`}
|
||||
pathEdit={`/leads/leads-edit/?id=${params?.row?.id}`}
|
||||
pathView={`/leads/leads-view/?id=${params?.row?.id}`}
|
||||
|
||||
hasUpdatePermission={hasUpdatePermission}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import React, {useEffect, useRef} from 'react'
|
||||
import React, {useEffect, useRef, useState} from 'react'
|
||||
import Link from 'next/link'
|
||||
import { useState } from 'react'
|
||||
import { mdiChevronUp, mdiChevronDown } from '@mdi/js'
|
||||
import BaseDivider from './BaseDivider'
|
||||
import BaseIcon from './BaseIcon'
|
||||
@ -129,4 +128,4 @@ export default function NavBarItem({ item }: Props) {
|
||||
}
|
||||
|
||||
return <div className={componentClass} ref={excludedRef}>{NavBarItemComponentContents}</div>
|
||||
}
|
||||
}
|
||||
147
frontend/src/components/Pipeline_stages/CardPipeline_stages.tsx
Normal file
147
frontend/src/components/Pipeline_stages/CardPipeline_stages.tsx
Normal file
@ -0,0 +1,147 @@
|
||||
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 = {
|
||||
pipeline_stages: any[];
|
||||
loading: boolean;
|
||||
onDelete: (id: string) => void;
|
||||
currentPage: number;
|
||||
numPages: number;
|
||||
onPageChange: (page: number) => void;
|
||||
};
|
||||
|
||||
const CardPipeline_stages = ({
|
||||
pipeline_stages,
|
||||
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_PIPELINE_STAGES')
|
||||
|
||||
|
||||
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 && pipeline_stages.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 gap-x-4 border-b border-gray-900/5 bg-gray-50 dark:bg-dark-800 relative`}>
|
||||
|
||||
<Link href={`/pipeline_stages/pipeline_stages-view/?id=${item.id}`} className='text-lg font-bold leading-6 line-clamp-1'>
|
||||
{item.title}
|
||||
</Link>
|
||||
|
||||
|
||||
<div className='ml-auto '>
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={item.id}
|
||||
pathEdit={`/pipeline_stages/pipeline_stages-edit/?id=${item.id}`}
|
||||
pathView={`/pipeline_stages/pipeline_stages-view/?id=${item.id}`}
|
||||
|
||||
hasUpdatePermission={hasUpdatePermission}
|
||||
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<dl className='divide-y divide-stone-300 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'>Title</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.title }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Order</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.order }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>Probability</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.probability }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className=' text-gray-500 dark:text-dark-600'>IsDefault</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ dataFormatter.booleanFormatter(item.is_default) }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
</li>
|
||||
))}
|
||||
{!loading && pipeline_stages.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 CardPipeline_stages;
|
||||
112
frontend/src/components/Pipeline_stages/ListPipeline_stages.tsx
Normal file
112
frontend/src/components/Pipeline_stages/ListPipeline_stages.tsx
Normal file
@ -0,0 +1,112 @@
|
||||
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 = {
|
||||
pipeline_stages: any[];
|
||||
loading: boolean;
|
||||
onDelete: (id: string) => void;
|
||||
currentPage: number;
|
||||
numPages: number;
|
||||
onPageChange: (page: number) => void;
|
||||
};
|
||||
|
||||
const ListPipeline_stages = ({ pipeline_stages, loading, onDelete, currentPage, numPages, onPageChange }: Props) => {
|
||||
|
||||
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_PIPELINE_STAGES')
|
||||
|
||||
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 && pipeline_stages.map((item) => (
|
||||
<div key={item.id}>
|
||||
<CardBox hasTable isList className={'rounded shadow-none'}>
|
||||
<div className={`flex rounded dark:bg-dark-900 border border-stone-300 items-center overflow-hidden`}>
|
||||
|
||||
<Link
|
||||
href={`/pipeline_stages/pipeline_stages-view/?id=${item.id}`}
|
||||
className={
|
||||
'flex-1 px-4 py-6 h-24 flex divide-x-2 divide-stone-300 items-center overflow-hidden`}> dark:divide-dark-700 overflow-x-auto'
|
||||
}
|
||||
>
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Title</p>
|
||||
<p className={'line-clamp-2'}>{ item.title }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Order</p>
|
||||
<p className={'line-clamp-2'}>{ item.order }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>Probability</p>
|
||||
<p className={'line-clamp-2'}>{ item.probability }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500 '}>IsDefault</p>
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.booleanFormatter(item.is_default) }</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</Link>
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={item.id}
|
||||
pathEdit={`/pipeline_stages/pipeline_stages-edit/?id=${item.id}`}
|
||||
pathView={`/pipeline_stages/pipeline_stages-view/?id=${item.id}`}
|
||||
|
||||
hasUpdatePermission={hasUpdatePermission}
|
||||
|
||||
/>
|
||||
</div>
|
||||
</CardBox>
|
||||
</div>
|
||||
))}
|
||||
{!loading && pipeline_stages.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 ListPipeline_stages
|
||||
463
frontend/src/components/Pipeline_stages/TablePipeline_stages.tsx
Normal file
463
frontend/src/components/Pipeline_stages/TablePipeline_stages.tsx
Normal file
@ -0,0 +1,463 @@
|
||||
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/pipeline_stages/pipeline_stagesSlice'
|
||||
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 "./configurePipeline_stagesCols";
|
||||
import _ from 'lodash';
|
||||
import dataFormatter from '../../helpers/dataFormatter'
|
||||
import {dataGridStyles} from "../../styles";
|
||||
|
||||
|
||||
|
||||
const perPage = 10
|
||||
|
||||
const TableSamplePipeline_stages = ({ 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 { pipeline_stages, loading, count, notify: pipeline_stagesNotify, refetch } = useAppSelector((state) => state.pipeline_stages)
|
||||
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 (pipeline_stagesNotify.showNotification) {
|
||||
notify(pipeline_stagesNotify.typeNotification, pipeline_stagesNotify.textNotification);
|
||||
}
|
||||
}, [pipeline_stagesNotify.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,
|
||||
`pipeline_stages`,
|
||||
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={pipeline_stages ?? []}
|
||||
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"
|
||||
color="success"
|
||||
label='Apply'
|
||||
onClick={handleSubmit}
|
||||
/>
|
||||
<BaseButton
|
||||
className="my-2"
|
||||
color='info'
|
||||
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 TableSamplePipeline_stages
|
||||
@ -0,0 +1,131 @@
|
||||
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_PIPELINE_STAGES')
|
||||
|
||||
return [
|
||||
|
||||
{
|
||||
field: 'title',
|
||||
headerName: 'Title',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'order',
|
||||
headerName: 'Order',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'number',
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'probability',
|
||||
headerName: 'Probability',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'number',
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'is_default',
|
||||
headerName: 'IsDefault',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
|
||||
editable: hasUpdatePermission,
|
||||
|
||||
type: 'boolean',
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
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={`/pipeline_stages/pipeline_stages-edit/?id=${params?.row?.id}`}
|
||||
pathView={`/pipeline_stages/pipeline_stages-view/?id=${params?.row?.id}`}
|
||||
|
||||
hasUpdatePermission={hasUpdatePermission}
|
||||
|
||||
/>
|
||||
</div>,
|
||||
]
|
||||
},
|
||||
},
|
||||
];
|
||||
};
|
||||
@ -103,68 +103,89 @@ export default {
|
||||
|
||||
|
||||
|
||||
coursesManyListFormatter(val) {
|
||||
pipeline_stagesManyListFormatter(val) {
|
||||
if (!val || !val.length) return []
|
||||
return val.map((item) => item.title)
|
||||
},
|
||||
coursesOneListFormatter(val) {
|
||||
pipeline_stagesOneListFormatter(val) {
|
||||
if (!val) return ''
|
||||
return val.title
|
||||
},
|
||||
coursesManyListFormatterEdit(val) {
|
||||
pipeline_stagesManyListFormatterEdit(val) {
|
||||
if (!val || !val.length) return []
|
||||
return val.map((item) => {
|
||||
return {id: item.id, label: item.title}
|
||||
});
|
||||
},
|
||||
coursesOneListFormatterEdit(val) {
|
||||
pipeline_stagesOneListFormatterEdit(val) {
|
||||
if (!val) return ''
|
||||
return {label: val.title, id: val.id}
|
||||
},
|
||||
|
||||
|
||||
|
||||
lessonsManyListFormatter(val) {
|
||||
leadsManyListFormatter(val) {
|
||||
if (!val || !val.length) return []
|
||||
return val.map((item) => item.name)
|
||||
},
|
||||
leadsOneListFormatter(val) {
|
||||
if (!val) return ''
|
||||
return val.name
|
||||
},
|
||||
leadsManyListFormatterEdit(val) {
|
||||
if (!val || !val.length) return []
|
||||
return val.map((item) => {
|
||||
return {id: item.id, label: item.name}
|
||||
});
|
||||
},
|
||||
leadsOneListFormatterEdit(val) {
|
||||
if (!val) return ''
|
||||
return {label: val.name, id: val.id}
|
||||
},
|
||||
|
||||
|
||||
|
||||
contactsManyListFormatter(val) {
|
||||
if (!val || !val.length) return []
|
||||
return val.map((item) => item.name)
|
||||
},
|
||||
contactsOneListFormatter(val) {
|
||||
if (!val) return ''
|
||||
return val.name
|
||||
},
|
||||
contactsManyListFormatterEdit(val) {
|
||||
if (!val || !val.length) return []
|
||||
return val.map((item) => {
|
||||
return {id: item.id, label: item.name}
|
||||
});
|
||||
},
|
||||
contactsOneListFormatterEdit(val) {
|
||||
if (!val) return ''
|
||||
return {label: val.name, id: val.id}
|
||||
},
|
||||
|
||||
|
||||
|
||||
dealsManyListFormatter(val) {
|
||||
if (!val || !val.length) return []
|
||||
return val.map((item) => item.title)
|
||||
},
|
||||
lessonsOneListFormatter(val) {
|
||||
dealsOneListFormatter(val) {
|
||||
if (!val) return ''
|
||||
return val.title
|
||||
},
|
||||
lessonsManyListFormatterEdit(val) {
|
||||
dealsManyListFormatterEdit(val) {
|
||||
if (!val || !val.length) return []
|
||||
return val.map((item) => {
|
||||
return {id: item.id, label: item.title}
|
||||
});
|
||||
},
|
||||
lessonsOneListFormatterEdit(val) {
|
||||
dealsOneListFormatterEdit(val) {
|
||||
if (!val) return ''
|
||||
return {label: val.title, id: val.id}
|
||||
},
|
||||
|
||||
|
||||
|
||||
enrollmentsManyListFormatter(val) {
|
||||
if (!val || !val.length) return []
|
||||
return val.map((item) => item.enrollment_label)
|
||||
},
|
||||
enrollmentsOneListFormatter(val) {
|
||||
if (!val) return ''
|
||||
return val.enrollment_label
|
||||
},
|
||||
enrollmentsManyListFormatterEdit(val) {
|
||||
if (!val || !val.length) return []
|
||||
return val.map((item) => {
|
||||
return {id: item.id, label: item.enrollment_label}
|
||||
});
|
||||
},
|
||||
enrollmentsOneListFormatterEdit(val) {
|
||||
if (!val) return ''
|
||||
return {label: val.enrollment_label, id: val.id}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import React, { ReactNode, useEffect } from 'react'
|
||||
import { useState } from 'react'
|
||||
import React, { ReactNode, useEffect, useState } from 'react'
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { mdiForwardburger, mdiBackburger, mdiMenu } from '@mdi/js'
|
||||
import menuAside from '../menuAside'
|
||||
@ -126,4 +125,4 @@ export default function LayoutAuthenticated({
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -33,36 +33,44 @@ const menuAside: MenuAsideItem[] = [
|
||||
permissions: 'READ_PERMISSIONS'
|
||||
},
|
||||
{
|
||||
href: '/courses/courses-list',
|
||||
label: 'Courses',
|
||||
href: '/pipeline_stages/pipeline_stages-list',
|
||||
label: 'Pipeline stages',
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
icon: 'mdiSchool' in icon ? icon['mdiSchool' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
||||
permissions: 'READ_COURSES'
|
||||
icon: 'mdiFormatListBulleted' in icon ? icon['mdiFormatListBulleted' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
||||
permissions: 'READ_PIPELINE_STAGES'
|
||||
},
|
||||
{
|
||||
href: '/lessons/lessons-list',
|
||||
label: 'Lessons',
|
||||
href: '/leads/leads-list',
|
||||
label: 'Leads',
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
icon: 'mdiBookOpen' in icon ? icon['mdiBookOpen' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
||||
permissions: 'READ_LESSONS'
|
||||
icon: 'mdiAccountPlus' in icon ? icon['mdiAccountPlus' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
||||
permissions: 'READ_LEADS'
|
||||
},
|
||||
{
|
||||
href: '/enrollments/enrollments-list',
|
||||
label: 'Enrollments',
|
||||
href: '/contacts/contacts-list',
|
||||
label: 'Contacts',
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
icon: 'mdiAccountMultiple' in icon ? icon['mdiAccountMultiple' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
||||
permissions: 'READ_ENROLLMENTS'
|
||||
icon: 'mdiAccount' in icon ? icon['mdiAccount' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
||||
permissions: 'READ_CONTACTS'
|
||||
},
|
||||
{
|
||||
href: '/progress/progress-list',
|
||||
label: 'Progress',
|
||||
href: '/deals/deals-list',
|
||||
label: 'Deals',
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
icon: 'mdiCheckCircle' in icon ? icon['mdiCheckCircle' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
||||
permissions: 'READ_PROGRESS'
|
||||
icon: 'mdiBriefcase' in icon ? icon['mdiBriefcase' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
||||
permissions: 'READ_DEALS'
|
||||
},
|
||||
{
|
||||
href: '/activities/activities-list',
|
||||
label: 'Activities',
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
icon: 'mdiCalendar' in icon ? icon['mdiCalendar' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
||||
permissions: 'READ_ACTIVITIES'
|
||||
},
|
||||
{
|
||||
href: '/profile',
|
||||
|
||||
@ -149,10 +149,10 @@ function MyApp({ Component, pageProps }: AppPropsWithLayout) {
|
||||
setStepsEnabled(false);
|
||||
};
|
||||
|
||||
const title = 'Instructor-Student LMS'
|
||||
const description = "Instructor-student LMS for courses, lessons, enrollments, and progress tracking."
|
||||
const title = 'Sales Pipeline CRM'
|
||||
const description = "Sales Pipeline CRM for managing leads, deals, contacts, activities and automated follow-ups."
|
||||
const url = "https://flatlogic.com/"
|
||||
const image = "https://project-screens.s3.amazonaws.com/screenshots/37612/app-hero-20260120-101908.png"
|
||||
const image = "https://project-screens.s3.amazonaws.com/screenshots/37742/app-hero-20260123-114942.png"
|
||||
const imageWidth = '1920'
|
||||
const imageHeight = '960'
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ import { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||
import { SwitchField } from '../../components/SwitchField'
|
||||
import {RichTextField} from "../../components/RichTextField";
|
||||
|
||||
import { update, fetch } from '../../stores/courses/coursesSlice'
|
||||
import { update, fetch } from '../../stores/activities/activitiesSlice'
|
||||
import { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import {saveFile} from "../../helpers/fileSaver";
|
||||
@ -34,13 +34,13 @@ import ImageField from "../../components/ImageField";
|
||||
|
||||
|
||||
|
||||
const EditCourses = () => {
|
||||
const EditActivities = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const initVals = {
|
||||
|
||||
|
||||
'title': '',
|
||||
'subject': '',
|
||||
|
||||
|
||||
|
||||
@ -72,8 +72,6 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
description: '',
|
||||
|
||||
|
||||
|
||||
|
||||
@ -86,7 +84,7 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
activity_type: '',
|
||||
|
||||
|
||||
|
||||
@ -94,13 +92,9 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -112,18 +106,14 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
start: new Date(),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
instructor: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -132,27 +122,19 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
category: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end: new Date(),
|
||||
|
||||
|
||||
|
||||
@ -168,16 +150,6 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
level: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -192,27 +164,21 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
completed: false,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
thumbnail: [],
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -220,8 +186,6 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
published: false,
|
||||
|
||||
|
||||
|
||||
|
||||
@ -234,19 +198,15 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
owner: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
start_date: new Date(),
|
||||
|
||||
|
||||
|
||||
@ -262,8 +222,6 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -272,15 +230,11 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end_date: new Date(),
|
||||
related_deal: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -290,10 +244,6 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'price': '',
|
||||
|
||||
|
||||
|
||||
|
||||
@ -308,23 +258,17 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
related_lead: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'language': '',
|
||||
|
||||
|
||||
|
||||
|
||||
notes: '',
|
||||
|
||||
|
||||
|
||||
@ -351,44 +295,44 @@ const EditCourses = () => {
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
const { courses } = useAppSelector((state) => state.courses)
|
||||
const { activities } = useAppSelector((state) => state.activities)
|
||||
|
||||
|
||||
const { coursesId } = router.query
|
||||
const { activitiesId } = router.query
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetch({ id: coursesId }))
|
||||
}, [coursesId])
|
||||
dispatch(fetch({ id: activitiesId }))
|
||||
}, [activitiesId])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof courses === 'object') {
|
||||
setInitialValues(courses)
|
||||
if (typeof activities === 'object') {
|
||||
setInitialValues(activities)
|
||||
}
|
||||
}, [courses])
|
||||
}, [activities])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof courses === 'object') {
|
||||
if (typeof activities === 'object') {
|
||||
|
||||
const newInitialVal = {...initVals};
|
||||
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (courses)[el])
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (activities)[el])
|
||||
|
||||
setInitialValues(newInitialVal);
|
||||
}
|
||||
}, [courses])
|
||||
}, [activities])
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(update({ id: coursesId, data }))
|
||||
await router.push('/courses/courses-list')
|
||||
await dispatch(update({ id: activitiesId, data }))
|
||||
await router.push('/activities/activities-list')
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Edit courses')}</title>
|
||||
<title>{getPageTitle('Edit activities')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit courses'} main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit activities'} main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
@ -402,11 +346,11 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
<FormField
|
||||
label="Title"
|
||||
label="Subject"
|
||||
>
|
||||
<Field
|
||||
name="title"
|
||||
placeholder="Title"
|
||||
name="subject"
|
||||
placeholder="Subject"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
@ -442,14 +386,6 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
<FormField label='Description' hasTextareaHeight>
|
||||
<Field
|
||||
name='description'
|
||||
id='description'
|
||||
component={RichTextField}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -460,106 +396,18 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Instructor' labelFor='instructor'>
|
||||
<Field
|
||||
name='instructor'
|
||||
id='instructor'
|
||||
component={SelectField}
|
||||
options={initialValues.instructor}
|
||||
itemRef={'users'}
|
||||
|
||||
|
||||
showField={'firstName'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Category" labelFor="category">
|
||||
<Field name="category" id="category" component="select">
|
||||
<FormField label="ActivityType" labelFor="activity_type">
|
||||
<Field name="activity_type" id="activity_type" component="select">
|
||||
|
||||
<option value="Programming">Programming</option>
|
||||
<option value="Call">Call</option>
|
||||
|
||||
<option value="Design">Design</option>
|
||||
<option value="Meeting">Meeting</option>
|
||||
|
||||
<option value="Math">Math</option>
|
||||
<option value="Email">Email</option>
|
||||
|
||||
<option value="Language">Language</option>
|
||||
<option value="Task">Task</option>
|
||||
|
||||
<option value="Business">Business</option>
|
||||
|
||||
<option value="Other">Other</option>
|
||||
<option value="FollowUp">FollowUp</option>
|
||||
|
||||
</Field>
|
||||
</FormField>
|
||||
@ -588,21 +436,67 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Start"
|
||||
>
|
||||
<DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={initialValues.start ?
|
||||
new Date(
|
||||
dayjs(initialValues.start).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
onChange={(date) => setInitialValues({...initialValues, 'start': date})}
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Level" labelFor="level">
|
||||
<Field name="level" id="level" component="select">
|
||||
|
||||
<option value="Beginner">Beginner</option>
|
||||
|
||||
<option value="Intermediate">Intermediate</option>
|
||||
|
||||
<option value="Advanced">Advanced</option>
|
||||
|
||||
</Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="End"
|
||||
>
|
||||
<DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={initialValues.end ?
|
||||
new Date(
|
||||
dayjs(initialValues.end).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
onChange={(date) => setInitialValues({...initialValues, 'end': date})}
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -634,54 +528,10 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField>
|
||||
<Field
|
||||
label='Thumbnail'
|
||||
color='info'
|
||||
icon={mdiUpload}
|
||||
path={'courses/thumbnail'}
|
||||
name='thumbnail'
|
||||
id='thumbnail'
|
||||
schema={{
|
||||
size: undefined,
|
||||
formats: undefined,
|
||||
}}
|
||||
component={FormImagePicker}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Published' labelFor='published'>
|
||||
<FormField label='Completed' labelFor='completed'>
|
||||
<Field
|
||||
name='published'
|
||||
id='published'
|
||||
name='completed'
|
||||
id='completed'
|
||||
component={SwitchField}
|
||||
></Field>
|
||||
</FormField>
|
||||
@ -708,21 +558,6 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="StartDate"
|
||||
>
|
||||
<DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={initialValues.start_date ?
|
||||
new Date(
|
||||
dayjs(initialValues.start_date).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
onChange={(date) => setInitialValues({...initialValues, 'start_date': date})}
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -731,85 +566,36 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="EndDate"
|
||||
>
|
||||
<DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={initialValues.end_date ?
|
||||
new Date(
|
||||
dayjs(initialValues.end_date).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
onChange={(date) => setInitialValues({...initialValues, 'end_date': date})}
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Price"
|
||||
>
|
||||
<FormField label='Owner' labelFor='owner'>
|
||||
<Field
|
||||
type="number"
|
||||
name="price"
|
||||
placeholder="Price"
|
||||
/>
|
||||
name='owner'
|
||||
id='owner'
|
||||
component={SelectField}
|
||||
options={initialValues.owner}
|
||||
itemRef={'users'}
|
||||
|
||||
|
||||
showField={'firstName'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -822,18 +608,137 @@ const EditCourses = () => {
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Language"
|
||||
>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='RelatedDeal' labelFor='related_deal'>
|
||||
<Field
|
||||
name="language"
|
||||
placeholder="Language"
|
||||
/>
|
||||
name='related_deal'
|
||||
id='related_deal'
|
||||
component={SelectField}
|
||||
options={initialValues.related_deal}
|
||||
itemRef={'deals'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
showField={'title'}
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='RelatedLead' labelFor='related_lead'>
|
||||
<Field
|
||||
name='related_lead'
|
||||
id='related_lead'
|
||||
component={SelectField}
|
||||
options={initialValues.related_lead}
|
||||
itemRef={'leads'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
showField={'name'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Notes' hasTextareaHeight>
|
||||
<Field
|
||||
name='notes'
|
||||
id='notes'
|
||||
component={RichTextField}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
@ -863,7 +768,7 @@ const EditCourses = () => {
|
||||
<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('/courses/courses-list')}/>
|
||||
<BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/activities/activities-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
@ -873,11 +778,11 @@ const EditCourses = () => {
|
||||
)
|
||||
}
|
||||
|
||||
EditCourses.getLayout = function getLayout(page: ReactElement) {
|
||||
EditActivities.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'UPDATE_COURSES'}
|
||||
permission={'UPDATE_ACTIVITIES'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -885,4 +790,4 @@ EditCourses.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default EditCourses
|
||||
export default EditActivities
|
||||
@ -25,7 +25,7 @@ import { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||
import { SwitchField } from '../../components/SwitchField'
|
||||
import {RichTextField} from "../../components/RichTextField";
|
||||
|
||||
import { update, fetch } from '../../stores/courses/coursesSlice'
|
||||
import { update, fetch } from '../../stores/activities/activitiesSlice'
|
||||
import { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import {saveFile} from "../../helpers/fileSaver";
|
||||
@ -34,13 +34,13 @@ import ImageField from "../../components/ImageField";
|
||||
|
||||
|
||||
|
||||
const EditCoursesPage = () => {
|
||||
const EditActivitiesPage = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const initVals = {
|
||||
|
||||
|
||||
'title': '',
|
||||
'subject': '',
|
||||
|
||||
|
||||
|
||||
@ -72,8 +72,6 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
description: '',
|
||||
|
||||
|
||||
|
||||
|
||||
@ -86,7 +84,7 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
activity_type: '',
|
||||
|
||||
|
||||
|
||||
@ -94,13 +92,9 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -112,18 +106,14 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
start: new Date(),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
instructor: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -132,27 +122,19 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
category: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end: new Date(),
|
||||
|
||||
|
||||
|
||||
@ -168,16 +150,6 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
level: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -192,27 +164,21 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
completed: false,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
thumbnail: [],
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -220,8 +186,6 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
published: false,
|
||||
|
||||
|
||||
|
||||
|
||||
@ -234,19 +198,15 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
owner: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
start_date: new Date(),
|
||||
|
||||
|
||||
|
||||
@ -262,8 +222,6 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -272,15 +230,11 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end_date: new Date(),
|
||||
related_deal: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -290,10 +244,6 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'price': '',
|
||||
|
||||
|
||||
|
||||
|
||||
@ -308,23 +258,17 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
related_lead: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'language': '',
|
||||
|
||||
|
||||
|
||||
|
||||
notes: '',
|
||||
|
||||
|
||||
|
||||
@ -351,7 +295,7 @@ const EditCoursesPage = () => {
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
const { courses } = useAppSelector((state) => state.courses)
|
||||
const { activities } = useAppSelector((state) => state.activities)
|
||||
|
||||
|
||||
const { id } = router.query
|
||||
@ -361,31 +305,31 @@ const EditCoursesPage = () => {
|
||||
}, [id])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof courses === 'object') {
|
||||
setInitialValues(courses)
|
||||
if (typeof activities === 'object') {
|
||||
setInitialValues(activities)
|
||||
}
|
||||
}, [courses])
|
||||
}, [activities])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof courses === 'object') {
|
||||
if (typeof activities === 'object') {
|
||||
const newInitialVal = {...initVals};
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (courses)[el])
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (activities)[el])
|
||||
setInitialValues(newInitialVal);
|
||||
}
|
||||
}, [courses])
|
||||
}, [activities])
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(update({ id: id, data }))
|
||||
await router.push('/courses/courses-list')
|
||||
await router.push('/activities/activities-list')
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Edit courses')}</title>
|
||||
<title>{getPageTitle('Edit activities')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit courses'} main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit activities'} main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
@ -399,11 +343,11 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
<FormField
|
||||
label="Title"
|
||||
label="Subject"
|
||||
>
|
||||
<Field
|
||||
name="title"
|
||||
placeholder="Title"
|
||||
name="subject"
|
||||
placeholder="Subject"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
@ -439,14 +383,6 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
<FormField label='Description' hasTextareaHeight>
|
||||
<Field
|
||||
name='description'
|
||||
id='description'
|
||||
component={RichTextField}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -457,106 +393,18 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Instructor' labelFor='instructor'>
|
||||
<Field
|
||||
name='instructor'
|
||||
id='instructor'
|
||||
component={SelectField}
|
||||
options={initialValues.instructor}
|
||||
itemRef={'users'}
|
||||
|
||||
|
||||
showField={'firstName'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Category" labelFor="category">
|
||||
<Field name="category" id="category" component="select">
|
||||
<FormField label="ActivityType" labelFor="activity_type">
|
||||
<Field name="activity_type" id="activity_type" component="select">
|
||||
|
||||
<option value="Programming">Programming</option>
|
||||
<option value="Call">Call</option>
|
||||
|
||||
<option value="Design">Design</option>
|
||||
<option value="Meeting">Meeting</option>
|
||||
|
||||
<option value="Math">Math</option>
|
||||
<option value="Email">Email</option>
|
||||
|
||||
<option value="Language">Language</option>
|
||||
<option value="Task">Task</option>
|
||||
|
||||
<option value="Business">Business</option>
|
||||
|
||||
<option value="Other">Other</option>
|
||||
<option value="FollowUp">FollowUp</option>
|
||||
|
||||
</Field>
|
||||
</FormField>
|
||||
@ -585,21 +433,67 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Start"
|
||||
>
|
||||
<DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={initialValues.start ?
|
||||
new Date(
|
||||
dayjs(initialValues.start).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
onChange={(date) => setInitialValues({...initialValues, 'start': date})}
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Level" labelFor="level">
|
||||
<Field name="level" id="level" component="select">
|
||||
|
||||
<option value="Beginner">Beginner</option>
|
||||
|
||||
<option value="Intermediate">Intermediate</option>
|
||||
|
||||
<option value="Advanced">Advanced</option>
|
||||
|
||||
</Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="End"
|
||||
>
|
||||
<DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={initialValues.end ?
|
||||
new Date(
|
||||
dayjs(initialValues.end).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
onChange={(date) => setInitialValues({...initialValues, 'end': date})}
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -631,54 +525,10 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField>
|
||||
<Field
|
||||
label='Thumbnail'
|
||||
color='info'
|
||||
icon={mdiUpload}
|
||||
path={'courses/thumbnail'}
|
||||
name='thumbnail'
|
||||
id='thumbnail'
|
||||
schema={{
|
||||
size: undefined,
|
||||
formats: undefined,
|
||||
}}
|
||||
component={FormImagePicker}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Published' labelFor='published'>
|
||||
<FormField label='Completed' labelFor='completed'>
|
||||
<Field
|
||||
name='published'
|
||||
id='published'
|
||||
name='completed'
|
||||
id='completed'
|
||||
component={SwitchField}
|
||||
></Field>
|
||||
</FormField>
|
||||
@ -705,21 +555,6 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="StartDate"
|
||||
>
|
||||
<DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={initialValues.start_date ?
|
||||
new Date(
|
||||
dayjs(initialValues.start_date).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
onChange={(date) => setInitialValues({...initialValues, 'start_date': date})}
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -728,85 +563,36 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="EndDate"
|
||||
>
|
||||
<DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={initialValues.end_date ?
|
||||
new Date(
|
||||
dayjs(initialValues.end_date).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
onChange={(date) => setInitialValues({...initialValues, 'end_date': date})}
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Price"
|
||||
>
|
||||
<FormField label='Owner' labelFor='owner'>
|
||||
<Field
|
||||
type="number"
|
||||
name="price"
|
||||
placeholder="Price"
|
||||
/>
|
||||
name='owner'
|
||||
id='owner'
|
||||
component={SelectField}
|
||||
options={initialValues.owner}
|
||||
itemRef={'users'}
|
||||
|
||||
|
||||
showField={'firstName'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -819,18 +605,137 @@ const EditCoursesPage = () => {
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Language"
|
||||
>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='RelatedDeal' labelFor='related_deal'>
|
||||
<Field
|
||||
name="language"
|
||||
placeholder="Language"
|
||||
/>
|
||||
name='related_deal'
|
||||
id='related_deal'
|
||||
component={SelectField}
|
||||
options={initialValues.related_deal}
|
||||
itemRef={'deals'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
showField={'title'}
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='RelatedLead' labelFor='related_lead'>
|
||||
<Field
|
||||
name='related_lead'
|
||||
id='related_lead'
|
||||
component={SelectField}
|
||||
options={initialValues.related_lead}
|
||||
itemRef={'leads'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
showField={'name'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Notes' hasTextareaHeight>
|
||||
<Field
|
||||
name='notes'
|
||||
id='notes'
|
||||
component={RichTextField}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
@ -860,7 +765,7 @@ const EditCoursesPage = () => {
|
||||
<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('/courses/courses-list')}/>
|
||||
<BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/activities/activities-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
@ -870,11 +775,11 @@ const EditCoursesPage = () => {
|
||||
)
|
||||
}
|
||||
|
||||
EditCoursesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
EditActivitiesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'UPDATE_COURSES'}
|
||||
permission={'UPDATE_ACTIVITIES'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -882,4 +787,4 @@ EditCoursesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default EditCoursesPage
|
||||
export default EditActivitiesPage
|
||||
@ -7,21 +7,21 @@ import LayoutAuthenticated from '../../layouts/Authenticated'
|
||||
import SectionMain from '../../components/SectionMain'
|
||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||
import { getPageTitle } from '../../config'
|
||||
import TableCourses from '../../components/Courses/TableCourses'
|
||||
import TableActivities from '../../components/Activities/TableActivities'
|
||||
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/courses/coursesSlice';
|
||||
import {setRefetch, uploadCsv} from '../../stores/activities/activitiesSlice';
|
||||
|
||||
|
||||
import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
|
||||
const CoursesTablesPage = () => {
|
||||
const ActivitiesTablesPage = () => {
|
||||
const [filterItems, setFilterItems] = useState([]);
|
||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||
const [isModalActive, setIsModalActive] = useState(false);
|
||||
@ -34,20 +34,28 @@ const CoursesTablesPage = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
|
||||
const [filters] = useState([{label: 'Title', title: 'title'},{label: 'Description', title: 'description'},{label: 'Language', title: 'language'},
|
||||
const [filters] = useState([{label: 'Subject', title: 'subject'},{label: 'Notes', title: 'notes'},
|
||||
|
||||
{label: 'Price', title: 'price', number: 'true'},
|
||||
{label: 'StartDate', title: 'start_date', date: 'true'},{label: 'EndDate', title: 'end_date', date: 'true'},
|
||||
|
||||
{label: 'Start', title: 'start', date: 'true'},{label: 'End', title: 'end', date: 'true'},
|
||||
|
||||
|
||||
{label: 'Instructor', title: 'instructor'},
|
||||
{label: 'Owner', title: 'owner'},
|
||||
|
||||
|
||||
|
||||
{label: 'RelatedDeal', title: 'related_deal'},
|
||||
|
||||
|
||||
|
||||
{label: 'RelatedLead', title: 'related_lead'},
|
||||
|
||||
|
||||
|
||||
{label: 'Category', title: 'category', type: 'enum', options: ['Programming','Design','Math','Language','Business','Other']},{label: 'Level', title: 'level', type: 'enum', options: ['Beginner','Intermediate','Advanced']},
|
||||
{label: 'ActivityType', title: 'activity_type', type: 'enum', options: ['Call','Meeting','Email','Task','FollowUp']},
|
||||
]);
|
||||
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_COURSES');
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_ACTIVITIES');
|
||||
|
||||
|
||||
const addFilter = () => {
|
||||
@ -64,13 +72,13 @@ const CoursesTablesPage = () => {
|
||||
setFilterItems([...filterItems, newItem]);
|
||||
};
|
||||
|
||||
const getCoursesCSV = async () => {
|
||||
const response = await axios({url: '/courses?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||
const getActivitiesCSV = async () => {
|
||||
const response = await axios({url: '/activities?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 = 'coursesCSV.csv'
|
||||
link.download = 'activitiesCSV.csv'
|
||||
link.click()
|
||||
};
|
||||
|
||||
@ -90,15 +98,15 @@ const CoursesTablesPage = () => {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Courses')}</title>
|
||||
<title>{getPageTitle('Activities')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Courses" main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Activities" main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
||||
|
||||
{hasCreatePermission && <BaseButton className={'mr-3'} href={'/courses/courses-new'} color='info' label='New Item'/>}
|
||||
{hasCreatePermission && <BaseButton className={'mr-3'} href={'/activities/activities-new'} color='info' label='New Item'/>}
|
||||
|
||||
<BaseButton
|
||||
className={'mr-3'}
|
||||
@ -106,7 +114,7 @@ const CoursesTablesPage = () => {
|
||||
label='Filter'
|
||||
onClick={addFilter}
|
||||
/>
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getCoursesCSV} />
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getActivitiesCSV} />
|
||||
|
||||
{hasCreatePermission && (
|
||||
<BaseButton
|
||||
@ -121,13 +129,13 @@ const CoursesTablesPage = () => {
|
||||
</div>
|
||||
|
||||
<div className='md:inline-flex items-center ms-auto'>
|
||||
<Link href={'/courses/courses-table'}>Switch to Table</Link>
|
||||
<Link href={'/activities/activities-table'}>Switch to Table</Link>
|
||||
</div>
|
||||
|
||||
</CardBox>
|
||||
|
||||
<CardBox className="mb-6" hasTable>
|
||||
<TableCourses
|
||||
<TableActivities
|
||||
filterItems={filterItems}
|
||||
setFilterItems={setFilterItems}
|
||||
filters={filters}
|
||||
@ -155,11 +163,11 @@ const CoursesTablesPage = () => {
|
||||
)
|
||||
}
|
||||
|
||||
CoursesTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
ActivitiesTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'READ_COURSES'}
|
||||
permission={'READ_ACTIVITIES'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -167,4 +175,4 @@ CoursesTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default CoursesTablesPage
|
||||
export default ActivitiesTablesPage
|
||||
@ -22,7 +22,7 @@ import { SelectField } from '../../components/SelectField'
|
||||
import { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||
import {RichTextField} from "../../components/RichTextField";
|
||||
|
||||
import { create } from '../../stores/courses/coursesSlice'
|
||||
import { create } from '../../stores/activities/activitiesSlice'
|
||||
import { useAppDispatch } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import moment from 'moment';
|
||||
@ -30,7 +30,7 @@ import moment from 'moment';
|
||||
const initialValues = {
|
||||
|
||||
|
||||
title: '',
|
||||
subject: '',
|
||||
|
||||
|
||||
|
||||
@ -48,7 +48,6 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
description: '',
|
||||
|
||||
|
||||
|
||||
@ -56,6 +55,7 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
activity_type: 'Call',
|
||||
|
||||
|
||||
|
||||
@ -68,12 +68,12 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
start: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
instructor: '',
|
||||
|
||||
|
||||
|
||||
@ -84,10 +84,10 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
end: '',
|
||||
|
||||
|
||||
|
||||
category: 'Programming',
|
||||
|
||||
|
||||
|
||||
@ -101,10 +101,10 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
completed: false,
|
||||
|
||||
|
||||
|
||||
level: 'Beginner',
|
||||
|
||||
|
||||
|
||||
@ -122,7 +122,7 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
thumbnail: [],
|
||||
owner: '',
|
||||
|
||||
|
||||
|
||||
@ -134,11 +134,11 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
published: false,
|
||||
|
||||
|
||||
|
||||
|
||||
related_deal: '',
|
||||
|
||||
|
||||
|
||||
@ -149,52 +149,19 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
start_date: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
related_lead: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end_date: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
price: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
language: '',
|
||||
|
||||
|
||||
notes: '',
|
||||
|
||||
|
||||
|
||||
@ -210,7 +177,7 @@ const initialValues = {
|
||||
}
|
||||
|
||||
|
||||
const CoursesNew = () => {
|
||||
const ActivitiesNew = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
|
||||
@ -222,7 +189,7 @@ const CoursesNew = () => {
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(create(data))
|
||||
await router.push('/courses/courses-list')
|
||||
await router.push('/activities/activities-list')
|
||||
}
|
||||
return (
|
||||
<>
|
||||
@ -242,8 +209,8 @@ const CoursesNew = () => {
|
||||
dateRangeStart && dateRangeEnd ?
|
||||
{
|
||||
...initialValues,
|
||||
start_date: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
|
||||
end_date: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
|
||||
start: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
|
||||
end: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
|
||||
} : initialValues
|
||||
|
||||
}
|
||||
@ -254,11 +221,11 @@ const CoursesNew = () => {
|
||||
|
||||
|
||||
<FormField
|
||||
label="Title"
|
||||
label="Subject"
|
||||
>
|
||||
<Field
|
||||
name="title"
|
||||
placeholder="Title"
|
||||
name="subject"
|
||||
placeholder="Subject"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
@ -292,13 +259,6 @@ const CoursesNew = () => {
|
||||
|
||||
|
||||
|
||||
<FormField label='Description' hasTextareaHeight>
|
||||
<Field
|
||||
name='description'
|
||||
id='description'
|
||||
component={RichTextField}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
@ -309,77 +269,18 @@ const CoursesNew = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Instructor" labelFor="instructor">
|
||||
<Field name="instructor" id="instructor" component={SelectField} options={[]} itemRef={'users'}></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Category" labelFor="category">
|
||||
<Field name="category" id="category" component="select">
|
||||
<FormField label="ActivityType" labelFor="activity_type">
|
||||
<Field name="activity_type" id="activity_type" component="select">
|
||||
|
||||
<option value="Programming">Programming</option>
|
||||
<option value="Call">Call</option>
|
||||
|
||||
<option value="Design">Design</option>
|
||||
<option value="Meeting">Meeting</option>
|
||||
|
||||
<option value="Math">Math</option>
|
||||
<option value="Email">Email</option>
|
||||
|
||||
<option value="Language">Language</option>
|
||||
<option value="Task">Task</option>
|
||||
|
||||
<option value="Business">Business</option>
|
||||
|
||||
<option value="Other">Other</option>
|
||||
<option value="FollowUp">FollowUp</option>
|
||||
|
||||
</Field>
|
||||
</FormField>
|
||||
@ -406,20 +307,50 @@ const CoursesNew = () => {
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Start"
|
||||
>
|
||||
<Field
|
||||
type="datetime-local"
|
||||
name="start"
|
||||
placeholder="Start"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Level" labelFor="level">
|
||||
<Field name="level" id="level" component="select">
|
||||
|
||||
<option value="Beginner">Beginner</option>
|
||||
|
||||
<option value="Intermediate">Intermediate</option>
|
||||
|
||||
<option value="Advanced">Advanced</option>
|
||||
|
||||
</Field>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="End"
|
||||
>
|
||||
<Field
|
||||
type="datetime-local"
|
||||
name="end"
|
||||
placeholder="End"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
@ -454,48 +385,10 @@ const CoursesNew = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField>
|
||||
<FormField label='Completed' labelFor='completed'>
|
||||
<Field
|
||||
label='Thumbnail'
|
||||
color='info'
|
||||
icon={mdiUpload}
|
||||
path={'courses/thumbnail'}
|
||||
name='thumbnail'
|
||||
id='thumbnail'
|
||||
schema={{
|
||||
size: undefined,
|
||||
formats: undefined,
|
||||
}}
|
||||
component={FormImagePicker}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Published' labelFor='published'>
|
||||
<Field
|
||||
name='published'
|
||||
id='published'
|
||||
name='completed'
|
||||
id='completed'
|
||||
component={SwitchField}
|
||||
></Field>
|
||||
</FormField>
|
||||
@ -520,14 +413,16 @@ const CoursesNew = () => {
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="StartDate"
|
||||
>
|
||||
<Field
|
||||
type="datetime-local"
|
||||
name="start_date"
|
||||
placeholder="StartDate"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Owner" labelFor="owner">
|
||||
<Field name="owner" id="owner" component={SelectField} options={[]} itemRef={'users'}></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
@ -556,14 +451,8 @@ const CoursesNew = () => {
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="EndDate"
|
||||
>
|
||||
<Field
|
||||
type="datetime-local"
|
||||
name="end_date"
|
||||
placeholder="EndDate"
|
||||
/>
|
||||
<FormField label="RelatedDeal" labelFor="related_deal">
|
||||
<Field name="related_deal" id="related_deal" component={SelectField} options={[]} itemRef={'deals'}></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
@ -588,43 +477,12 @@ const CoursesNew = () => {
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Price"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="price"
|
||||
placeholder="Price"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Language"
|
||||
>
|
||||
<Field
|
||||
name="language"
|
||||
placeholder="Language"
|
||||
/>
|
||||
<FormField label="RelatedLead" labelFor="related_lead">
|
||||
<Field name="related_lead" id="related_lead" component={SelectField} options={[]} itemRef={'leads'}></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
@ -639,6 +497,22 @@ const CoursesNew = () => {
|
||||
|
||||
|
||||
|
||||
<FormField label='Notes' hasTextareaHeight>
|
||||
<Field
|
||||
name='notes'
|
||||
id='notes'
|
||||
component={RichTextField}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -655,7 +529,7 @@ const CoursesNew = () => {
|
||||
<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('/courses/courses-list')}/>
|
||||
<BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/activities/activities-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
@ -665,11 +539,11 @@ const CoursesNew = () => {
|
||||
)
|
||||
}
|
||||
|
||||
CoursesNew.getLayout = function getLayout(page: ReactElement) {
|
||||
ActivitiesNew.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'CREATE_COURSES'}
|
||||
permission={'CREATE_ACTIVITIES'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -677,4 +551,4 @@ CoursesNew.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default CoursesNew
|
||||
export default ActivitiesNew
|
||||
@ -7,21 +7,21 @@ import LayoutAuthenticated from '../../layouts/Authenticated'
|
||||
import SectionMain from '../../components/SectionMain'
|
||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||
import { getPageTitle } from '../../config'
|
||||
import TableCourses from '../../components/Courses/TableCourses'
|
||||
import TableActivities from '../../components/Activities/TableActivities'
|
||||
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/courses/coursesSlice';
|
||||
import {setRefetch, uploadCsv} from '../../stores/activities/activitiesSlice';
|
||||
|
||||
|
||||
import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
|
||||
const CoursesTablesPage = () => {
|
||||
const ActivitiesTablesPage = () => {
|
||||
const [filterItems, setFilterItems] = useState([]);
|
||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||
const [isModalActive, setIsModalActive] = useState(false);
|
||||
@ -34,20 +34,28 @@ const CoursesTablesPage = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
|
||||
const [filters] = useState([{label: 'Title', title: 'title'},{label: 'Description', title: 'description'},{label: 'Language', title: 'language'},
|
||||
const [filters] = useState([{label: 'Subject', title: 'subject'},{label: 'Notes', title: 'notes'},
|
||||
|
||||
{label: 'Price', title: 'price', number: 'true'},
|
||||
{label: 'StartDate', title: 'start_date', date: 'true'},{label: 'EndDate', title: 'end_date', date: 'true'},
|
||||
|
||||
{label: 'Start', title: 'start', date: 'true'},{label: 'End', title: 'end', date: 'true'},
|
||||
|
||||
|
||||
{label: 'Instructor', title: 'instructor'},
|
||||
{label: 'Owner', title: 'owner'},
|
||||
|
||||
|
||||
|
||||
{label: 'RelatedDeal', title: 'related_deal'},
|
||||
|
||||
|
||||
|
||||
{label: 'RelatedLead', title: 'related_lead'},
|
||||
|
||||
|
||||
|
||||
{label: 'Category', title: 'category', type: 'enum', options: ['Programming','Design','Math','Language','Business','Other']},{label: 'Level', title: 'level', type: 'enum', options: ['Beginner','Intermediate','Advanced']},
|
||||
{label: 'ActivityType', title: 'activity_type', type: 'enum', options: ['Call','Meeting','Email','Task','FollowUp']},
|
||||
]);
|
||||
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_COURSES');
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_ACTIVITIES');
|
||||
|
||||
|
||||
const addFilter = () => {
|
||||
@ -64,13 +72,13 @@ const CoursesTablesPage = () => {
|
||||
setFilterItems([...filterItems, newItem]);
|
||||
};
|
||||
|
||||
const getCoursesCSV = async () => {
|
||||
const response = await axios({url: '/courses?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||
const getActivitiesCSV = async () => {
|
||||
const response = await axios({url: '/activities?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 = 'coursesCSV.csv'
|
||||
link.download = 'activitiesCSV.csv'
|
||||
link.click()
|
||||
};
|
||||
|
||||
@ -90,15 +98,15 @@ const CoursesTablesPage = () => {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Courses')}</title>
|
||||
<title>{getPageTitle('Activities')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Courses" main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Activities" main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
||||
|
||||
{hasCreatePermission && <BaseButton className={'mr-3'} href={'/courses/courses-new'} color='info' label='New Item'/>}
|
||||
{hasCreatePermission && <BaseButton className={'mr-3'} href={'/activities/activities-new'} color='info' label='New Item'/>}
|
||||
|
||||
<BaseButton
|
||||
className={'mr-3'}
|
||||
@ -106,7 +114,7 @@ const CoursesTablesPage = () => {
|
||||
label='Filter'
|
||||
onClick={addFilter}
|
||||
/>
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getCoursesCSV} />
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getActivitiesCSV} />
|
||||
|
||||
{hasCreatePermission && (
|
||||
<BaseButton
|
||||
@ -119,14 +127,14 @@ const CoursesTablesPage = () => {
|
||||
<div className='md:inline-flex items-center ms-auto'>
|
||||
<div id='delete-rows-button'></div>
|
||||
|
||||
<Link href={'/courses/courses-list'}>
|
||||
<Link href={'/activities/activities-list'}>
|
||||
Back to <span className='capitalize'>calendar</span>
|
||||
</Link>
|
||||
|
||||
</div>
|
||||
</CardBox>
|
||||
<CardBox className="mb-6" hasTable>
|
||||
<TableCourses
|
||||
<TableActivities
|
||||
filterItems={filterItems}
|
||||
setFilterItems={setFilterItems}
|
||||
filters={filters}
|
||||
@ -153,11 +161,11 @@ const CoursesTablesPage = () => {
|
||||
)
|
||||
}
|
||||
|
||||
CoursesTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
ActivitiesTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'READ_COURSES'}
|
||||
permission={'READ_ACTIVITIES'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -165,4 +173,4 @@ CoursesTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default CoursesTablesPage
|
||||
export default ActivitiesTablesPage
|
||||
@ -5,7 +5,7 @@ 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/progress/progressSlice'
|
||||
import { fetch } from '../../stores/activities/activitiesSlice'
|
||||
import {saveFile} from "../../helpers/fileSaver";
|
||||
import dataFormatter from '../../helpers/dataFormatter';
|
||||
import ImageField from "../../components/ImageField";
|
||||
@ -21,10 +21,10 @@ import {SwitchField} from "../../components/SwitchField";
|
||||
import FormField from "../../components/FormField";
|
||||
|
||||
|
||||
const ProgressView = () => {
|
||||
const ActivitiesView = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const { progress } = useAppSelector((state) => state.progress)
|
||||
const { activities } = useAppSelector((state) => state.activities)
|
||||
|
||||
|
||||
const { id } = router.query;
|
||||
@ -42,24 +42,105 @@ const ProgressView = () => {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('View progress')}</title>
|
||||
<title>{getPageTitle('View activities')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View progress')} main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View activities')} main>
|
||||
<BaseButton
|
||||
color='info'
|
||||
label='Edit'
|
||||
href={`/progress/progress-edit/?id=${id}`}
|
||||
href={`/activities/activities-edit/?id=${id}`}
|
||||
/>
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Subject</p>
|
||||
<p>{activities?.subject}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<FormField label='Multi Text' hasTextareaHeight>
|
||||
<textarea className={'w-full'} disabled value={progress?.note} />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>ActivityType</p>
|
||||
<p>{activities?.activity_type ?? 'No data'}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Start'>
|
||||
{activities.start ? <DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={activities.start ?
|
||||
new Date(
|
||||
dayjs(activities.start).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
disabled
|
||||
/> : <p>No Start</p>}
|
||||
</FormField>
|
||||
|
||||
|
||||
@ -76,14 +157,6 @@ const ProgressView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -97,43 +170,18 @@ const ProgressView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Enrollment</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p>{progress?.enrollment?.enrollment_label ?? 'No data'}</p>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='End'>
|
||||
{activities.end ? <DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={activities.end ?
|
||||
new Date(
|
||||
dayjs(activities.end).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
disabled
|
||||
/> : <p>No End</p>}
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
@ -147,41 +195,6 @@ const ProgressView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Lesson</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p>{progress?.lesson?.title ?? 'No data'}</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -205,7 +218,7 @@ const ProgressView = () => {
|
||||
|
||||
<FormField label='Completed'>
|
||||
<SwitchField
|
||||
field={{name: 'completed', value: progress?.completed}}
|
||||
field={{name: 'completed', value: activities?.completed}}
|
||||
form={{setFieldValue: () => null}}
|
||||
disabled
|
||||
/>
|
||||
@ -232,18 +245,45 @@ const ProgressView = () => {
|
||||
|
||||
|
||||
|
||||
<FormField label='CompletedAt'>
|
||||
{progress.completed_at ? <DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={progress.completed_at ?
|
||||
new Date(
|
||||
dayjs(progress.completed_at).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
disabled
|
||||
/> : <p>No CompletedAt</p>}
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Owner</p>
|
||||
|
||||
|
||||
<p>{activities?.owner?.firstName ?? 'No data'}</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -259,8 +299,95 @@ const ProgressView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>RelatedDeal</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p>{activities?.related_deal?.title ?? 'No data'}</p>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>RelatedLead</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p>{activities?.related_lead?.name ?? 'No data'}</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -269,8 +396,11 @@ const ProgressView = () => {
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Score</p>
|
||||
<p>{progress?.score || 'No data'}</p>
|
||||
<p className={'block font-bold mb-2'}>Notes</p>
|
||||
{activities.notes
|
||||
? <p dangerouslySetInnerHTML={{__html: activities.notes}}/>
|
||||
: <p>No data</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
@ -291,36 +421,6 @@ const ProgressView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Attempts</p>
|
||||
<p>{progress?.attempts || 'No data'}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -331,6 +431,7 @@ const ProgressView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -339,7 +440,7 @@ const ProgressView = () => {
|
||||
<BaseButton
|
||||
color='info'
|
||||
label='Back'
|
||||
onClick={() => router.push('/progress/progress-list')}
|
||||
onClick={() => router.push('/activities/activities-list')}
|
||||
/>
|
||||
</CardBox>
|
||||
</SectionMain>
|
||||
@ -347,11 +448,11 @@ const ProgressView = () => {
|
||||
);
|
||||
};
|
||||
|
||||
ProgressView.getLayout = function getLayout(page: ReactElement) {
|
||||
ActivitiesView.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'READ_PROGRESS'}
|
||||
permission={'READ_ACTIVITIES'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -359,4 +460,4 @@ ProgressView.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default ProgressView;
|
||||
export default ActivitiesView;
|
||||
@ -25,7 +25,7 @@ import { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||
import { SwitchField } from '../../components/SwitchField'
|
||||
import {RichTextField} from "../../components/RichTextField";
|
||||
|
||||
import { update, fetch } from '../../stores/progress/progressSlice'
|
||||
import { update, fetch } from '../../stores/contacts/contactsSlice'
|
||||
import { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import {saveFile} from "../../helpers/fileSaver";
|
||||
@ -34,15 +34,15 @@ import ImageField from "../../components/ImageField";
|
||||
|
||||
|
||||
|
||||
const EditProgress = () => {
|
||||
const EditContacts = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const initVals = {
|
||||
|
||||
|
||||
|
||||
'name': '',
|
||||
|
||||
note: '',
|
||||
|
||||
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ const EditProgress = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
'email': '',
|
||||
|
||||
|
||||
|
||||
@ -90,13 +90,13 @@ const EditProgress = () => {
|
||||
|
||||
|
||||
|
||||
enrollment: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'phone': '',
|
||||
|
||||
|
||||
|
||||
@ -118,13 +118,13 @@ const EditProgress = () => {
|
||||
|
||||
|
||||
|
||||
lesson: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'title': '',
|
||||
|
||||
|
||||
|
||||
@ -136,7 +136,7 @@ const EditProgress = () => {
|
||||
|
||||
|
||||
|
||||
completed: false,
|
||||
|
||||
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ const EditProgress = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
'company': '',
|
||||
|
||||
|
||||
|
||||
@ -161,8 +161,6 @@ const EditProgress = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
completed_at: new Date(),
|
||||
|
||||
|
||||
|
||||
@ -178,9 +176,9 @@ const EditProgress = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'score': '',
|
||||
|
||||
|
||||
|
||||
@ -203,6 +201,8 @@ const EditProgress = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
owner: null,
|
||||
|
||||
|
||||
|
||||
@ -210,11 +210,11 @@ const EditProgress = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
notes: '',
|
||||
|
||||
|
||||
|
||||
attempts: '',
|
||||
|
||||
|
||||
|
||||
|
||||
@ -239,44 +239,44 @@ const EditProgress = () => {
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
const { progress } = useAppSelector((state) => state.progress)
|
||||
const { contacts } = useAppSelector((state) => state.contacts)
|
||||
|
||||
|
||||
const { progressId } = router.query
|
||||
const { contactsId } = router.query
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetch({ id: progressId }))
|
||||
}, [progressId])
|
||||
dispatch(fetch({ id: contactsId }))
|
||||
}, [contactsId])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof progress === 'object') {
|
||||
setInitialValues(progress)
|
||||
if (typeof contacts === 'object') {
|
||||
setInitialValues(contacts)
|
||||
}
|
||||
}, [progress])
|
||||
}, [contacts])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof progress === 'object') {
|
||||
if (typeof contacts === 'object') {
|
||||
|
||||
const newInitialVal = {...initVals};
|
||||
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (progress)[el])
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (contacts)[el])
|
||||
|
||||
setInitialValues(newInitialVal);
|
||||
}
|
||||
}, [progress])
|
||||
}, [contacts])
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(update({ id: progressId, data }))
|
||||
await router.push('/progress/progress-list')
|
||||
await dispatch(update({ id: contactsId, data }))
|
||||
await router.push('/contacts/contacts-list')
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Edit progress')}</title>
|
||||
<title>{getPageTitle('Edit contacts')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit progress'} main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit contacts'} main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
@ -287,248 +287,14 @@ const EditProgress = () => {
|
||||
>
|
||||
<Form>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Note" hasTextareaHeight>
|
||||
<Field name="note" as="textarea" placeholder="Note" />
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Enrollment' labelFor='enrollment'>
|
||||
<Field
|
||||
name='enrollment'
|
||||
id='enrollment'
|
||||
component={SelectField}
|
||||
options={initialValues.enrollment}
|
||||
itemRef={'enrollments'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
showField={'enrollment_label'}
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Lesson' labelFor='lesson'>
|
||||
<Field
|
||||
name='lesson'
|
||||
id='lesson'
|
||||
component={SelectField}
|
||||
options={initialValues.lesson}
|
||||
itemRef={'lessons'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
showField={'title'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Completed' labelFor='completed'>
|
||||
<Field
|
||||
name='completed'
|
||||
id='completed'
|
||||
component={SwitchField}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="CompletedAt"
|
||||
>
|
||||
<DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={initialValues.completed_at ?
|
||||
new Date(
|
||||
dayjs(initialValues.completed_at).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
onChange={(date) => setInitialValues({...initialValues, 'completed_at': date})}
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Score"
|
||||
label="Name"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="score"
|
||||
placeholder="Score"
|
||||
name="name"
|
||||
placeholder="Name"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
@ -547,6 +313,160 @@ const EditProgress = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Email"
|
||||
>
|
||||
<Field
|
||||
name="email"
|
||||
placeholder="Email"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Phone"
|
||||
>
|
||||
<Field
|
||||
name="phone"
|
||||
placeholder="Phone"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="JobTitle"
|
||||
>
|
||||
<Field
|
||||
name="title"
|
||||
placeholder="JobTitle"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Company"
|
||||
>
|
||||
<Field
|
||||
name="company"
|
||||
placeholder="Company"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -560,15 +480,69 @@ const EditProgress = () => {
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Attempts"
|
||||
>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Owner' labelFor='owner'>
|
||||
<Field
|
||||
type="number"
|
||||
name="attempts"
|
||||
placeholder="Attempts"
|
||||
/>
|
||||
name='owner'
|
||||
id='owner'
|
||||
component={SelectField}
|
||||
options={initialValues.owner}
|
||||
itemRef={'users'}
|
||||
|
||||
|
||||
showField={'firstName'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Notes" hasTextareaHeight>
|
||||
<Field name="notes" as="textarea" placeholder="Notes" />
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -596,7 +570,7 @@ const EditProgress = () => {
|
||||
<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('/progress/progress-list')}/>
|
||||
<BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/contacts/contacts-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
@ -606,11 +580,11 @@ const EditProgress = () => {
|
||||
)
|
||||
}
|
||||
|
||||
EditProgress.getLayout = function getLayout(page: ReactElement) {
|
||||
EditContacts.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'UPDATE_PROGRESS'}
|
||||
permission={'UPDATE_CONTACTS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -618,4 +592,4 @@ EditProgress.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default EditProgress
|
||||
export default EditContacts
|
||||
@ -25,7 +25,7 @@ import { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||
import { SwitchField } from '../../components/SwitchField'
|
||||
import {RichTextField} from "../../components/RichTextField";
|
||||
|
||||
import { update, fetch } from '../../stores/progress/progressSlice'
|
||||
import { update, fetch } from '../../stores/contacts/contactsSlice'
|
||||
import { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import {saveFile} from "../../helpers/fileSaver";
|
||||
@ -34,15 +34,15 @@ import ImageField from "../../components/ImageField";
|
||||
|
||||
|
||||
|
||||
const EditProgressPage = () => {
|
||||
const EditContactsPage = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const initVals = {
|
||||
|
||||
|
||||
|
||||
'name': '',
|
||||
|
||||
note: '',
|
||||
|
||||
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ const EditProgressPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
'email': '',
|
||||
|
||||
|
||||
|
||||
@ -90,13 +90,13 @@ const EditProgressPage = () => {
|
||||
|
||||
|
||||
|
||||
enrollment: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'phone': '',
|
||||
|
||||
|
||||
|
||||
@ -118,13 +118,13 @@ const EditProgressPage = () => {
|
||||
|
||||
|
||||
|
||||
lesson: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'title': '',
|
||||
|
||||
|
||||
|
||||
@ -136,7 +136,7 @@ const EditProgressPage = () => {
|
||||
|
||||
|
||||
|
||||
completed: false,
|
||||
|
||||
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ const EditProgressPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
'company': '',
|
||||
|
||||
|
||||
|
||||
@ -161,8 +161,6 @@ const EditProgressPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
completed_at: new Date(),
|
||||
|
||||
|
||||
|
||||
@ -178,9 +176,9 @@ const EditProgressPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'score': '',
|
||||
|
||||
|
||||
|
||||
@ -203,6 +201,8 @@ const EditProgressPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
owner: null,
|
||||
|
||||
|
||||
|
||||
@ -210,11 +210,11 @@ const EditProgressPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
notes: '',
|
||||
|
||||
|
||||
|
||||
attempts: '',
|
||||
|
||||
|
||||
|
||||
|
||||
@ -239,7 +239,7 @@ const EditProgressPage = () => {
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
const { progress } = useAppSelector((state) => state.progress)
|
||||
const { contacts } = useAppSelector((state) => state.contacts)
|
||||
|
||||
|
||||
const { id } = router.query
|
||||
@ -249,31 +249,31 @@ const EditProgressPage = () => {
|
||||
}, [id])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof progress === 'object') {
|
||||
setInitialValues(progress)
|
||||
if (typeof contacts === 'object') {
|
||||
setInitialValues(contacts)
|
||||
}
|
||||
}, [progress])
|
||||
}, [contacts])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof progress === 'object') {
|
||||
if (typeof contacts === 'object') {
|
||||
const newInitialVal = {...initVals};
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (progress)[el])
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (contacts)[el])
|
||||
setInitialValues(newInitialVal);
|
||||
}
|
||||
}, [progress])
|
||||
}, [contacts])
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(update({ id: id, data }))
|
||||
await router.push('/progress/progress-list')
|
||||
await router.push('/contacts/contacts-list')
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Edit progress')}</title>
|
||||
<title>{getPageTitle('Edit contacts')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit progress'} main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit contacts'} main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
@ -284,248 +284,14 @@ const EditProgressPage = () => {
|
||||
>
|
||||
<Form>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Note" hasTextareaHeight>
|
||||
<Field name="note" as="textarea" placeholder="Note" />
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Enrollment' labelFor='enrollment'>
|
||||
<Field
|
||||
name='enrollment'
|
||||
id='enrollment'
|
||||
component={SelectField}
|
||||
options={initialValues.enrollment}
|
||||
itemRef={'enrollments'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
showField={'enrollment_label'}
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Lesson' labelFor='lesson'>
|
||||
<Field
|
||||
name='lesson'
|
||||
id='lesson'
|
||||
component={SelectField}
|
||||
options={initialValues.lesson}
|
||||
itemRef={'lessons'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
showField={'title'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Completed' labelFor='completed'>
|
||||
<Field
|
||||
name='completed'
|
||||
id='completed'
|
||||
component={SwitchField}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="CompletedAt"
|
||||
>
|
||||
<DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={initialValues.completed_at ?
|
||||
new Date(
|
||||
dayjs(initialValues.completed_at).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
onChange={(date) => setInitialValues({...initialValues, 'completed_at': date})}
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Score"
|
||||
label="Name"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="score"
|
||||
placeholder="Score"
|
||||
name="name"
|
||||
placeholder="Name"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
@ -544,6 +310,160 @@ const EditProgressPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Email"
|
||||
>
|
||||
<Field
|
||||
name="email"
|
||||
placeholder="Email"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Phone"
|
||||
>
|
||||
<Field
|
||||
name="phone"
|
||||
placeholder="Phone"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="JobTitle"
|
||||
>
|
||||
<Field
|
||||
name="title"
|
||||
placeholder="JobTitle"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Company"
|
||||
>
|
||||
<Field
|
||||
name="company"
|
||||
placeholder="Company"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -557,15 +477,69 @@ const EditProgressPage = () => {
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Attempts"
|
||||
>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Owner' labelFor='owner'>
|
||||
<Field
|
||||
type="number"
|
||||
name="attempts"
|
||||
placeholder="Attempts"
|
||||
/>
|
||||
name='owner'
|
||||
id='owner'
|
||||
component={SelectField}
|
||||
options={initialValues.owner}
|
||||
itemRef={'users'}
|
||||
|
||||
|
||||
showField={'firstName'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Notes" hasTextareaHeight>
|
||||
<Field name="notes" as="textarea" placeholder="Notes" />
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -593,7 +567,7 @@ const EditProgressPage = () => {
|
||||
<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('/progress/progress-list')}/>
|
||||
<BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/contacts/contacts-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
@ -603,11 +577,11 @@ const EditProgressPage = () => {
|
||||
)
|
||||
}
|
||||
|
||||
EditProgressPage.getLayout = function getLayout(page: ReactElement) {
|
||||
EditContactsPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'UPDATE_PROGRESS'}
|
||||
permission={'UPDATE_CONTACTS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -615,4 +589,4 @@ EditProgressPage.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default EditProgressPage
|
||||
export default EditContactsPage
|
||||
@ -7,21 +7,21 @@ import LayoutAuthenticated from '../../layouts/Authenticated'
|
||||
import SectionMain from '../../components/SectionMain'
|
||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||
import { getPageTitle } from '../../config'
|
||||
import TableProgress from '../../components/Progress/TableProgress'
|
||||
import TableContacts from '../../components/Contacts/TableContacts'
|
||||
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/progress/progressSlice';
|
||||
import {setRefetch, uploadCsv} from '../../stores/contacts/contactsSlice';
|
||||
|
||||
|
||||
import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
|
||||
const ProgressTablesPage = () => {
|
||||
const ContactsTablesPage = () => {
|
||||
const [filterItems, setFilterItems] = useState([]);
|
||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||
const [isModalActive, setIsModalActive] = useState(false);
|
||||
@ -34,24 +34,20 @@ const ProgressTablesPage = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
|
||||
const [filters] = useState([{label: 'Note', title: 'note'},
|
||||
{label: 'Attempts', title: 'attempts', number: 'true'},
|
||||
{label: 'Score', title: 'score', number: 'true'},
|
||||
{label: 'CompletedAt', title: 'completed_at', date: 'true'},
|
||||
const [filters] = useState([{label: 'Name', title: 'name'},{label: 'Email', title: 'email'},{label: 'Phone', title: 'phone'},{label: 'JobTitle', title: 'title'},{label: 'Company', title: 'company'},{label: 'Notes', title: 'notes'},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{label: 'Enrollment', title: 'enrollment'},
|
||||
|
||||
|
||||
|
||||
{label: 'Lesson', title: 'lesson'},
|
||||
{label: 'Owner', title: 'owner'},
|
||||
|
||||
|
||||
|
||||
|
||||
]);
|
||||
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_PROGRESS');
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_CONTACTS');
|
||||
|
||||
|
||||
const addFilter = () => {
|
||||
@ -68,13 +64,13 @@ const ProgressTablesPage = () => {
|
||||
setFilterItems([...filterItems, newItem]);
|
||||
};
|
||||
|
||||
const getProgressCSV = async () => {
|
||||
const response = await axios({url: '/progress?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||
const getContactsCSV = async () => {
|
||||
const response = await axios({url: '/contacts?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 = 'progressCSV.csv'
|
||||
link.download = 'contactsCSV.csv'
|
||||
link.click()
|
||||
};
|
||||
|
||||
@ -94,15 +90,15 @@ const ProgressTablesPage = () => {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Progress')}</title>
|
||||
<title>{getPageTitle('Contacts')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Progress" main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Contacts" main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
||||
|
||||
{hasCreatePermission && <BaseButton className={'mr-3'} href={'/progress/progress-new'} color='info' label='New Item'/>}
|
||||
{hasCreatePermission && <BaseButton className={'mr-3'} href={'/contacts/contacts-new'} color='info' label='New Item'/>}
|
||||
|
||||
<BaseButton
|
||||
className={'mr-3'}
|
||||
@ -110,7 +106,7 @@ const ProgressTablesPage = () => {
|
||||
label='Filter'
|
||||
onClick={addFilter}
|
||||
/>
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getProgressCSV} />
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getContactsCSV} />
|
||||
|
||||
{hasCreatePermission && (
|
||||
<BaseButton
|
||||
@ -125,13 +121,13 @@ const ProgressTablesPage = () => {
|
||||
</div>
|
||||
|
||||
<div className='md:inline-flex items-center ms-auto'>
|
||||
<Link href={'/progress/progress-table'}>Switch to Table</Link>
|
||||
<Link href={'/contacts/contacts-table'}>Switch to Table</Link>
|
||||
</div>
|
||||
|
||||
</CardBox>
|
||||
|
||||
<CardBox className="mb-6" hasTable>
|
||||
<TableProgress
|
||||
<TableContacts
|
||||
filterItems={filterItems}
|
||||
setFilterItems={setFilterItems}
|
||||
filters={filters}
|
||||
@ -159,11 +155,11 @@ const ProgressTablesPage = () => {
|
||||
)
|
||||
}
|
||||
|
||||
ProgressTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
ContactsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'READ_PROGRESS'}
|
||||
permission={'READ_CONTACTS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -171,4 +167,4 @@ ProgressTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default ProgressTablesPage
|
||||
export default ContactsTablesPage
|
||||
@ -22,7 +22,7 @@ import { SelectField } from '../../components/SelectField'
|
||||
import { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||
import {RichTextField} from "../../components/RichTextField";
|
||||
|
||||
import { create } from '../../stores/progress/progressSlice'
|
||||
import { create } from '../../stores/contacts/contactsSlice'
|
||||
import { useAppDispatch } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import moment from 'moment';
|
||||
@ -30,8 +30,8 @@ import moment from 'moment';
|
||||
const initialValues = {
|
||||
|
||||
|
||||
name: '',
|
||||
|
||||
note: '',
|
||||
|
||||
|
||||
|
||||
@ -46,6 +46,7 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
email: '',
|
||||
|
||||
|
||||
|
||||
@ -57,11 +58,11 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
enrollment: '',
|
||||
|
||||
|
||||
|
||||
|
||||
phone: '',
|
||||
|
||||
|
||||
|
||||
@ -73,18 +74,17 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
lesson: '',
|
||||
|
||||
|
||||
|
||||
|
||||
title: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
completed: false,
|
||||
|
||||
|
||||
|
||||
@ -94,12 +94,12 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
company: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
completed_at: '',
|
||||
|
||||
|
||||
|
||||
@ -110,7 +110,6 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
score: '',
|
||||
|
||||
|
||||
|
||||
@ -122,14 +121,15 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
owner: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
notes: '',
|
||||
|
||||
|
||||
attempts: '',
|
||||
|
||||
|
||||
|
||||
@ -144,7 +144,7 @@ const initialValues = {
|
||||
}
|
||||
|
||||
|
||||
const ProgressNew = () => {
|
||||
const ContactsNew = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
|
||||
@ -153,7 +153,7 @@ const ProgressNew = () => {
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(create(data))
|
||||
await router.push('/progress/progress-list')
|
||||
await router.push('/contacts/contacts-list')
|
||||
}
|
||||
return (
|
||||
<>
|
||||
@ -176,148 +176,13 @@ const ProgressNew = () => {
|
||||
<Form>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Note" hasTextareaHeight>
|
||||
<Field name="note" as="textarea" placeholder="Note" />
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Enrollment" labelFor="enrollment">
|
||||
<Field name="enrollment" id="enrollment" component={SelectField} options={[]} itemRef={'enrollments'}></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Lesson" labelFor="lesson">
|
||||
<Field name="lesson" id="lesson" component={SelectField} options={[]} itemRef={'lessons'}></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Completed' labelFor='completed'>
|
||||
<Field
|
||||
name='completed'
|
||||
id='completed'
|
||||
component={SwitchField}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="CompletedAt"
|
||||
label="Name"
|
||||
>
|
||||
<Field
|
||||
type="datetime-local"
|
||||
name="completed_at"
|
||||
placeholder="CompletedAt"
|
||||
name="name"
|
||||
placeholder="Name"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
@ -343,14 +208,184 @@ const ProgressNew = () => {
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Score"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="score"
|
||||
placeholder="Score"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Email"
|
||||
>
|
||||
<Field
|
||||
name="email"
|
||||
placeholder="Email"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Phone"
|
||||
>
|
||||
<Field
|
||||
name="phone"
|
||||
placeholder="Phone"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="JobTitle"
|
||||
>
|
||||
<Field
|
||||
name="title"
|
||||
placeholder="JobTitle"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Company"
|
||||
>
|
||||
<Field
|
||||
name="company"
|
||||
placeholder="Company"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Owner" labelFor="owner">
|
||||
<Field name="owner" id="owner" component={SelectField} options={[]} itemRef={'users'}></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Notes" hasTextareaHeight>
|
||||
<Field name="notes" as="textarea" placeholder="Notes" />
|
||||
</FormField>
|
||||
|
||||
|
||||
@ -372,38 +407,6 @@ const ProgressNew = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Attempts"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="attempts"
|
||||
placeholder="Attempts"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -411,7 +414,7 @@ const ProgressNew = () => {
|
||||
<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('/progress/progress-list')}/>
|
||||
<BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/contacts/contacts-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
@ -421,11 +424,11 @@ const ProgressNew = () => {
|
||||
)
|
||||
}
|
||||
|
||||
ProgressNew.getLayout = function getLayout(page: ReactElement) {
|
||||
ContactsNew.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'CREATE_PROGRESS'}
|
||||
permission={'CREATE_CONTACTS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -433,4 +436,4 @@ ProgressNew.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default ProgressNew
|
||||
export default ContactsNew
|
||||
@ -7,21 +7,21 @@ import LayoutAuthenticated from '../../layouts/Authenticated'
|
||||
import SectionMain from '../../components/SectionMain'
|
||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||
import { getPageTitle } from '../../config'
|
||||
import TableProgress from '../../components/Progress/TableProgress'
|
||||
import TableContacts from '../../components/Contacts/TableContacts'
|
||||
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/progress/progressSlice';
|
||||
import {setRefetch, uploadCsv} from '../../stores/contacts/contactsSlice';
|
||||
|
||||
|
||||
import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
|
||||
const ProgressTablesPage = () => {
|
||||
const ContactsTablesPage = () => {
|
||||
const [filterItems, setFilterItems] = useState([]);
|
||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||
const [isModalActive, setIsModalActive] = useState(false);
|
||||
@ -34,24 +34,20 @@ const ProgressTablesPage = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
|
||||
const [filters] = useState([{label: 'Note', title: 'note'},
|
||||
{label: 'Attempts', title: 'attempts', number: 'true'},
|
||||
{label: 'Score', title: 'score', number: 'true'},
|
||||
{label: 'CompletedAt', title: 'completed_at', date: 'true'},
|
||||
const [filters] = useState([{label: 'Name', title: 'name'},{label: 'Email', title: 'email'},{label: 'Phone', title: 'phone'},{label: 'JobTitle', title: 'title'},{label: 'Company', title: 'company'},{label: 'Notes', title: 'notes'},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{label: 'Enrollment', title: 'enrollment'},
|
||||
|
||||
|
||||
|
||||
{label: 'Lesson', title: 'lesson'},
|
||||
{label: 'Owner', title: 'owner'},
|
||||
|
||||
|
||||
|
||||
|
||||
]);
|
||||
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_PROGRESS');
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_CONTACTS');
|
||||
|
||||
|
||||
const addFilter = () => {
|
||||
@ -68,13 +64,13 @@ const ProgressTablesPage = () => {
|
||||
setFilterItems([...filterItems, newItem]);
|
||||
};
|
||||
|
||||
const getProgressCSV = async () => {
|
||||
const response = await axios({url: '/progress?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||
const getContactsCSV = async () => {
|
||||
const response = await axios({url: '/contacts?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 = 'progressCSV.csv'
|
||||
link.download = 'contactsCSV.csv'
|
||||
link.click()
|
||||
};
|
||||
|
||||
@ -94,15 +90,15 @@ const ProgressTablesPage = () => {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Progress')}</title>
|
||||
<title>{getPageTitle('Contacts')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Progress" main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Contacts" main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
||||
|
||||
{hasCreatePermission && <BaseButton className={'mr-3'} href={'/progress/progress-new'} color='info' label='New Item'/>}
|
||||
{hasCreatePermission && <BaseButton className={'mr-3'} href={'/contacts/contacts-new'} color='info' label='New Item'/>}
|
||||
|
||||
<BaseButton
|
||||
className={'mr-3'}
|
||||
@ -110,7 +106,7 @@ const ProgressTablesPage = () => {
|
||||
label='Filter'
|
||||
onClick={addFilter}
|
||||
/>
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getProgressCSV} />
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getContactsCSV} />
|
||||
|
||||
{hasCreatePermission && (
|
||||
<BaseButton
|
||||
@ -123,14 +119,14 @@ const ProgressTablesPage = () => {
|
||||
<div className='md:inline-flex items-center ms-auto'>
|
||||
<div id='delete-rows-button'></div>
|
||||
|
||||
<Link href={'/progress/progress-list'}>
|
||||
<Link href={'/contacts/contacts-list'}>
|
||||
Back to <span className='capitalize'>list</span>
|
||||
</Link>
|
||||
|
||||
</div>
|
||||
</CardBox>
|
||||
<CardBox className="mb-6" hasTable>
|
||||
<TableProgress
|
||||
<TableContacts
|
||||
filterItems={filterItems}
|
||||
setFilterItems={setFilterItems}
|
||||
filters={filters}
|
||||
@ -157,11 +153,11 @@ const ProgressTablesPage = () => {
|
||||
)
|
||||
}
|
||||
|
||||
ProgressTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
ContactsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'READ_PROGRESS'}
|
||||
permission={'READ_CONTACTS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -169,4 +165,4 @@ ProgressTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default ProgressTablesPage
|
||||
export default ContactsTablesPage
|
||||
@ -5,7 +5,7 @@ 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/enrollments/enrollmentsSlice'
|
||||
import { fetch } from '../../stores/contacts/contactsSlice'
|
||||
import {saveFile} from "../../helpers/fileSaver";
|
||||
import dataFormatter from '../../helpers/dataFormatter';
|
||||
import ImageField from "../../components/ImageField";
|
||||
@ -21,10 +21,10 @@ import {SwitchField} from "../../components/SwitchField";
|
||||
import FormField from "../../components/FormField";
|
||||
|
||||
|
||||
const EnrollmentsView = () => {
|
||||
const ContactsView = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const { enrollments } = useAppSelector((state) => state.enrollments)
|
||||
const { contacts } = useAppSelector((state) => state.contacts)
|
||||
|
||||
|
||||
const { id } = router.query;
|
||||
@ -42,14 +42,14 @@ const EnrollmentsView = () => {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('View enrollments')}</title>
|
||||
<title>{getPageTitle('View contacts')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View enrollments')} main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View contacts')} main>
|
||||
<BaseButton
|
||||
color='info'
|
||||
label='Edit'
|
||||
href={`/enrollments/enrollments-edit/?id=${id}`}
|
||||
href={`/contacts/contacts-edit/?id=${id}`}
|
||||
/>
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
@ -57,8 +57,136 @@ const EnrollmentsView = () => {
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>EnrollmentLabel</p>
|
||||
<p>{enrollments?.enrollment_label}</p>
|
||||
<p className={'block font-bold mb-2'}>Name</p>
|
||||
<p>{contacts?.name}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Email</p>
|
||||
<p>{contacts?.email}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Phone</p>
|
||||
<p>{contacts?.phone}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>JobTitle</p>
|
||||
<p>{contacts?.title}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Company</p>
|
||||
<p>{contacts?.company}</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -108,10 +236,12 @@ const EnrollmentsView = () => {
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Student</p>
|
||||
<p className={'block font-bold mb-2'}>Owner</p>
|
||||
|
||||
|
||||
<p>{contacts?.owner?.firstName ?? 'No data'}</p>
|
||||
|
||||
|
||||
<p>{enrollments?.student?.firstName ?? 'No data'}</p>
|
||||
|
||||
|
||||
|
||||
@ -140,75 +270,8 @@ const EnrollmentsView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Course</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p>{enrollments?.course?.title ?? 'No data'}</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='EnrolledAt'>
|
||||
{enrollments.enrolled_at ? <DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={enrollments.enrolled_at ?
|
||||
new Date(
|
||||
dayjs(enrollments.enrolled_at).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
disabled
|
||||
/> : <p>No EnrolledAt</p>}
|
||||
<FormField label='Multi Text' hasTextareaHeight>
|
||||
<textarea className={'w-full'} disabled value={contacts?.notes} />
|
||||
</FormField>
|
||||
|
||||
|
||||
@ -225,94 +288,6 @@ const EnrollmentsView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Status</p>
|
||||
<p>{enrollments?.status ?? 'No data'}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>ProgressPercent</p>
|
||||
<p>{enrollments?.progress_percent || 'No data'}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>PricePaid</p>
|
||||
<p>{enrollments?.price_paid || 'No data'}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -331,7 +306,7 @@ const EnrollmentsView = () => {
|
||||
|
||||
|
||||
<>
|
||||
<p className={'block font-bold mb-2'}>Progress Enrollment</p>
|
||||
<p className={'block font-bold mb-2'}>Deals PrimaryContact</p>
|
||||
<CardBox
|
||||
className='mb-6 border border-gray-300 rounded overflow-hidden'
|
||||
hasTable
|
||||
@ -342,7 +317,29 @@ const EnrollmentsView = () => {
|
||||
<tr>
|
||||
|
||||
|
||||
<th>Note</th>
|
||||
<th>Title</th>
|
||||
|
||||
|
||||
|
||||
<th>DealNumber</th>
|
||||
|
||||
|
||||
|
||||
<th>Value</th>
|
||||
|
||||
|
||||
|
||||
<th>Currency</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th>Status</th>
|
||||
|
||||
|
||||
|
||||
<th>CloseDate</th>
|
||||
|
||||
|
||||
|
||||
@ -350,31 +347,49 @@ const EnrollmentsView = () => {
|
||||
|
||||
|
||||
|
||||
<th>Completed</th>
|
||||
|
||||
|
||||
|
||||
<th>CompletedAt</th>
|
||||
|
||||
|
||||
|
||||
<th>Score</th>
|
||||
|
||||
|
||||
|
||||
<th>Attempts</th>
|
||||
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{enrollments.progress_enrollment && Array.isArray(enrollments.progress_enrollment) &&
|
||||
enrollments.progress_enrollment.map((item: any) => (
|
||||
<tr key={item.id} onClick={() => router.push(`/progress/progress-view/?id=${item.id}`)}>
|
||||
{contacts.deals_primary_contact && Array.isArray(contacts.deals_primary_contact) &&
|
||||
contacts.deals_primary_contact.map((item: any) => (
|
||||
<tr key={item.id} onClick={() => router.push(`/deals/deals-view/?id=${item.id}`)}>
|
||||
|
||||
|
||||
<td data-label="note">
|
||||
{ item.note }
|
||||
<td data-label="title">
|
||||
{ item.title }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="deal_number">
|
||||
{ item.deal_number }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="value">
|
||||
{ item.value }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="currency">
|
||||
{ item.currency }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td data-label="status">
|
||||
{ item.status }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="close_date">
|
||||
{ dataFormatter.dateTimeFormatter(item.close_date) }
|
||||
</td>
|
||||
|
||||
|
||||
@ -383,46 +398,25 @@ const EnrollmentsView = () => {
|
||||
|
||||
|
||||
|
||||
<td data-label="completed">
|
||||
{ dataFormatter.booleanFormatter(item.completed) }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="completed_at">
|
||||
{ dataFormatter.dateTimeFormatter(item.completed_at) }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="score">
|
||||
{ item.score }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="attempts">
|
||||
{ item.attempts }
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{!enrollments?.progress_enrollment?.length && <div className={'text-center py-4'}>No data</div>}
|
||||
{!contacts?.deals_primary_contact?.length && <div className={'text-center py-4'}>No data</div>}
|
||||
</CardBox>
|
||||
</>
|
||||
|
||||
|
||||
|
||||
|
||||
<BaseDivider />
|
||||
|
||||
<BaseButton
|
||||
color='info'
|
||||
label='Back'
|
||||
onClick={() => router.push('/enrollments/enrollments-list')}
|
||||
onClick={() => router.push('/contacts/contacts-list')}
|
||||
/>
|
||||
</CardBox>
|
||||
</SectionMain>
|
||||
@ -430,11 +424,11 @@ const EnrollmentsView = () => {
|
||||
);
|
||||
};
|
||||
|
||||
EnrollmentsView.getLayout = function getLayout(page: ReactElement) {
|
||||
ContactsView.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'READ_ENROLLMENTS'}
|
||||
permission={'READ_CONTACTS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -442,4 +436,4 @@ EnrollmentsView.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default EnrollmentsView;
|
||||
export default ContactsView;
|
||||
@ -9,6 +9,7 @@ import SectionTitleLineWithButton from '../components/SectionTitleLineWithButton
|
||||
import BaseIcon from "../components/BaseIcon";
|
||||
import { getPageTitle } from '../config'
|
||||
import Link from "next/link";
|
||||
import CardBox from '../components/CardBox';
|
||||
|
||||
import { hasPermission } from "../helpers/userPermissions";
|
||||
import { fetchWidgets } from '../stores/roles/rolesSlice';
|
||||
@ -16,62 +17,55 @@ import { WidgetCreator } from '../components/WidgetCreator/WidgetCreator';
|
||||
import { SmartWidget } from '../components/SmartWidget/SmartWidget';
|
||||
|
||||
import { useAppDispatch, useAppSelector } from '../stores/hooks';
|
||||
|
||||
const Dashboard = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const iconsColor = useAppSelector((state) => state.style.iconsColor);
|
||||
const corners = useAppSelector((state) => state.style.corners);
|
||||
const cardsStyle = useAppSelector((state) => state.style.cardsStyle);
|
||||
|
||||
const loadingMessage = 'Loading...';
|
||||
const loadingMessage = '...';
|
||||
|
||||
const [leads, setLeads] = React.useState<any>(loadingMessage);
|
||||
const [dealsCount, setDealsCount] = React.useState<any>(loadingMessage);
|
||||
const [totalValue, setTotalValue] = React.useState<any>(loadingMessage);
|
||||
const [activitiesCount, setActivitiesCount] = React.useState<any>(loadingMessage);
|
||||
|
||||
const [users, setUsers] = React.useState(loadingMessage);
|
||||
const [roles, setRoles] = React.useState(loadingMessage);
|
||||
const [permissions, setPermissions] = React.useState(loadingMessage);
|
||||
const [courses, setCourses] = React.useState(loadingMessage);
|
||||
const [lessons, setLessons] = React.useState(loadingMessage);
|
||||
const [enrollments, setEnrollments] = React.useState(loadingMessage);
|
||||
const [progress, setProgress] = React.useState(loadingMessage);
|
||||
const [recentDeals, setRecentDeals] = React.useState([]);
|
||||
const [upcomingActivities, setUpcomingActivities] = React.useState([]);
|
||||
const [pipelineStages, setPipelineStages] = React.useState([]);
|
||||
|
||||
|
||||
const [widgetsRole, setWidgetsRole] = React.useState({
|
||||
role: { value: '', label: '' },
|
||||
});
|
||||
const { currentUser } = useAppSelector((state) => state.auth);
|
||||
const { isFetchingQuery } = useAppSelector((state) => state.openAi);
|
||||
|
||||
const { rolesWidgets, loading } = useAppSelector((state) => state.roles);
|
||||
|
||||
|
||||
async function loadData() {
|
||||
const entities = ['users','roles','permissions','courses','lessons','enrollments','progress',];
|
||||
const fns = [setUsers,setRoles,setPermissions,setCourses,setLessons,setEnrollments,setProgress,];
|
||||
|
||||
const requests = entities.map((entity, index) => {
|
||||
|
||||
if(hasPermission(currentUser, `READ_${entity.toUpperCase()}`)) {
|
||||
return axios.get(`/${entity.toLowerCase()}/count`);
|
||||
} else {
|
||||
fns[index](null);
|
||||
return Promise.resolve({data: {count: null}});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Promise.allSettled(requests).then((results) => {
|
||||
results.forEach((result, i) => {
|
||||
if (result.status === 'fulfilled') {
|
||||
fns[i](result.value.data.count);
|
||||
} else {
|
||||
fns[i](result.reason.message);
|
||||
}
|
||||
if (hasPermission(currentUser, 'READ_LEADS')) {
|
||||
axios.get('/leads/count').then(res => setLeads(res.data.count));
|
||||
}
|
||||
if (hasPermission(currentUser, 'READ_DEALS')) {
|
||||
axios.get('/deals/stats').then(res => {
|
||||
setDealsCount(res.data.count);
|
||||
setTotalValue(res.data.totalValue || 0);
|
||||
});
|
||||
});
|
||||
axios.get('/deals?limit=5&sort=desc&field=createdAt').then(res => setRecentDeals(res.data.rows));
|
||||
}
|
||||
if (hasPermission(currentUser, 'READ_ACTIVITIES')) {
|
||||
axios.get('/activities/count').then(res => setActivitiesCount(res.data.count));
|
||||
axios.get('/activities?limit=10&sort=asc&field=start&completed=false').then(res => setUpcomingActivities(res.data.rows));
|
||||
}
|
||||
if (hasPermission(currentUser, 'READ_PIPELINE_STAGES')) {
|
||||
axios.get('/pipeline_stages').then(res => setPipelineStages(res.data.rows || []));
|
||||
}
|
||||
}
|
||||
|
||||
async function getWidgets(roleId) {
|
||||
await dispatch(fetchWidgets(roleId));
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!currentUser) return;
|
||||
loadData().then();
|
||||
@ -82,18 +76,24 @@ const Dashboard = () => {
|
||||
if (!currentUser || !widgetsRole?.role?.value) return;
|
||||
getWidgets(widgetsRole?.role?.value || '').then();
|
||||
}, [widgetsRole?.role?.value]);
|
||||
|
||||
const formatCurrency = (value) => {
|
||||
return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }).format(value);
|
||||
}
|
||||
|
||||
const isOverdue = (date) => {
|
||||
return new Date(date) < new Date();
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>
|
||||
{getPageTitle('Overview')}
|
||||
</title>
|
||||
<title>{getPageTitle('Overview')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton
|
||||
icon={icon.mdiChartTimelineVariant}
|
||||
title='Overview'
|
||||
title='Sales Overview'
|
||||
main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
@ -104,16 +104,172 @@ const Dashboard = () => {
|
||||
setWidgetsRole={setWidgetsRole}
|
||||
widgetsRole={widgetsRole}
|
||||
/>}
|
||||
{!!rolesWidgets.length &&
|
||||
hasPermission(currentUser, 'CREATE_ROLES') && (
|
||||
<p className=' text-gray-500 dark:text-gray-400 mb-4'>
|
||||
{`${widgetsRole?.role?.label || 'Users'}'s widgets`}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className='grid grid-cols-1 gap-6 lg:grid-cols-4 mb-6'>
|
||||
<CardBox className={`${cardsStyle} border-l-4 border-indigo-500 shadow-md`}>
|
||||
<div className="flex justify-between items-center">
|
||||
<div>
|
||||
<p className="text-xs text-gray-500 uppercase font-bold tracking-wider">Pipeline Value</p>
|
||||
<p className="text-2xl font-black text-indigo-600">{totalValue === '...' ? totalValue : formatCurrency(totalValue)}</p>
|
||||
</div>
|
||||
<div className="bg-indigo-50 p-2 rounded-lg">
|
||||
<BaseIcon path={icon.mdiCurrencyUsd} size={24} className="text-indigo-500" />
|
||||
</div>
|
||||
</div>
|
||||
</CardBox>
|
||||
<CardBox className={`${cardsStyle} border-l-4 border-emerald-500 shadow-md`}>
|
||||
<div className="flex justify-between items-center">
|
||||
<div>
|
||||
<p className="text-xs text-gray-500 uppercase font-bold tracking-wider">Active Deals</p>
|
||||
<p className="text-2xl font-black text-emerald-600">{dealsCount}</p>
|
||||
</div>
|
||||
<div className="bg-emerald-50 p-2 rounded-lg">
|
||||
<BaseIcon path={icon.mdiBriefcaseOutline} size={24} className="text-emerald-500" />
|
||||
</div>
|
||||
</div>
|
||||
</CardBox>
|
||||
<CardBox className={`${cardsStyle} border-l-4 border-amber-500 shadow-md`}>
|
||||
<div className="flex justify-between items-center">
|
||||
<div>
|
||||
<p className="text-xs text-gray-500 uppercase font-bold tracking-wider">Open Leads</p>
|
||||
<p className="text-2xl font-black text-amber-600">{leads}</p>
|
||||
</div>
|
||||
<div className="bg-amber-50 p-2 rounded-lg">
|
||||
<BaseIcon path={icon.mdiAccountArrowRightOutline} size={24} className="text-amber-500" />
|
||||
</div>
|
||||
</div>
|
||||
</CardBox>
|
||||
<CardBox className={`${cardsStyle} border-l-4 border-rose-500 shadow-md`}>
|
||||
<div className="flex justify-between items-center">
|
||||
<div>
|
||||
<p className="text-xs text-gray-500 uppercase font-bold tracking-wider">Total Tasks</p>
|
||||
<p className="text-2xl font-black text-rose-600">{activitiesCount}</p>
|
||||
</div>
|
||||
<div className="bg-rose-50 p-2 rounded-lg">
|
||||
<BaseIcon path={icon.mdiCalendarCheckOutline} size={24} className="text-rose-500" />
|
||||
</div>
|
||||
</div>
|
||||
</CardBox>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6">
|
||||
<CardBox className={`${cardsStyle} lg:col-span-2`}>
|
||||
<div className="flex justify-between items-center mb-6">
|
||||
<div>
|
||||
<h3 className="text-lg font-bold">Recent Deals</h3>
|
||||
<p className="text-xs text-gray-500">Your latest pipeline additions</p>
|
||||
</div>
|
||||
<Link href="/deals/deals-list" className="text-indigo-600 text-sm font-semibold hover:text-indigo-800 transition-colors">View Pipeline</Link>
|
||||
</div>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-left text-sm">
|
||||
<thead>
|
||||
<tr className="border-b dark:border-slate-700">
|
||||
<th className="py-3 px-2 font-bold text-gray-600 uppercase text-[10px] tracking-widest">Title</th>
|
||||
<th className="py-3 px-2 font-bold text-gray-600 uppercase text-[10px] tracking-widest">Value</th>
|
||||
<th className="py-3 px-2 font-bold text-gray-600 uppercase text-[10px] tracking-widest">Stage</th>
|
||||
<th className="py-3 px-2 text-right font-bold text-gray-600 uppercase text-[10px] tracking-widest">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{recentDeals.map((deal: any) => (
|
||||
<tr key={deal.id} className="border-b dark:border-slate-800 last:border-0 hover:bg-gray-50 dark:hover:bg-slate-800/50 transition-colors">
|
||||
<td className="py-4 px-2 font-semibold text-gray-800 dark:text-gray-200">{deal.title}</td>
|
||||
<td className="py-4 px-2 font-medium">{formatCurrency(deal.value)}</td>
|
||||
<td className="py-4 px-2">
|
||||
<span className="text-xs bg-gray-100 dark:bg-slate-800 px-2 py-1 rounded text-gray-600 dark:text-gray-400 font-medium">
|
||||
{deal.stage?.title || 'Unknown'}
|
||||
</span>
|
||||
</td>
|
||||
<td className="py-4 px-2 text-right">
|
||||
<span className={`px-3 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider ${
|
||||
deal.status === 'Won' ? 'bg-emerald-100 text-emerald-700' :
|
||||
deal.status === 'Lost' ? 'bg-rose-100 text-rose-700' :
|
||||
'bg-indigo-100 text-indigo-700'
|
||||
}`}>
|
||||
{deal.status || 'Open'}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
{recentDeals.length === 0 && (
|
||||
<tr>
|
||||
<td colSpan={4} className="py-10 text-center text-gray-500 italic">No recent deals found</td>
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</CardBox>
|
||||
|
||||
<CardBox className={cardsStyle}>
|
||||
<div className="flex justify-between items-center mb-6">
|
||||
<div>
|
||||
<h3 className="text-lg font-bold">Follow-ups</h3>
|
||||
<p className="text-xs text-gray-500">Upcoming actions</p>
|
||||
</div>
|
||||
<Link href="/activities/activities-list" className="text-indigo-600 text-sm font-semibold hover:text-indigo-800 transition-colors">View all</Link>
|
||||
</div>
|
||||
<div className="space-y-3">
|
||||
{upcomingActivities.map((activity: any) => {
|
||||
const overdue = isOverdue(activity.start);
|
||||
return (
|
||||
<div key={activity.id} className={`flex items-start p-3 rounded-xl border transition-all ${overdue ? 'bg-rose-50 border-rose-100 shadow-sm' : 'dark:border-slate-800 hover:border-indigo-200 hover:shadow-sm'}`}>
|
||||
<div className={`p-2 rounded-lg mr-3 shadow-sm ${
|
||||
activity.activity_type === 'Call' ? 'bg-blue-500 text-white' :
|
||||
activity.activity_type === 'Meeting' ? 'bg-indigo-500 text-white' :
|
||||
'bg-amber-500 text-white'
|
||||
}`}>
|
||||
<BaseIcon path={activity.activity_type === 'Call' ? icon.mdiPhone : activity.activity_type === 'Meeting' ? icon.mdiAccountGroup : icon.mdiBellOutline} size={18} />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className={`font-bold text-sm truncate ${overdue ? 'text-rose-700' : 'text-gray-800 dark:text-gray-200'}`}>{activity.subject}</p>
|
||||
<div className="flex items-center mt-1">
|
||||
<BaseIcon path={icon.mdiClockOutline} size={12} className={overdue ? 'text-rose-500' : 'text-gray-400'} />
|
||||
<p className={`text-[10px] ml-1 font-medium ${overdue ? 'text-rose-600 animate-pulse' : 'text-gray-500'}`}>
|
||||
{new Date(activity.start).toLocaleString([], { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' })}
|
||||
{overdue && ' (OVERDUE)'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{upcomingActivities.length === 0 && (
|
||||
<div className="py-10 text-center bg-gray-50 dark:bg-slate-800/50 rounded-xl border border-dashed border-gray-200 dark:border-slate-700">
|
||||
<BaseIcon path={icon.mdiCheckCircleOutline} size={32} className="text-emerald-500 mx-auto mb-2" />
|
||||
<p className="text-gray-500 font-medium text-sm">All caught up!</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardBox>
|
||||
</div>
|
||||
|
||||
{pipelineStages.length > 0 && (
|
||||
<div className="mb-6 overflow-x-auto pb-4">
|
||||
<div className="flex space-x-4 min-w-max">
|
||||
{pipelineStages.sort((a,b) => a.order - b.order).map((stage: any) => (
|
||||
<div key={stage.id} className="bg-white dark:bg-slate-900 border dark:border-slate-800 rounded-xl p-4 w-48 shadow-sm">
|
||||
<p className="text-[10px] font-black text-gray-400 uppercase tracking-widest mb-1">{stage.title}</p>
|
||||
<div className="flex items-end justify-between">
|
||||
<span className="text-lg font-black text-indigo-600">{stage.probability}%</span>
|
||||
<span className="text-xs font-bold text-gray-500">Prob.</span>
|
||||
</div>
|
||||
<div className="w-full bg-gray-100 dark:bg-slate-800 h-1.5 rounded-full mt-3 overflow-hidden">
|
||||
<div
|
||||
className="bg-indigo-500 h-full rounded-full"
|
||||
style={{ width: `${stage.probability}%` }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className='grid grid-cols-1 gap-6 lg:grid-cols-4 mb-6 grid-flow-dense'>
|
||||
{(isFetchingQuery || loading) && (
|
||||
<div className={` ${corners !== 'rounded-full'? corners : 'rounded-3xl'} dark:bg-dark-900 text-lg leading-tight text-gray-500 flex items-center ${cardsStyle} dark:border-dark-700 p-6`}>
|
||||
<div className={` ${corners !== 'rounded-full'? corners : 'rounded-3xl'} dark:bg-dark-900 text-lg leading-tight text-gray-500 flex items-center ${cardsStyle} dark:border-dark-700 p-6 shadow-sm`}>
|
||||
<BaseIcon
|
||||
className={`${iconsColor} animate-spin mr-5`}
|
||||
w='w-16'
|
||||
@ -121,7 +277,7 @@ const Dashboard = () => {
|
||||
size={48}
|
||||
path={icon.mdiLoading}
|
||||
/>{' '}
|
||||
Loading widgets...
|
||||
Loading insights...
|
||||
</div>
|
||||
)}
|
||||
|
||||
@ -137,209 +293,6 @@ const Dashboard = () => {
|
||||
))}
|
||||
</div>
|
||||
|
||||
{!!rolesWidgets.length && <hr className='my-6 ' />}
|
||||
|
||||
<div id="dashboard" className='grid grid-cols-1 gap-6 lg:grid-cols-3 mb-6'>
|
||||
|
||||
|
||||
{hasPermission(currentUser, 'READ_USERS') && <Link href={'/users/users-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">
|
||||
Users
|
||||
</div>
|
||||
<div className="text-3xl leading-tight font-semibold">
|
||||
{users}
|
||||
</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.mdiAccountGroup || icon.mdiTable}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>}
|
||||
|
||||
{hasPermission(currentUser, 'READ_ROLES') && <Link href={'/roles/roles-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">
|
||||
Roles
|
||||
</div>
|
||||
<div className="text-3xl leading-tight font-semibold">
|
||||
{roles}
|
||||
</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.mdiShieldAccountVariantOutline || icon.mdiTable}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>}
|
||||
|
||||
{hasPermission(currentUser, 'READ_PERMISSIONS') && <Link href={'/permissions/permissions-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">
|
||||
Permissions
|
||||
</div>
|
||||
<div className="text-3xl leading-tight font-semibold">
|
||||
{permissions}
|
||||
</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.mdiShieldAccountOutline || icon.mdiTable}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>}
|
||||
|
||||
{hasPermission(currentUser, 'READ_COURSES') && <Link href={'/courses/courses-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">
|
||||
Courses
|
||||
</div>
|
||||
<div className="text-3xl leading-tight font-semibold">
|
||||
{courses}
|
||||
</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={'mdiSchool' in icon ? icon['mdiSchool' as keyof typeof icon] : icon.mdiTable || icon.mdiTable}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>}
|
||||
|
||||
{hasPermission(currentUser, 'READ_LESSONS') && <Link href={'/lessons/lessons-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">
|
||||
Lessons
|
||||
</div>
|
||||
<div className="text-3xl leading-tight font-semibold">
|
||||
{lessons}
|
||||
</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={'mdiBookOpen' in icon ? icon['mdiBookOpen' as keyof typeof icon] : icon.mdiTable || icon.mdiTable}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>}
|
||||
|
||||
{hasPermission(currentUser, 'READ_ENROLLMENTS') && <Link href={'/enrollments/enrollments-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">
|
||||
Enrollments
|
||||
</div>
|
||||
<div className="text-3xl leading-tight font-semibold">
|
||||
{enrollments}
|
||||
</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={'mdiAccountMultiple' in icon ? icon['mdiAccountMultiple' as keyof typeof icon] : icon.mdiTable || icon.mdiTable}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>}
|
||||
|
||||
{hasPermission(currentUser, 'READ_PROGRESS') && <Link href={'/progress/progress-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">
|
||||
Progress
|
||||
</div>
|
||||
<div className="text-3xl leading-tight font-semibold">
|
||||
{progress}
|
||||
</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={'mdiCheckCircle' in icon ? icon['mdiCheckCircle' as keyof typeof icon] : icon.mdiTable || icon.mdiTable}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>}
|
||||
|
||||
|
||||
</div>
|
||||
</SectionMain>
|
||||
</>
|
||||
)
|
||||
@ -349,4 +302,4 @@ Dashboard.getLayout = function getLayout(page: ReactElement) {
|
||||
return <LayoutAuthenticated>{page}</LayoutAuthenticated>
|
||||
}
|
||||
|
||||
export default Dashboard
|
||||
export default Dashboard
|
||||
@ -25,7 +25,7 @@ import { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||
import { SwitchField } from '../../components/SwitchField'
|
||||
import {RichTextField} from "../../components/RichTextField";
|
||||
|
||||
import { update, fetch } from '../../stores/lessons/lessonsSlice'
|
||||
import { update, fetch } from '../../stores/deals/dealsSlice'
|
||||
import { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import {saveFile} from "../../helpers/fileSaver";
|
||||
@ -34,7 +34,7 @@ import ImageField from "../../components/ImageField";
|
||||
|
||||
|
||||
|
||||
const EditLessons = () => {
|
||||
const EditDeals = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const initVals = {
|
||||
@ -68,12 +68,10 @@ const EditLessons = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
'deal_number': '',
|
||||
|
||||
|
||||
|
||||
content: '',
|
||||
|
||||
|
||||
|
||||
|
||||
@ -94,15 +92,11 @@ const EditLessons = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'value': '',
|
||||
|
||||
|
||||
|
||||
@ -117,28 +111,20 @@ const EditLessons = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
course: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
order: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'currency': '',
|
||||
|
||||
|
||||
|
||||
@ -149,8 +135,6 @@ const EditLessons = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -158,8 +142,6 @@ const EditLessons = () => {
|
||||
|
||||
|
||||
|
||||
duration_minutes: '',
|
||||
|
||||
|
||||
|
||||
|
||||
@ -168,17 +150,13 @@ const EditLessons = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -196,69 +174,7 @@ const EditLessons = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
video_files: [],
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
resources: [],
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
release_date: new Date(),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
stage: null,
|
||||
|
||||
|
||||
|
||||
@ -289,50 +205,162 @@ const EditLessons = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
close_date: new Date(),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
owner: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
primary_contact: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
description: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
const { lessons } = useAppSelector((state) => state.lessons)
|
||||
const { deals } = useAppSelector((state) => state.deals)
|
||||
|
||||
|
||||
const { lessonsId } = router.query
|
||||
const { dealsId } = router.query
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetch({ id: lessonsId }))
|
||||
}, [lessonsId])
|
||||
dispatch(fetch({ id: dealsId }))
|
||||
}, [dealsId])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof lessons === 'object') {
|
||||
setInitialValues(lessons)
|
||||
if (typeof deals === 'object') {
|
||||
setInitialValues(deals)
|
||||
}
|
||||
}, [lessons])
|
||||
}, [deals])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof lessons === 'object') {
|
||||
if (typeof deals === 'object') {
|
||||
|
||||
const newInitialVal = {...initVals};
|
||||
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (lessons)[el])
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (deals)[el])
|
||||
|
||||
setInitialValues(newInitialVal);
|
||||
}
|
||||
}, [lessons])
|
||||
}, [deals])
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(update({ id: lessonsId, data }))
|
||||
await router.push('/lessons/lessons-list')
|
||||
await dispatch(update({ id: dealsId, data }))
|
||||
await router.push('/deals/deals-list')
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Edit lessons')}</title>
|
||||
<title>{getPageTitle('Edit deals')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit lessons'} main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit deals'} main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
@ -382,16 +410,13 @@ const EditLessons = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Content' hasTextareaHeight>
|
||||
<FormField
|
||||
label="DealNumber"
|
||||
>
|
||||
<Field
|
||||
name='content'
|
||||
id='content'
|
||||
component={RichTextField}
|
||||
></Field>
|
||||
name="deal_number"
|
||||
placeholder="DealNumber"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
@ -411,6 +436,85 @@ const EditLessons = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Value"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="value"
|
||||
placeholder="Value"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Currency"
|
||||
>
|
||||
<Field
|
||||
name="currency"
|
||||
placeholder="Currency"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -437,13 +541,13 @@ const EditLessons = () => {
|
||||
|
||||
|
||||
|
||||
<FormField label='Course' labelFor='course'>
|
||||
<FormField label='Stage' labelFor='stage'>
|
||||
<Field
|
||||
name='course'
|
||||
id='course'
|
||||
name='stage'
|
||||
id='stage'
|
||||
component={SelectField}
|
||||
options={initialValues.course}
|
||||
itemRef={'courses'}
|
||||
options={initialValues.stage}
|
||||
itemRef={'pipeline_stages'}
|
||||
|
||||
|
||||
|
||||
@ -461,6 +565,8 @@ const EditLessons = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
@ -482,14 +588,24 @@ const EditLessons = () => {
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Order"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="order"
|
||||
placeholder="Order"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Status" labelFor="status">
|
||||
<Field name="status" id="status" component="select">
|
||||
|
||||
<option value="Open">Open</option>
|
||||
|
||||
<option value="Won">Won</option>
|
||||
|
||||
<option value="Lost">Lost</option>
|
||||
|
||||
</Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
@ -499,144 +615,10 @@ const EditLessons = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Duration(minutes)"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="duration_minutes"
|
||||
placeholder="Duration(minutes)"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField>
|
||||
<Field
|
||||
label='VideoFiles'
|
||||
color='info'
|
||||
icon={mdiUpload}
|
||||
path={'lessons/video_files'}
|
||||
name='video_files'
|
||||
id='video_files'
|
||||
schema={{
|
||||
size: undefined,
|
||||
formats: undefined,
|
||||
}}
|
||||
component={FormFilePicker}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField>
|
||||
<Field
|
||||
label='Resources'
|
||||
color='info'
|
||||
icon={mdiUpload}
|
||||
path={'lessons/resources'}
|
||||
name='resources'
|
||||
id='resources'
|
||||
schema={{
|
||||
size: undefined,
|
||||
formats: undefined,
|
||||
}}
|
||||
component={FormFilePicker}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -651,17 +633,17 @@ const EditLessons = () => {
|
||||
|
||||
|
||||
<FormField
|
||||
label="ReleaseDate"
|
||||
label="CloseDate"
|
||||
>
|
||||
<DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={initialValues.release_date ?
|
||||
selected={initialValues.close_date ?
|
||||
new Date(
|
||||
dayjs(initialValues.release_date).format('YYYY-MM-DD hh:mm'),
|
||||
dayjs(initialValues.close_date).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
onChange={(date) => setInitialValues({...initialValues, 'release_date': date})}
|
||||
onChange={(date) => setInitialValues({...initialValues, 'close_date': date})}
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
@ -697,17 +679,133 @@ const EditLessons = () => {
|
||||
|
||||
|
||||
|
||||
<FormField label="Status" labelFor="status">
|
||||
<Field name="status" id="status" component="select">
|
||||
|
||||
<option value="draft">draft</option>
|
||||
|
||||
<option value="published">published</option>
|
||||
|
||||
<option value="archived">archived</option>
|
||||
|
||||
</Field>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Owner' labelFor='owner'>
|
||||
<Field
|
||||
name='owner'
|
||||
id='owner'
|
||||
component={SelectField}
|
||||
options={initialValues.owner}
|
||||
itemRef={'users'}
|
||||
|
||||
|
||||
showField={'firstName'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='PrimaryContact' labelFor='primary_contact'>
|
||||
<Field
|
||||
name='primary_contact'
|
||||
id='primary_contact'
|
||||
component={SelectField}
|
||||
options={initialValues.primary_contact}
|
||||
itemRef={'contacts'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
showField={'name'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Description' hasTextareaHeight>
|
||||
<Field
|
||||
name='description'
|
||||
id='description'
|
||||
component={RichTextField}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -727,7 +825,7 @@ const EditLessons = () => {
|
||||
<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('/lessons/lessons-list')}/>
|
||||
<BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/deals/deals-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
@ -737,11 +835,11 @@ const EditLessons = () => {
|
||||
)
|
||||
}
|
||||
|
||||
EditLessons.getLayout = function getLayout(page: ReactElement) {
|
||||
EditDeals.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'UPDATE_LESSONS'}
|
||||
permission={'UPDATE_DEALS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -749,4 +847,4 @@ EditLessons.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default EditLessons
|
||||
export default EditDeals
|
||||
@ -25,7 +25,7 @@ import { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||
import { SwitchField } from '../../components/SwitchField'
|
||||
import {RichTextField} from "../../components/RichTextField";
|
||||
|
||||
import { update, fetch } from '../../stores/lessons/lessonsSlice'
|
||||
import { update, fetch } from '../../stores/deals/dealsSlice'
|
||||
import { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import {saveFile} from "../../helpers/fileSaver";
|
||||
@ -34,7 +34,7 @@ import ImageField from "../../components/ImageField";
|
||||
|
||||
|
||||
|
||||
const EditLessonsPage = () => {
|
||||
const EditDealsPage = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const initVals = {
|
||||
@ -68,12 +68,10 @@ const EditLessonsPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
'deal_number': '',
|
||||
|
||||
|
||||
|
||||
content: '',
|
||||
|
||||
|
||||
|
||||
|
||||
@ -94,15 +92,11 @@ const EditLessonsPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'value': '',
|
||||
|
||||
|
||||
|
||||
@ -117,28 +111,20 @@ const EditLessonsPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
course: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
order: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'currency': '',
|
||||
|
||||
|
||||
|
||||
@ -149,8 +135,6 @@ const EditLessonsPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -158,8 +142,6 @@ const EditLessonsPage = () => {
|
||||
|
||||
|
||||
|
||||
duration_minutes: '',
|
||||
|
||||
|
||||
|
||||
|
||||
@ -168,17 +150,13 @@ const EditLessonsPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -196,69 +174,7 @@ const EditLessonsPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
video_files: [],
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
resources: [],
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
release_date: new Date(),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
stage: null,
|
||||
|
||||
|
||||
|
||||
@ -289,13 +205,125 @@ const EditLessonsPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
close_date: new Date(),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
owner: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
primary_contact: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
description: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
const { lessons } = useAppSelector((state) => state.lessons)
|
||||
const { deals } = useAppSelector((state) => state.deals)
|
||||
|
||||
|
||||
const { id } = router.query
|
||||
@ -305,31 +333,31 @@ const EditLessonsPage = () => {
|
||||
}, [id])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof lessons === 'object') {
|
||||
setInitialValues(lessons)
|
||||
if (typeof deals === 'object') {
|
||||
setInitialValues(deals)
|
||||
}
|
||||
}, [lessons])
|
||||
}, [deals])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof lessons === 'object') {
|
||||
if (typeof deals === 'object') {
|
||||
const newInitialVal = {...initVals};
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (lessons)[el])
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (deals)[el])
|
||||
setInitialValues(newInitialVal);
|
||||
}
|
||||
}, [lessons])
|
||||
}, [deals])
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(update({ id: id, data }))
|
||||
await router.push('/lessons/lessons-list')
|
||||
await router.push('/deals/deals-list')
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Edit lessons')}</title>
|
||||
<title>{getPageTitle('Edit deals')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit lessons'} main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit deals'} main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
@ -379,16 +407,13 @@ const EditLessonsPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Content' hasTextareaHeight>
|
||||
<FormField
|
||||
label="DealNumber"
|
||||
>
|
||||
<Field
|
||||
name='content'
|
||||
id='content'
|
||||
component={RichTextField}
|
||||
></Field>
|
||||
name="deal_number"
|
||||
placeholder="DealNumber"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
@ -408,6 +433,85 @@ const EditLessonsPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Value"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="value"
|
||||
placeholder="Value"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Currency"
|
||||
>
|
||||
<Field
|
||||
name="currency"
|
||||
placeholder="Currency"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -434,13 +538,13 @@ const EditLessonsPage = () => {
|
||||
|
||||
|
||||
|
||||
<FormField label='Course' labelFor='course'>
|
||||
<FormField label='Stage' labelFor='stage'>
|
||||
<Field
|
||||
name='course'
|
||||
id='course'
|
||||
name='stage'
|
||||
id='stage'
|
||||
component={SelectField}
|
||||
options={initialValues.course}
|
||||
itemRef={'courses'}
|
||||
options={initialValues.stage}
|
||||
itemRef={'pipeline_stages'}
|
||||
|
||||
|
||||
|
||||
@ -458,6 +562,8 @@ const EditLessonsPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
@ -479,14 +585,24 @@ const EditLessonsPage = () => {
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Order"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="order"
|
||||
placeholder="Order"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Status" labelFor="status">
|
||||
<Field name="status" id="status" component="select">
|
||||
|
||||
<option value="Open">Open</option>
|
||||
|
||||
<option value="Won">Won</option>
|
||||
|
||||
<option value="Lost">Lost</option>
|
||||
|
||||
</Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
@ -496,144 +612,10 @@ const EditLessonsPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Duration(minutes)"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="duration_minutes"
|
||||
placeholder="Duration(minutes)"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField>
|
||||
<Field
|
||||
label='VideoFiles'
|
||||
color='info'
|
||||
icon={mdiUpload}
|
||||
path={'lessons/video_files'}
|
||||
name='video_files'
|
||||
id='video_files'
|
||||
schema={{
|
||||
size: undefined,
|
||||
formats: undefined,
|
||||
}}
|
||||
component={FormFilePicker}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField>
|
||||
<Field
|
||||
label='Resources'
|
||||
color='info'
|
||||
icon={mdiUpload}
|
||||
path={'lessons/resources'}
|
||||
name='resources'
|
||||
id='resources'
|
||||
schema={{
|
||||
size: undefined,
|
||||
formats: undefined,
|
||||
}}
|
||||
component={FormFilePicker}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -648,17 +630,17 @@ const EditLessonsPage = () => {
|
||||
|
||||
|
||||
<FormField
|
||||
label="ReleaseDate"
|
||||
label="CloseDate"
|
||||
>
|
||||
<DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={initialValues.release_date ?
|
||||
selected={initialValues.close_date ?
|
||||
new Date(
|
||||
dayjs(initialValues.release_date).format('YYYY-MM-DD hh:mm'),
|
||||
dayjs(initialValues.close_date).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
onChange={(date) => setInitialValues({...initialValues, 'release_date': date})}
|
||||
onChange={(date) => setInitialValues({...initialValues, 'close_date': date})}
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
@ -694,17 +676,133 @@ const EditLessonsPage = () => {
|
||||
|
||||
|
||||
|
||||
<FormField label="Status" labelFor="status">
|
||||
<Field name="status" id="status" component="select">
|
||||
|
||||
<option value="draft">draft</option>
|
||||
|
||||
<option value="published">published</option>
|
||||
|
||||
<option value="archived">archived</option>
|
||||
|
||||
</Field>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Owner' labelFor='owner'>
|
||||
<Field
|
||||
name='owner'
|
||||
id='owner'
|
||||
component={SelectField}
|
||||
options={initialValues.owner}
|
||||
itemRef={'users'}
|
||||
|
||||
|
||||
showField={'firstName'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='PrimaryContact' labelFor='primary_contact'>
|
||||
<Field
|
||||
name='primary_contact'
|
||||
id='primary_contact'
|
||||
component={SelectField}
|
||||
options={initialValues.primary_contact}
|
||||
itemRef={'contacts'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
showField={'name'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Description' hasTextareaHeight>
|
||||
<Field
|
||||
name='description'
|
||||
id='description'
|
||||
component={RichTextField}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -724,7 +822,7 @@ const EditLessonsPage = () => {
|
||||
<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('/lessons/lessons-list')}/>
|
||||
<BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/deals/deals-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
@ -734,11 +832,11 @@ const EditLessonsPage = () => {
|
||||
)
|
||||
}
|
||||
|
||||
EditLessonsPage.getLayout = function getLayout(page: ReactElement) {
|
||||
EditDealsPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'UPDATE_LESSONS'}
|
||||
permission={'UPDATE_DEALS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -746,4 +844,4 @@ EditLessonsPage.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default EditLessonsPage
|
||||
export default EditDealsPage
|
||||
201
frontend/src/pages/deals/deals-list.tsx
Normal file
201
frontend/src/pages/deals/deals-list.tsx
Normal file
@ -0,0 +1,201 @@
|
||||
import { mdiChartTimelineVariant, mdiViewColumn, mdiTable } from '@mdi/js'
|
||||
import Head from 'next/head'
|
||||
import { uniqueId } from 'lodash';
|
||||
import React, { ReactElement, useState, useEffect } 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 TableDeals from '../../components/Deals/TableDeals'
|
||||
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, deleteItem, update} from '../../stores/deals/dealsSlice';
|
||||
import KanbanBoard from '../../components/KanbanBoard/KanbanBoard';
|
||||
|
||||
|
||||
import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
|
||||
const DealsTablesPage = () => {
|
||||
const [filterItems, setFilterItems] = useState([]);
|
||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||
const [isModalActive, setIsModalActive] = useState(false);
|
||||
const [isKanbanView, setIsKanbanView] = useState(false);
|
||||
const [pipelineStages, setPipelineStages] = useState([]);
|
||||
|
||||
|
||||
const { currentUser } = useAppSelector((state) => state.auth);
|
||||
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
|
||||
const [filters] = useState([{label: 'Title', title: 'title'},{label: 'DealNumber', title: 'deal_number'},{label: 'Currency', title: 'currency'},{label: 'Description', title: 'description'},
|
||||
|
||||
{label: 'Value', title: 'value', number: 'true'},
|
||||
{label: 'CloseDate', title: 'close_date', date: 'true'},
|
||||
|
||||
|
||||
{label: 'Stage', title: 'stage'},
|
||||
|
||||
|
||||
|
||||
{label: 'Owner', title: 'owner'},
|
||||
|
||||
|
||||
|
||||
{label: 'PrimaryContact', title: 'primary_contact'},
|
||||
|
||||
|
||||
|
||||
{label: 'Status', title: 'status', type: 'enum', options: ['Open','Won','Lost']},
|
||||
]);
|
||||
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_DEALS');
|
||||
|
||||
useEffect(() => {
|
||||
axios.get('/pipeline_stages').then(res => {
|
||||
setPipelineStages(res.data.rows?.sort((a,b) => a.order - b.order).map(s => ({id: s.id, label: s.title})) || []);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const addFilter = () => {
|
||||
const newItem = {
|
||||
id: uniqueId(),
|
||||
fields: {
|
||||
filterValue: '',
|
||||
filterValueFrom: '',
|
||||
filterValueTo: '',
|
||||
selectedField: '',
|
||||
},
|
||||
};
|
||||
newItem.fields.selectedField = filters[0].title;
|
||||
setFilterItems([...filterItems, newItem]);
|
||||
};
|
||||
|
||||
const getDealsCSV = async () => {
|
||||
const response = await axios({url: '/deals?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 = 'dealsCSV.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('Deals')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Pipeline" main>
|
||||
<div className="flex space-x-2">
|
||||
<BaseButton
|
||||
icon={isKanbanView ? mdiTable : mdiViewColumn}
|
||||
label={isKanbanView ? 'Table View' : 'Kanban Board'}
|
||||
color="whiteDark"
|
||||
onClick={() => setIsKanbanView(!isKanbanView)}
|
||||
/>
|
||||
{hasCreatePermission && <BaseButton href={'/deals/deals-new'} color='info' label='New Deal'/>}
|
||||
</div>
|
||||
</SectionTitleLineWithButton>
|
||||
|
||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap items-center'>
|
||||
<BaseButton
|
||||
className={'mr-3'}
|
||||
color='info'
|
||||
label='Add Filter'
|
||||
onClick={addFilter}
|
||||
/>
|
||||
<BaseButton className={'mr-3'} color='info' outline label='Export CSV' onClick={getDealsCSV} />
|
||||
|
||||
{hasCreatePermission && (
|
||||
<BaseButton
|
||||
color='info'
|
||||
outline
|
||||
label='Import CSV'
|
||||
onClick={() => setIsModalActive(true)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className='md:inline-flex items-center ms-auto'>
|
||||
<div id='delete-rows-button'></div>
|
||||
</div>
|
||||
|
||||
<div className='md:inline-flex items-center ms-auto'>
|
||||
<Link href={'/deals/deals-table'} className="text-sm font-medium text-indigo-600 hover:underline">Full Table View</Link>
|
||||
</div>
|
||||
|
||||
</CardBox>
|
||||
|
||||
{isKanbanView ? (
|
||||
<div className="h-[calc(100vh-350px)] overflow-hidden">
|
||||
<KanbanBoard
|
||||
columns={pipelineStages}
|
||||
entityName="deals"
|
||||
columnFieldName="stageId"
|
||||
filtersQuery={''} // You can pass dynamic filters here if needed
|
||||
showFieldName="title"
|
||||
deleteThunk={deleteItem}
|
||||
updateThunk={update}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<TableDeals
|
||||
filterItems={filterItems}
|
||||
setFilterItems={setFilterItems}
|
||||
filters={filters}
|
||||
showGrid={false}
|
||||
/>
|
||||
)}
|
||||
|
||||
</SectionMain>
|
||||
<CardBoxModal
|
||||
title='Upload CSV'
|
||||
buttonColor='info'
|
||||
buttonLabel={'Confirm'}
|
||||
isActive={isModalActive}
|
||||
onConfirm={onModalConfirm}
|
||||
onCancel={onModalCancel}
|
||||
>
|
||||
<DragDropFilePicker
|
||||
file={csvFile}
|
||||
setFile={setCsvFile}
|
||||
formats={'.csv'}
|
||||
/>
|
||||
</CardBoxModal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
DealsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
permission={'READ_DEALS'}
|
||||
>
|
||||
{page}
|
||||
</LayoutAuthenticated>
|
||||
)
|
||||
}
|
||||
|
||||
export default DealsTablesPage
|
||||
@ -22,7 +22,7 @@ import { SelectField } from '../../components/SelectField'
|
||||
import { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||
import {RichTextField} from "../../components/RichTextField";
|
||||
|
||||
import { create } from '../../stores/lessons/lessonsSlice'
|
||||
import { create } from '../../stores/deals/dealsSlice'
|
||||
import { useAppDispatch } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import moment from 'moment';
|
||||
@ -46,9 +46,9 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
deal_number: '',
|
||||
|
||||
|
||||
content: '',
|
||||
|
||||
|
||||
|
||||
@ -62,6 +62,7 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
value: '',
|
||||
|
||||
|
||||
|
||||
@ -73,15 +74,14 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
course: '',
|
||||
|
||||
|
||||
|
||||
|
||||
currency: '',
|
||||
|
||||
|
||||
|
||||
order: '',
|
||||
|
||||
|
||||
|
||||
@ -97,7 +97,6 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
duration_minutes: '',
|
||||
|
||||
|
||||
|
||||
@ -106,6 +105,7 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
stage: '',
|
||||
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
video_files: [],
|
||||
status: 'Open',
|
||||
|
||||
|
||||
|
||||
@ -132,10 +132,10 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
close_date: '',
|
||||
|
||||
|
||||
|
||||
resources: [],
|
||||
|
||||
|
||||
|
||||
@ -147,7 +147,6 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
release_date: '',
|
||||
|
||||
|
||||
|
||||
@ -155,6 +154,7 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
owner: '',
|
||||
|
||||
|
||||
|
||||
@ -167,7 +167,23 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
status: 'draft',
|
||||
|
||||
|
||||
|
||||
primary_contact: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
description: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -177,7 +193,7 @@ const initialValues = {
|
||||
}
|
||||
|
||||
|
||||
const LessonsNew = () => {
|
||||
const DealsNew = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
|
||||
@ -186,7 +202,7 @@ const LessonsNew = () => {
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(create(data))
|
||||
await router.push('/lessons/lessons-list')
|
||||
await router.push('/deals/deals-list')
|
||||
}
|
||||
return (
|
||||
<>
|
||||
@ -238,236 +254,6 @@ const LessonsNew = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Content' hasTextareaHeight>
|
||||
<Field
|
||||
name='content'
|
||||
id='content'
|
||||
component={RichTextField}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Course" labelFor="course">
|
||||
<Field name="course" id="course" component={SelectField} options={[]} itemRef={'courses'}></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Order"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="order"
|
||||
placeholder="Order"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Duration(minutes)"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="duration_minutes"
|
||||
placeholder="Duration(minutes)"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField>
|
||||
<Field
|
||||
label='VideoFiles'
|
||||
color='info'
|
||||
icon={mdiUpload}
|
||||
path={'lessons/video_files'}
|
||||
name='video_files'
|
||||
id='video_files'
|
||||
schema={{
|
||||
size: undefined,
|
||||
formats: undefined,
|
||||
}}
|
||||
component={FormFilePicker}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField>
|
||||
<Field
|
||||
label='Resources'
|
||||
color='info'
|
||||
icon={mdiUpload}
|
||||
path={'lessons/resources'}
|
||||
name='resources'
|
||||
id='resources'
|
||||
schema={{
|
||||
size: undefined,
|
||||
formats: undefined,
|
||||
}}
|
||||
component={FormFilePicker}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -476,12 +262,11 @@ const LessonsNew = () => {
|
||||
|
||||
|
||||
<FormField
|
||||
label="ReleaseDate"
|
||||
label="DealNumber"
|
||||
>
|
||||
<Field
|
||||
type="datetime-local"
|
||||
name="release_date"
|
||||
placeholder="ReleaseDate"
|
||||
name="deal_number"
|
||||
placeholder="DealNumber"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
@ -504,6 +289,117 @@ const LessonsNew = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Value"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="value"
|
||||
placeholder="Value"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Currency"
|
||||
>
|
||||
<Field
|
||||
name="currency"
|
||||
placeholder="Currency"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Stage" labelFor="stage">
|
||||
<Field name="stage" id="stage" component={SelectField} options={[]} itemRef={'pipeline_stages'}></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -518,11 +414,11 @@ const LessonsNew = () => {
|
||||
<FormField label="Status" labelFor="status">
|
||||
<Field name="status" id="status" component="select">
|
||||
|
||||
<option value="draft">draft</option>
|
||||
<option value="Open">Open</option>
|
||||
|
||||
<option value="published">published</option>
|
||||
<option value="Won">Won</option>
|
||||
|
||||
<option value="archived">archived</option>
|
||||
<option value="Lost">Lost</option>
|
||||
|
||||
</Field>
|
||||
</FormField>
|
||||
@ -536,12 +432,142 @@ const LessonsNew = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="CloseDate"
|
||||
>
|
||||
<Field
|
||||
type="datetime-local"
|
||||
name="close_date"
|
||||
placeholder="CloseDate"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Owner" labelFor="owner">
|
||||
<Field name="owner" id="owner" component={SelectField} options={[]} itemRef={'users'}></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="PrimaryContact" labelFor="primary_contact">
|
||||
<Field name="primary_contact" id="primary_contact" component={SelectField} options={[]} itemRef={'contacts'}></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Description' hasTextareaHeight>
|
||||
<Field
|
||||
name='description'
|
||||
id='description'
|
||||
component={RichTextField}
|
||||
></Field>
|
||||
</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('/lessons/lessons-list')}/>
|
||||
<BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/deals/deals-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
@ -551,11 +577,11 @@ const LessonsNew = () => {
|
||||
)
|
||||
}
|
||||
|
||||
LessonsNew.getLayout = function getLayout(page: ReactElement) {
|
||||
DealsNew.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'CREATE_LESSONS'}
|
||||
permission={'CREATE_DEALS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -563,4 +589,4 @@ LessonsNew.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default LessonsNew
|
||||
export default DealsNew
|
||||
@ -7,21 +7,21 @@ import LayoutAuthenticated from '../../layouts/Authenticated'
|
||||
import SectionMain from '../../components/SectionMain'
|
||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||
import { getPageTitle } from '../../config'
|
||||
import TableLessons from '../../components/Lessons/TableLessons'
|
||||
import TableDeals from '../../components/Deals/TableDeals'
|
||||
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/lessons/lessonsSlice';
|
||||
import {setRefetch, uploadCsv} from '../../stores/deals/dealsSlice';
|
||||
|
||||
|
||||
import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
|
||||
const LessonsTablesPage = () => {
|
||||
const DealsTablesPage = () => {
|
||||
const [filterItems, setFilterItems] = useState([]);
|
||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||
const [isModalActive, setIsModalActive] = useState(false);
|
||||
@ -34,20 +34,28 @@ const LessonsTablesPage = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
|
||||
const [filters] = useState([{label: 'Title', title: 'title'},{label: 'Content', title: 'content'},
|
||||
{label: 'Order', title: 'order', number: 'true'},{label: 'Duration(minutes)', title: 'duration_minutes', number: 'true'},
|
||||
const [filters] = useState([{label: 'Title', title: 'title'},{label: 'DealNumber', title: 'deal_number'},{label: 'Currency', title: 'currency'},{label: 'Description', title: 'description'},
|
||||
|
||||
{label: 'ReleaseDate', title: 'release_date', date: 'true'},
|
||||
{label: 'Value', title: 'value', number: 'true'},
|
||||
{label: 'CloseDate', title: 'close_date', date: 'true'},
|
||||
|
||||
|
||||
{label: 'Course', title: 'course'},
|
||||
{label: 'Stage', title: 'stage'},
|
||||
|
||||
|
||||
|
||||
{label: 'Owner', title: 'owner'},
|
||||
|
||||
|
||||
|
||||
{label: 'PrimaryContact', title: 'primary_contact'},
|
||||
|
||||
|
||||
|
||||
{label: 'Status', title: 'status', type: 'enum', options: ['draft','published','archived']},
|
||||
{label: 'Status', title: 'status', type: 'enum', options: ['Open','Won','Lost']},
|
||||
]);
|
||||
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_LESSONS');
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_DEALS');
|
||||
|
||||
|
||||
const addFilter = () => {
|
||||
@ -64,13 +72,13 @@ const LessonsTablesPage = () => {
|
||||
setFilterItems([...filterItems, newItem]);
|
||||
};
|
||||
|
||||
const getLessonsCSV = async () => {
|
||||
const response = await axios({url: '/lessons?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||
const getDealsCSV = async () => {
|
||||
const response = await axios({url: '/deals?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 = 'lessonsCSV.csv'
|
||||
link.download = 'dealsCSV.csv'
|
||||
link.click()
|
||||
};
|
||||
|
||||
@ -90,15 +98,15 @@ const LessonsTablesPage = () => {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Lessons')}</title>
|
||||
<title>{getPageTitle('Deals')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Lessons" main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Deals" main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
||||
|
||||
{hasCreatePermission && <BaseButton className={'mr-3'} href={'/lessons/lessons-new'} color='info' label='New Item'/>}
|
||||
{hasCreatePermission && <BaseButton className={'mr-3'} href={'/deals/deals-new'} color='info' label='New Item'/>}
|
||||
|
||||
<BaseButton
|
||||
className={'mr-3'}
|
||||
@ -106,7 +114,7 @@ const LessonsTablesPage = () => {
|
||||
label='Filter'
|
||||
onClick={addFilter}
|
||||
/>
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getLessonsCSV} />
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getDealsCSV} />
|
||||
|
||||
{hasCreatePermission && (
|
||||
<BaseButton
|
||||
@ -119,14 +127,14 @@ const LessonsTablesPage = () => {
|
||||
<div className='md:inline-flex items-center ms-auto'>
|
||||
<div id='delete-rows-button'></div>
|
||||
|
||||
<Link href={'/lessons/lessons-list'}>
|
||||
<Link href={'/deals/deals-list'}>
|
||||
Back to <span className='capitalize'>kanban</span>
|
||||
</Link>
|
||||
|
||||
</div>
|
||||
</CardBox>
|
||||
<CardBox className="mb-6" hasTable>
|
||||
<TableLessons
|
||||
<TableDeals
|
||||
filterItems={filterItems}
|
||||
setFilterItems={setFilterItems}
|
||||
filters={filters}
|
||||
@ -153,11 +161,11 @@ const LessonsTablesPage = () => {
|
||||
)
|
||||
}
|
||||
|
||||
LessonsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
DealsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'READ_LESSONS'}
|
||||
permission={'READ_DEALS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -165,4 +173,4 @@ LessonsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default LessonsTablesPage
|
||||
export default DealsTablesPage
|
||||
@ -5,7 +5,7 @@ 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/courses/coursesSlice'
|
||||
import { fetch } from '../../stores/deals/dealsSlice'
|
||||
import {saveFile} from "../../helpers/fileSaver";
|
||||
import dataFormatter from '../../helpers/dataFormatter';
|
||||
import ImageField from "../../components/ImageField";
|
||||
@ -21,10 +21,10 @@ import {SwitchField} from "../../components/SwitchField";
|
||||
import FormField from "../../components/FormField";
|
||||
|
||||
|
||||
const CoursesView = () => {
|
||||
const DealsView = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const { courses } = useAppSelector((state) => state.courses)
|
||||
const { deals } = useAppSelector((state) => state.deals)
|
||||
|
||||
|
||||
const { id } = router.query;
|
||||
@ -42,14 +42,14 @@ const CoursesView = () => {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('View courses')}</title>
|
||||
<title>{getPageTitle('View deals')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View courses')} main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View deals')} main>
|
||||
<BaseButton
|
||||
color='info'
|
||||
label='Edit'
|
||||
href={`/courses/courses-edit/?id=${id}`}
|
||||
href={`/deals/deals-edit/?id=${id}`}
|
||||
/>
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
@ -58,7 +58,7 @@ const CoursesView = () => {
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Title</p>
|
||||
<p>{courses?.title}</p>
|
||||
<p>{deals?.title}</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -85,6 +85,40 @@ const CoursesView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>DealNumber</p>
|
||||
<p>{deals?.deal_number}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -93,11 +127,8 @@ const CoursesView = () => {
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Description</p>
|
||||
{courses.description
|
||||
? <p dangerouslySetInnerHTML={{__html: courses.description}}/>
|
||||
: <p>No data</p>
|
||||
}
|
||||
<p className={'block font-bold mb-2'}>Value</p>
|
||||
<p>{deals?.value || 'No data'}</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -118,6 +149,36 @@ const CoursesView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Currency</p>
|
||||
<p>{deals?.currency}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -143,10 +204,136 @@ const CoursesView = () => {
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Instructor</p>
|
||||
<p className={'block font-bold mb-2'}>Stage</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p>{deals?.stage?.title ?? 'No data'}</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Status</p>
|
||||
<p>{deals?.status ?? 'No data'}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='CloseDate'>
|
||||
{deals.close_date ? <DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={deals.close_date ?
|
||||
new Date(
|
||||
dayjs(deals.close_date).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
disabled
|
||||
/> : <p>No CloseDate</p>}
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Owner</p>
|
||||
|
||||
|
||||
<p>{deals?.owner?.firstName ?? 'No data'}</p>
|
||||
|
||||
|
||||
<p>{courses?.instructor?.firstName ?? 'No data'}</p>
|
||||
|
||||
|
||||
|
||||
@ -186,11 +373,35 @@ const CoursesView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Category</p>
|
||||
<p>{courses?.category ?? 'No data'}</p>
|
||||
<p className={'block font-bold mb-2'}>PrimaryContact</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p>{deals?.primary_contact?.name ?? 'No data'}</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -198,20 +409,6 @@ const CoursesView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -220,213 +417,11 @@ const CoursesView = () => {
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Level</p>
|
||||
<p>{courses?.level ?? 'No data'}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Thumbnail</p>
|
||||
{courses?.thumbnail?.length
|
||||
? (
|
||||
<ImageField
|
||||
name={'thumbnail'}
|
||||
image={courses?.thumbnail}
|
||||
className='w-20 h-20'
|
||||
/>
|
||||
) : <p>No Thumbnail</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Published'>
|
||||
<SwitchField
|
||||
field={{name: 'published', value: courses?.published}}
|
||||
form={{setFieldValue: () => null}}
|
||||
disabled
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='StartDate'>
|
||||
{courses.start_date ? <DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={courses.start_date ?
|
||||
new Date(
|
||||
dayjs(courses.start_date).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
disabled
|
||||
/> : <p>No StartDate</p>}
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='EndDate'>
|
||||
{courses.end_date ? <DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={courses.end_date ?
|
||||
new Date(
|
||||
dayjs(courses.end_date).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
disabled
|
||||
/> : <p>No EndDate</p>}
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Price</p>
|
||||
<p>{courses?.price || 'No data'}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Language</p>
|
||||
<p>{courses?.language}</p>
|
||||
<p className={'block font-bold mb-2'}>Description</p>
|
||||
{deals.description
|
||||
? <p dangerouslySetInnerHTML={{__html: deals.description}}/>
|
||||
: <p>No data</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
@ -444,10 +439,6 @@ const CoursesView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -456,12 +447,15 @@ const CoursesView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<>
|
||||
<p className={'block font-bold mb-2'}>Lessons Course</p>
|
||||
<p className={'block font-bold mb-2'}>Activities RelatedDeal</p>
|
||||
<CardBox
|
||||
className='mb-6 border border-gray-300 rounded overflow-hidden'
|
||||
hasTable
|
||||
@ -472,7 +466,23 @@ const CoursesView = () => {
|
||||
<tr>
|
||||
|
||||
|
||||
<th>Title</th>
|
||||
<th>Subject</th>
|
||||
|
||||
|
||||
|
||||
<th>ActivityType</th>
|
||||
|
||||
|
||||
|
||||
<th>Start</th>
|
||||
|
||||
|
||||
|
||||
<th>End</th>
|
||||
|
||||
|
||||
|
||||
<th>Completed</th>
|
||||
|
||||
|
||||
|
||||
@ -480,35 +490,43 @@ const CoursesView = () => {
|
||||
|
||||
|
||||
|
||||
<th>Order</th>
|
||||
|
||||
|
||||
|
||||
<th>Duration(minutes)</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th>ReleaseDate</th>
|
||||
|
||||
|
||||
|
||||
<th>Status</th>
|
||||
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{courses.lessons_course && Array.isArray(courses.lessons_course) &&
|
||||
courses.lessons_course.map((item: any) => (
|
||||
<tr key={item.id} onClick={() => router.push(`/lessons/lessons-view/?id=${item.id}`)}>
|
||||
{deals.activities_related_deal && Array.isArray(deals.activities_related_deal) &&
|
||||
deals.activities_related_deal.map((item: any) => (
|
||||
<tr key={item.id} onClick={() => router.push(`/activities/activities-view/?id=${item.id}`)}>
|
||||
|
||||
|
||||
<td data-label="title">
|
||||
{ item.title }
|
||||
<td data-label="subject">
|
||||
{ item.subject }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="activity_type">
|
||||
{ item.activity_type }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="start">
|
||||
{ dataFormatter.dateTimeFormatter(item.start) }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="end">
|
||||
{ dataFormatter.dateTimeFormatter(item.end) }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="completed">
|
||||
{ dataFormatter.booleanFormatter(item.completed) }
|
||||
</td>
|
||||
|
||||
|
||||
@ -517,137 +535,26 @@ const CoursesView = () => {
|
||||
|
||||
|
||||
|
||||
<td data-label="order">
|
||||
{ item.order }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="duration_minutes">
|
||||
{ item.duration_minutes }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td data-label="release_date">
|
||||
{ dataFormatter.dateTimeFormatter(item.release_date) }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="status">
|
||||
{ item.status }
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{!courses?.lessons_course?.length && <div className={'text-center py-4'}>No data</div>}
|
||||
{!deals?.activities_related_deal?.length && <div className={'text-center py-4'}>No data</div>}
|
||||
</CardBox>
|
||||
</>
|
||||
|
||||
|
||||
<>
|
||||
<p className={'block font-bold mb-2'}>Enrollments Course</p>
|
||||
<CardBox
|
||||
className='mb-6 border border-gray-300 rounded overflow-hidden'
|
||||
hasTable
|
||||
>
|
||||
<div className='overflow-x-auto'>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
|
||||
<th>EnrollmentLabel</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th>EnrolledAt</th>
|
||||
|
||||
|
||||
|
||||
<th>Status</th>
|
||||
|
||||
|
||||
|
||||
<th>ProgressPercent</th>
|
||||
|
||||
|
||||
|
||||
<th>PricePaid</th>
|
||||
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{courses.enrollments_course && Array.isArray(courses.enrollments_course) &&
|
||||
courses.enrollments_course.map((item: any) => (
|
||||
<tr key={item.id} onClick={() => router.push(`/enrollments/enrollments-view/?id=${item.id}`)}>
|
||||
|
||||
|
||||
<td data-label="enrollment_label">
|
||||
{ item.enrollment_label }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td data-label="enrolled_at">
|
||||
{ dataFormatter.dateTimeFormatter(item.enrolled_at) }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="status">
|
||||
{ item.status }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="progress_percent">
|
||||
{ item.progress_percent }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="price_paid">
|
||||
{ item.price_paid }
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{!courses?.enrollments_course?.length && <div className={'text-center py-4'}>No data</div>}
|
||||
</CardBox>
|
||||
</>
|
||||
|
||||
|
||||
|
||||
|
||||
<BaseDivider />
|
||||
|
||||
<BaseButton
|
||||
color='info'
|
||||
label='Back'
|
||||
onClick={() => router.push('/courses/courses-list')}
|
||||
onClick={() => router.push('/deals/deals-list')}
|
||||
/>
|
||||
</CardBox>
|
||||
</SectionMain>
|
||||
@ -655,11 +562,11 @@ const CoursesView = () => {
|
||||
);
|
||||
};
|
||||
|
||||
CoursesView.getLayout = function getLayout(page: ReactElement) {
|
||||
DealsView.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'READ_COURSES'}
|
||||
permission={'READ_DEALS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -667,4 +574,4 @@ CoursesView.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default CoursesView;
|
||||
export default DealsView;
|
||||
@ -22,11 +22,11 @@ export default function Starter() {
|
||||
photographer_url: undefined,
|
||||
})
|
||||
const [illustrationVideo, setIllustrationVideo] = useState({video_files: []})
|
||||
const [contentType, setContentType] = useState('image');
|
||||
const [contentType, setContentType] = useState('video');
|
||||
const [contentPosition, setContentPosition] = useState('left');
|
||||
const textColor = useAppSelector((state) => state.style.linkColor);
|
||||
|
||||
const title = 'Instructor-Student LMS'
|
||||
const title = 'Sales Pipeline CRM'
|
||||
|
||||
// Fetch Pexels image/video
|
||||
useEffect(() => {
|
||||
@ -128,7 +128,7 @@ export default function Starter() {
|
||||
: null}
|
||||
<div className='flex items-center justify-center flex-col space-y-4 w-full lg:w-full'>
|
||||
<CardBox className='w-full md:w-3/5 lg:w-2/3'>
|
||||
<CardBoxComponentTitle title="Welcome to your Instructor-Student LMS app!"/>
|
||||
<CardBoxComponentTitle title="Welcome to your Sales Pipeline CRM app!"/>
|
||||
|
||||
<div className="space-y-3">
|
||||
<p className='text-center text-gray-500'>This is a React.js/Node.js app generated by the <a className={`${textColor}`} href="https://flatlogic.com/generator">Flatlogic Web App Generator</a></p>
|
||||
|
||||
@ -25,7 +25,7 @@ import { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||
import { SwitchField } from '../../components/SwitchField'
|
||||
import {RichTextField} from "../../components/RichTextField";
|
||||
|
||||
import { update, fetch } from '../../stores/enrollments/enrollmentsSlice'
|
||||
import { update, fetch } from '../../stores/leads/leadsSlice'
|
||||
import { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import {saveFile} from "../../helpers/fileSaver";
|
||||
@ -34,13 +34,97 @@ import ImageField from "../../components/ImageField";
|
||||
|
||||
|
||||
|
||||
const EditEnrollments = () => {
|
||||
const EditLeads = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const initVals = {
|
||||
|
||||
|
||||
'enrollment_label': '',
|
||||
'name': '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'company': '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'email': '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'phone': '',
|
||||
|
||||
|
||||
|
||||
@ -84,63 +168,7 @@ const EditEnrollments = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
student: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
course: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enrolled_at: new Date(),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
source: '',
|
||||
|
||||
|
||||
|
||||
@ -180,7 +208,35 @@ const EditEnrollments = () => {
|
||||
|
||||
|
||||
|
||||
'progress_percent': '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
owner: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'estimated_value': '',
|
||||
|
||||
|
||||
|
||||
@ -208,12 +264,12 @@ const EditEnrollments = () => {
|
||||
|
||||
|
||||
|
||||
'price_paid': '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
notes: '',
|
||||
|
||||
|
||||
|
||||
|
||||
@ -239,44 +295,44 @@ const EditEnrollments = () => {
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
const { enrollments } = useAppSelector((state) => state.enrollments)
|
||||
const { leads } = useAppSelector((state) => state.leads)
|
||||
|
||||
|
||||
const { enrollmentsId } = router.query
|
||||
const { leadsId } = router.query
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetch({ id: enrollmentsId }))
|
||||
}, [enrollmentsId])
|
||||
dispatch(fetch({ id: leadsId }))
|
||||
}, [leadsId])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof enrollments === 'object') {
|
||||
setInitialValues(enrollments)
|
||||
if (typeof leads === 'object') {
|
||||
setInitialValues(leads)
|
||||
}
|
||||
}, [enrollments])
|
||||
}, [leads])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof enrollments === 'object') {
|
||||
if (typeof leads === 'object') {
|
||||
|
||||
const newInitialVal = {...initVals};
|
||||
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (enrollments)[el])
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (leads)[el])
|
||||
|
||||
setInitialValues(newInitialVal);
|
||||
}
|
||||
}, [enrollments])
|
||||
}, [leads])
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(update({ id: enrollmentsId, data }))
|
||||
await router.push('/enrollments/enrollments-list')
|
||||
await dispatch(update({ id: leadsId, data }))
|
||||
await router.push('/leads/leads-list')
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Edit enrollments')}</title>
|
||||
<title>{getPageTitle('Edit leads')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit enrollments'} main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit leads'} main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
@ -290,11 +346,122 @@ const EditEnrollments = () => {
|
||||
|
||||
|
||||
<FormField
|
||||
label="EnrollmentLabel"
|
||||
label="Name"
|
||||
>
|
||||
<Field
|
||||
name="enrollment_label"
|
||||
placeholder="EnrollmentLabel"
|
||||
name="name"
|
||||
placeholder="Name"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Company"
|
||||
>
|
||||
<Field
|
||||
name="company"
|
||||
placeholder="Company"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Email"
|
||||
>
|
||||
<Field
|
||||
name="email"
|
||||
placeholder="Email"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Phone"
|
||||
>
|
||||
<Field
|
||||
name="phone"
|
||||
placeholder="Phone"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
@ -340,136 +507,21 @@ const EditEnrollments = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Student' labelFor='student'>
|
||||
<Field
|
||||
name='student'
|
||||
id='student'
|
||||
component={SelectField}
|
||||
options={initialValues.student}
|
||||
itemRef={'users'}
|
||||
|
||||
|
||||
showField={'firstName'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
<FormField label="Source" labelFor="source">
|
||||
<Field name="source" id="source" component="select">
|
||||
|
||||
<option value="Website">Website</option>
|
||||
|
||||
<option value="Referral">Referral</option>
|
||||
|
||||
<option value="Email">Email</option>
|
||||
|
||||
<option value="ColdCall">ColdCall</option>
|
||||
|
||||
<option value="SocialMedia">SocialMedia</option>
|
||||
|
||||
</Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Course' labelFor='course'>
|
||||
<Field
|
||||
name='course'
|
||||
id='course'
|
||||
component={SelectField}
|
||||
options={initialValues.course}
|
||||
itemRef={'courses'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
showField={'title'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="EnrolledAt"
|
||||
>
|
||||
<DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={initialValues.enrolled_at ?
|
||||
new Date(
|
||||
dayjs(initialValues.enrolled_at).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
onChange={(date) => setInitialValues({...initialValues, 'enrolled_at': date})}
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -502,11 +554,13 @@ const EditEnrollments = () => {
|
||||
<FormField label="Status" labelFor="status">
|
||||
<Field name="status" id="status" component="select">
|
||||
|
||||
<option value="active">active</option>
|
||||
<option value="New">New</option>
|
||||
|
||||
<option value="completed">completed</option>
|
||||
<option value="Contacted">Contacted</option>
|
||||
|
||||
<option value="cancelled">cancelled</option>
|
||||
<option value="Qualified">Qualified</option>
|
||||
|
||||
<option value="Unqualified">Unqualified</option>
|
||||
|
||||
</Field>
|
||||
</FormField>
|
||||
@ -530,14 +584,74 @@ const EditEnrollments = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Owner' labelFor='owner'>
|
||||
<Field
|
||||
name='owner'
|
||||
id='owner'
|
||||
component={SelectField}
|
||||
options={initialValues.owner}
|
||||
itemRef={'users'}
|
||||
|
||||
|
||||
showField={'firstName'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="ProgressPercent"
|
||||
label="EstimatedValue"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="progress_percent"
|
||||
placeholder="ProgressPercent"
|
||||
name="estimated_value"
|
||||
placeholder="EstimatedValue"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
@ -567,16 +681,12 @@ const EditEnrollments = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="PricePaid"
|
||||
>
|
||||
<FormField label='Notes' hasTextareaHeight>
|
||||
<Field
|
||||
type="number"
|
||||
name="price_paid"
|
||||
placeholder="PricePaid"
|
||||
/>
|
||||
name='notes'
|
||||
id='notes'
|
||||
component={RichTextField}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
@ -594,6 +704,8 @@ const EditEnrollments = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -605,7 +717,7 @@ const EditEnrollments = () => {
|
||||
<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('/enrollments/enrollments-list')}/>
|
||||
<BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/leads/leads-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
@ -615,11 +727,11 @@ const EditEnrollments = () => {
|
||||
)
|
||||
}
|
||||
|
||||
EditEnrollments.getLayout = function getLayout(page: ReactElement) {
|
||||
EditLeads.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'UPDATE_ENROLLMENTS'}
|
||||
permission={'UPDATE_LEADS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -627,4 +739,4 @@ EditEnrollments.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default EditEnrollments
|
||||
export default EditLeads
|
||||
@ -25,7 +25,7 @@ import { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||
import { SwitchField } from '../../components/SwitchField'
|
||||
import {RichTextField} from "../../components/RichTextField";
|
||||
|
||||
import { update, fetch } from '../../stores/enrollments/enrollmentsSlice'
|
||||
import { update, fetch } from '../../stores/leads/leadsSlice'
|
||||
import { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import {saveFile} from "../../helpers/fileSaver";
|
||||
@ -34,13 +34,97 @@ import ImageField from "../../components/ImageField";
|
||||
|
||||
|
||||
|
||||
const EditEnrollmentsPage = () => {
|
||||
const EditLeadsPage = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const initVals = {
|
||||
|
||||
|
||||
'enrollment_label': '',
|
||||
'name': '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'company': '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'email': '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'phone': '',
|
||||
|
||||
|
||||
|
||||
@ -84,63 +168,7 @@ const EditEnrollmentsPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
student: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
course: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enrolled_at: new Date(),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
source: '',
|
||||
|
||||
|
||||
|
||||
@ -180,7 +208,35 @@ const EditEnrollmentsPage = () => {
|
||||
|
||||
|
||||
|
||||
'progress_percent': '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
owner: null,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'estimated_value': '',
|
||||
|
||||
|
||||
|
||||
@ -208,12 +264,12 @@ const EditEnrollmentsPage = () => {
|
||||
|
||||
|
||||
|
||||
'price_paid': '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
notes: '',
|
||||
|
||||
|
||||
|
||||
|
||||
@ -239,7 +295,7 @@ const EditEnrollmentsPage = () => {
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
const { enrollments } = useAppSelector((state) => state.enrollments)
|
||||
const { leads } = useAppSelector((state) => state.leads)
|
||||
|
||||
|
||||
const { id } = router.query
|
||||
@ -249,31 +305,31 @@ const EditEnrollmentsPage = () => {
|
||||
}, [id])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof enrollments === 'object') {
|
||||
setInitialValues(enrollments)
|
||||
if (typeof leads === 'object') {
|
||||
setInitialValues(leads)
|
||||
}
|
||||
}, [enrollments])
|
||||
}, [leads])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof enrollments === 'object') {
|
||||
if (typeof leads === 'object') {
|
||||
const newInitialVal = {...initVals};
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (enrollments)[el])
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (leads)[el])
|
||||
setInitialValues(newInitialVal);
|
||||
}
|
||||
}, [enrollments])
|
||||
}, [leads])
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(update({ id: id, data }))
|
||||
await router.push('/enrollments/enrollments-list')
|
||||
await router.push('/leads/leads-list')
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Edit enrollments')}</title>
|
||||
<title>{getPageTitle('Edit leads')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit enrollments'} main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit leads'} main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
@ -287,11 +343,122 @@ const EditEnrollmentsPage = () => {
|
||||
|
||||
|
||||
<FormField
|
||||
label="EnrollmentLabel"
|
||||
label="Name"
|
||||
>
|
||||
<Field
|
||||
name="enrollment_label"
|
||||
placeholder="EnrollmentLabel"
|
||||
name="name"
|
||||
placeholder="Name"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Company"
|
||||
>
|
||||
<Field
|
||||
name="company"
|
||||
placeholder="Company"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Email"
|
||||
>
|
||||
<Field
|
||||
name="email"
|
||||
placeholder="Email"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Phone"
|
||||
>
|
||||
<Field
|
||||
name="phone"
|
||||
placeholder="Phone"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
@ -337,136 +504,21 @@ const EditEnrollmentsPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Student' labelFor='student'>
|
||||
<Field
|
||||
name='student'
|
||||
id='student'
|
||||
component={SelectField}
|
||||
options={initialValues.student}
|
||||
itemRef={'users'}
|
||||
|
||||
|
||||
showField={'firstName'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
<FormField label="Source" labelFor="source">
|
||||
<Field name="source" id="source" component="select">
|
||||
|
||||
<option value="Website">Website</option>
|
||||
|
||||
<option value="Referral">Referral</option>
|
||||
|
||||
<option value="Email">Email</option>
|
||||
|
||||
<option value="ColdCall">ColdCall</option>
|
||||
|
||||
<option value="SocialMedia">SocialMedia</option>
|
||||
|
||||
</Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Course' labelFor='course'>
|
||||
<Field
|
||||
name='course'
|
||||
id='course'
|
||||
component={SelectField}
|
||||
options={initialValues.course}
|
||||
itemRef={'courses'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
showField={'title'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="EnrolledAt"
|
||||
>
|
||||
<DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={initialValues.enrolled_at ?
|
||||
new Date(
|
||||
dayjs(initialValues.enrolled_at).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
onChange={(date) => setInitialValues({...initialValues, 'enrolled_at': date})}
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -499,11 +551,13 @@ const EditEnrollmentsPage = () => {
|
||||
<FormField label="Status" labelFor="status">
|
||||
<Field name="status" id="status" component="select">
|
||||
|
||||
<option value="active">active</option>
|
||||
<option value="New">New</option>
|
||||
|
||||
<option value="completed">completed</option>
|
||||
<option value="Contacted">Contacted</option>
|
||||
|
||||
<option value="cancelled">cancelled</option>
|
||||
<option value="Qualified">Qualified</option>
|
||||
|
||||
<option value="Unqualified">Unqualified</option>
|
||||
|
||||
</Field>
|
||||
</FormField>
|
||||
@ -527,14 +581,74 @@ const EditEnrollmentsPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='Owner' labelFor='owner'>
|
||||
<Field
|
||||
name='owner'
|
||||
id='owner'
|
||||
component={SelectField}
|
||||
options={initialValues.owner}
|
||||
itemRef={'users'}
|
||||
|
||||
|
||||
showField={'firstName'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="ProgressPercent"
|
||||
label="EstimatedValue"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="progress_percent"
|
||||
placeholder="ProgressPercent"
|
||||
name="estimated_value"
|
||||
placeholder="EstimatedValue"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
@ -564,16 +678,12 @@ const EditEnrollmentsPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="PricePaid"
|
||||
>
|
||||
<FormField label='Notes' hasTextareaHeight>
|
||||
<Field
|
||||
type="number"
|
||||
name="price_paid"
|
||||
placeholder="PricePaid"
|
||||
/>
|
||||
name='notes'
|
||||
id='notes'
|
||||
component={RichTextField}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
@ -591,6 +701,8 @@ const EditEnrollmentsPage = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -602,7 +714,7 @@ const EditEnrollmentsPage = () => {
|
||||
<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('/enrollments/enrollments-list')}/>
|
||||
<BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/leads/leads-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
@ -612,11 +724,11 @@ const EditEnrollmentsPage = () => {
|
||||
)
|
||||
}
|
||||
|
||||
EditEnrollmentsPage.getLayout = function getLayout(page: ReactElement) {
|
||||
EditLeadsPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'UPDATE_ENROLLMENTS'}
|
||||
permission={'UPDATE_LEADS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -624,4 +736,4 @@ EditEnrollmentsPage.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default EditEnrollmentsPage
|
||||
export default EditLeadsPage
|
||||
@ -7,21 +7,21 @@ import LayoutAuthenticated from '../../layouts/Authenticated'
|
||||
import SectionMain from '../../components/SectionMain'
|
||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||
import { getPageTitle } from '../../config'
|
||||
import TableEnrollments from '../../components/Enrollments/TableEnrollments'
|
||||
import TableLeads from '../../components/Leads/TableLeads'
|
||||
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/enrollments/enrollmentsSlice';
|
||||
import {setRefetch, uploadCsv} from '../../stores/leads/leadsSlice';
|
||||
|
||||
|
||||
import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
|
||||
const EnrollmentsTablesPage = () => {
|
||||
const LeadsTablesPage = () => {
|
||||
const [filterItems, setFilterItems] = useState([]);
|
||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||
const [isModalActive, setIsModalActive] = useState(false);
|
||||
@ -34,24 +34,20 @@ const EnrollmentsTablesPage = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
|
||||
const [filters] = useState([{label: 'EnrollmentLabel', title: 'enrollment_label'},
|
||||
const [filters] = useState([{label: 'Name', title: 'name'},{label: 'Company', title: 'company'},{label: 'Email', title: 'email'},{label: 'Phone', title: 'phone'},{label: 'Notes', title: 'notes'},
|
||||
|
||||
{label: 'EstimatedValue', title: 'estimated_value', number: 'true'},
|
||||
|
||||
{label: 'ProgressPercent', title: 'progress_percent', number: 'true'},{label: 'PricePaid', title: 'price_paid', number: 'true'},
|
||||
{label: 'EnrolledAt', title: 'enrolled_at', date: 'true'},
|
||||
|
||||
|
||||
{label: 'Student', title: 'student'},
|
||||
|
||||
|
||||
|
||||
{label: 'Course', title: 'course'},
|
||||
{label: 'Owner', title: 'owner'},
|
||||
|
||||
|
||||
|
||||
{label: 'Status', title: 'status', type: 'enum', options: ['active','completed','cancelled']},
|
||||
{label: 'Source', title: 'source', type: 'enum', options: ['Website','Referral','Email','ColdCall','SocialMedia']},{label: 'Status', title: 'status', type: 'enum', options: ['New','Contacted','Qualified','Unqualified']},
|
||||
]);
|
||||
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_ENROLLMENTS');
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_LEADS');
|
||||
|
||||
|
||||
const addFilter = () => {
|
||||
@ -68,13 +64,13 @@ const EnrollmentsTablesPage = () => {
|
||||
setFilterItems([...filterItems, newItem]);
|
||||
};
|
||||
|
||||
const getEnrollmentsCSV = async () => {
|
||||
const response = await axios({url: '/enrollments?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||
const getLeadsCSV = async () => {
|
||||
const response = await axios({url: '/leads?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 = 'enrollmentsCSV.csv'
|
||||
link.download = 'leadsCSV.csv'
|
||||
link.click()
|
||||
};
|
||||
|
||||
@ -94,15 +90,15 @@ const EnrollmentsTablesPage = () => {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Enrollments')}</title>
|
||||
<title>{getPageTitle('Leads')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Enrollments" main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Leads" main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
||||
|
||||
{hasCreatePermission && <BaseButton className={'mr-3'} href={'/enrollments/enrollments-new'} color='info' label='New Item'/>}
|
||||
{hasCreatePermission && <BaseButton className={'mr-3'} href={'/leads/leads-new'} color='info' label='New Item'/>}
|
||||
|
||||
<BaseButton
|
||||
className={'mr-3'}
|
||||
@ -110,7 +106,7 @@ const EnrollmentsTablesPage = () => {
|
||||
label='Filter'
|
||||
onClick={addFilter}
|
||||
/>
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getEnrollmentsCSV} />
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getLeadsCSV} />
|
||||
|
||||
{hasCreatePermission && (
|
||||
<BaseButton
|
||||
@ -127,7 +123,7 @@ const EnrollmentsTablesPage = () => {
|
||||
</CardBox>
|
||||
|
||||
<CardBox className="mb-6" hasTable>
|
||||
<TableEnrollments
|
||||
<TableLeads
|
||||
filterItems={filterItems}
|
||||
setFilterItems={setFilterItems}
|
||||
filters={filters}
|
||||
@ -155,11 +151,11 @@ const EnrollmentsTablesPage = () => {
|
||||
)
|
||||
}
|
||||
|
||||
EnrollmentsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
LeadsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'READ_ENROLLMENTS'}
|
||||
permission={'READ_LEADS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -167,4 +163,4 @@ EnrollmentsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default EnrollmentsTablesPage
|
||||
export default LeadsTablesPage
|
||||
@ -22,7 +22,7 @@ import { SelectField } from '../../components/SelectField'
|
||||
import { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||
import {RichTextField} from "../../components/RichTextField";
|
||||
|
||||
import { create } from '../../stores/enrollments/enrollmentsSlice'
|
||||
import { create } from '../../stores/leads/leadsSlice'
|
||||
import { useAppDispatch } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import moment from 'moment';
|
||||
@ -30,7 +30,7 @@ import moment from 'moment';
|
||||
const initialValues = {
|
||||
|
||||
|
||||
enrollment_label: '',
|
||||
name: '',
|
||||
|
||||
|
||||
|
||||
@ -46,6 +46,7 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
company: '',
|
||||
|
||||
|
||||
|
||||
@ -57,11 +58,11 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
student: '',
|
||||
|
||||
|
||||
|
||||
|
||||
email: '',
|
||||
|
||||
|
||||
|
||||
@ -73,17 +74,16 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
course: '',
|
||||
|
||||
|
||||
|
||||
|
||||
phone: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enrolled_at: '',
|
||||
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
status: 'active',
|
||||
source: 'Website',
|
||||
|
||||
|
||||
|
||||
@ -111,7 +111,6 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
progress_percent: '',
|
||||
|
||||
|
||||
|
||||
@ -121,13 +120,13 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
status: 'New',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
price_paid: '',
|
||||
|
||||
|
||||
|
||||
@ -140,12 +139,46 @@ const initialValues = {
|
||||
|
||||
|
||||
|
||||
owner: '',
|
||||
|
||||
|
||||
|
||||
|
||||
estimated_value: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
notes: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
const EnrollmentsNew = () => {
|
||||
const LeadsNew = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
|
||||
@ -154,7 +187,7 @@ const EnrollmentsNew = () => {
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(create(data))
|
||||
await router.push('/enrollments/enrollments-list')
|
||||
await router.push('/leads/leads-list')
|
||||
}
|
||||
return (
|
||||
<>
|
||||
@ -179,11 +212,11 @@ const EnrollmentsNew = () => {
|
||||
|
||||
|
||||
<FormField
|
||||
label="EnrollmentLabel"
|
||||
label="Name"
|
||||
>
|
||||
<Field
|
||||
name="enrollment_label"
|
||||
placeholder="EnrollmentLabel"
|
||||
name="name"
|
||||
placeholder="Name"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
@ -210,86 +243,15 @@ const EnrollmentsNew = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Student" labelFor="student">
|
||||
<Field name="student" id="student" component={SelectField} options={[]} itemRef={'users'}></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Course" labelFor="course">
|
||||
<Field name="course" id="course" component={SelectField} options={[]} itemRef={'courses'}></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="EnrolledAt"
|
||||
label="Company"
|
||||
>
|
||||
<Field
|
||||
type="datetime-local"
|
||||
name="enrolled_at"
|
||||
placeholder="EnrolledAt"
|
||||
name="company"
|
||||
placeholder="Company"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
@ -312,6 +274,128 @@ const EnrollmentsNew = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Email"
|
||||
>
|
||||
<Field
|
||||
name="email"
|
||||
placeholder="Email"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Phone"
|
||||
>
|
||||
<Field
|
||||
name="phone"
|
||||
placeholder="Phone"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Source" labelFor="source">
|
||||
<Field name="source" id="source" component="select">
|
||||
|
||||
<option value="Website">Website</option>
|
||||
|
||||
<option value="Referral">Referral</option>
|
||||
|
||||
<option value="Email">Email</option>
|
||||
|
||||
<option value="ColdCall">ColdCall</option>
|
||||
|
||||
<option value="SocialMedia">SocialMedia</option>
|
||||
|
||||
</Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -326,11 +410,13 @@ const EnrollmentsNew = () => {
|
||||
<FormField label="Status" labelFor="status">
|
||||
<Field name="status" id="status" component="select">
|
||||
|
||||
<option value="active">active</option>
|
||||
<option value="New">New</option>
|
||||
|
||||
<option value="completed">completed</option>
|
||||
<option value="Contacted">Contacted</option>
|
||||
|
||||
<option value="cancelled">cancelled</option>
|
||||
<option value="Qualified">Qualified</option>
|
||||
|
||||
<option value="Unqualified">Unqualified</option>
|
||||
|
||||
</Field>
|
||||
</FormField>
|
||||
@ -353,13 +439,43 @@ const EnrollmentsNew = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label="Owner" labelFor="owner">
|
||||
<Field name="owner" id="owner" component={SelectField} options={[]} itemRef={'users'}></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="ProgressPercent"
|
||||
label="EstimatedValue"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="progress_percent"
|
||||
placeholder="ProgressPercent"
|
||||
name="estimated_value"
|
||||
placeholder="EstimatedValue"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
@ -387,17 +503,15 @@ const EnrollmentsNew = () => {
|
||||
|
||||
|
||||
|
||||
<FormField label='Notes' hasTextareaHeight>
|
||||
<Field
|
||||
name='notes'
|
||||
id='notes'
|
||||
component={RichTextField}
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
|
||||
<FormField
|
||||
label="PricePaid"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="price_paid"
|
||||
placeholder="PricePaid"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
@ -421,7 +535,7 @@ const EnrollmentsNew = () => {
|
||||
<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('/enrollments/enrollments-list')}/>
|
||||
<BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/leads/leads-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
@ -431,11 +545,11 @@ const EnrollmentsNew = () => {
|
||||
)
|
||||
}
|
||||
|
||||
EnrollmentsNew.getLayout = function getLayout(page: ReactElement) {
|
||||
LeadsNew.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'CREATE_ENROLLMENTS'}
|
||||
permission={'CREATE_LEADS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -443,4 +557,4 @@ EnrollmentsNew.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default EnrollmentsNew
|
||||
export default LeadsNew
|
||||
@ -7,21 +7,21 @@ import LayoutAuthenticated from '../../layouts/Authenticated'
|
||||
import SectionMain from '../../components/SectionMain'
|
||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||
import { getPageTitle } from '../../config'
|
||||
import TableEnrollments from '../../components/Enrollments/TableEnrollments'
|
||||
import TableLeads from '../../components/Leads/TableLeads'
|
||||
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/enrollments/enrollmentsSlice';
|
||||
import {setRefetch, uploadCsv} from '../../stores/leads/leadsSlice';
|
||||
|
||||
|
||||
import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
|
||||
const EnrollmentsTablesPage = () => {
|
||||
const LeadsTablesPage = () => {
|
||||
const [filterItems, setFilterItems] = useState([]);
|
||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||
const [isModalActive, setIsModalActive] = useState(false);
|
||||
@ -34,24 +34,20 @@ const EnrollmentsTablesPage = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
|
||||
const [filters] = useState([{label: 'EnrollmentLabel', title: 'enrollment_label'},
|
||||
const [filters] = useState([{label: 'Name', title: 'name'},{label: 'Company', title: 'company'},{label: 'Email', title: 'email'},{label: 'Phone', title: 'phone'},{label: 'Notes', title: 'notes'},
|
||||
|
||||
{label: 'EstimatedValue', title: 'estimated_value', number: 'true'},
|
||||
|
||||
{label: 'ProgressPercent', title: 'progress_percent', number: 'true'},{label: 'PricePaid', title: 'price_paid', number: 'true'},
|
||||
{label: 'EnrolledAt', title: 'enrolled_at', date: 'true'},
|
||||
|
||||
|
||||
{label: 'Student', title: 'student'},
|
||||
|
||||
|
||||
|
||||
{label: 'Course', title: 'course'},
|
||||
{label: 'Owner', title: 'owner'},
|
||||
|
||||
|
||||
|
||||
{label: 'Status', title: 'status', type: 'enum', options: ['active','completed','cancelled']},
|
||||
{label: 'Source', title: 'source', type: 'enum', options: ['Website','Referral','Email','ColdCall','SocialMedia']},{label: 'Status', title: 'status', type: 'enum', options: ['New','Contacted','Qualified','Unqualified']},
|
||||
]);
|
||||
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_ENROLLMENTS');
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_LEADS');
|
||||
|
||||
|
||||
const addFilter = () => {
|
||||
@ -68,13 +64,13 @@ const EnrollmentsTablesPage = () => {
|
||||
setFilterItems([...filterItems, newItem]);
|
||||
};
|
||||
|
||||
const getEnrollmentsCSV = async () => {
|
||||
const response = await axios({url: '/enrollments?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||
const getLeadsCSV = async () => {
|
||||
const response = await axios({url: '/leads?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 = 'enrollmentsCSV.csv'
|
||||
link.download = 'leadsCSV.csv'
|
||||
link.click()
|
||||
};
|
||||
|
||||
@ -94,15 +90,15 @@ const EnrollmentsTablesPage = () => {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Enrollments')}</title>
|
||||
<title>{getPageTitle('Leads')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Enrollments" main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Leads" main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
||||
|
||||
{hasCreatePermission && <BaseButton className={'mr-3'} href={'/enrollments/enrollments-new'} color='info' label='New Item'/>}
|
||||
{hasCreatePermission && <BaseButton className={'mr-3'} href={'/leads/leads-new'} color='info' label='New Item'/>}
|
||||
|
||||
<BaseButton
|
||||
className={'mr-3'}
|
||||
@ -110,7 +106,7 @@ const EnrollmentsTablesPage = () => {
|
||||
label='Filter'
|
||||
onClick={addFilter}
|
||||
/>
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getEnrollmentsCSV} />
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getLeadsCSV} />
|
||||
|
||||
{hasCreatePermission && (
|
||||
<BaseButton
|
||||
@ -123,14 +119,14 @@ const EnrollmentsTablesPage = () => {
|
||||
<div className='md:inline-flex items-center ms-auto'>
|
||||
<div id='delete-rows-button'></div>
|
||||
|
||||
<Link href={'/enrollments/enrollments-list'}>
|
||||
<Link href={'/leads/leads-list'}>
|
||||
Back to <span className='capitalize'>table</span>
|
||||
</Link>
|
||||
|
||||
</div>
|
||||
</CardBox>
|
||||
<CardBox className="mb-6" hasTable>
|
||||
<TableEnrollments
|
||||
<TableLeads
|
||||
filterItems={filterItems}
|
||||
setFilterItems={setFilterItems}
|
||||
filters={filters}
|
||||
@ -157,11 +153,11 @@ const EnrollmentsTablesPage = () => {
|
||||
)
|
||||
}
|
||||
|
||||
EnrollmentsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
LeadsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'READ_ENROLLMENTS'}
|
||||
permission={'READ_LEADS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -169,4 +165,4 @@ EnrollmentsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default EnrollmentsTablesPage
|
||||
export default LeadsTablesPage
|
||||
@ -5,7 +5,7 @@ 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/lessons/lessonsSlice'
|
||||
import { fetch } from '../../stores/leads/leadsSlice'
|
||||
import {saveFile} from "../../helpers/fileSaver";
|
||||
import dataFormatter from '../../helpers/dataFormatter';
|
||||
import ImageField from "../../components/ImageField";
|
||||
@ -21,10 +21,10 @@ import {SwitchField} from "../../components/SwitchField";
|
||||
import FormField from "../../components/FormField";
|
||||
|
||||
|
||||
const LessonsView = () => {
|
||||
const LeadsView = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const { lessons } = useAppSelector((state) => state.lessons)
|
||||
const { leads } = useAppSelector((state) => state.leads)
|
||||
|
||||
|
||||
const { id } = router.query;
|
||||
@ -42,14 +42,14 @@ const LessonsView = () => {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('View lessons')}</title>
|
||||
<title>{getPageTitle('View leads')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View lessons')} main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View leads')} main>
|
||||
<BaseButton
|
||||
color='info'
|
||||
label='Edit'
|
||||
href={`/lessons/lessons-edit/?id=${id}`}
|
||||
href={`/leads/leads-edit/?id=${id}`}
|
||||
/>
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
@ -57,8 +57,8 @@ const LessonsView = () => {
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Title</p>
|
||||
<p>{lessons?.title}</p>
|
||||
<p className={'block font-bold mb-2'}>Name</p>
|
||||
<p>{leads?.name}</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -85,19 +85,12 @@ const LessonsView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Content</p>
|
||||
{lessons.content
|
||||
? <p dangerouslySetInnerHTML={{__html: lessons.content}}/>
|
||||
: <p>No data</p>
|
||||
}
|
||||
<p className={'block font-bold mb-2'}>Company</p>
|
||||
<p>{leads?.company}</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -120,68 +113,16 @@ const LessonsView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Course</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p>{lessons?.course?.title ?? 'No data'}</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Order</p>
|
||||
<p>{lessons?.order || 'No data'}</p>
|
||||
<p className={'block font-bold mb-2'}>Email</p>
|
||||
<p>{leads?.email}</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -202,18 +143,18 @@ const LessonsView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Duration(minutes)</p>
|
||||
<p>{lessons?.duration_minutes || 'No data'}</p>
|
||||
<p className={'block font-bold mb-2'}>Phone</p>
|
||||
<p>{leads?.phone}</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -234,16 +175,12 @@ const LessonsView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -262,90 +199,10 @@ const LessonsView = () => {
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>VideoFiles</p>
|
||||
{lessons?.video_files?.length
|
||||
? dataFormatter.filesFormatter(lessons.video_files).map(link => (
|
||||
<button
|
||||
key={link.publicUrl}
|
||||
onClick={(e) => saveFile(e, link.publicUrl, link.name)}
|
||||
>
|
||||
{link.name}
|
||||
</button>
|
||||
)) : <p>No VideoFiles</p>
|
||||
}
|
||||
<p className={'block font-bold mb-2'}>Source</p>
|
||||
<p>{leads?.source ?? 'No data'}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Resources</p>
|
||||
{lessons?.resources?.length
|
||||
? dataFormatter.filesFormatter(lessons.resources).map(link => (
|
||||
<button
|
||||
key={link.publicUrl}
|
||||
onClick={(e) => saveFile(e, link.publicUrl, link.name)}
|
||||
>
|
||||
{link.name}
|
||||
</button>
|
||||
)) : <p>No Resources</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='ReleaseDate'>
|
||||
{lessons.release_date ? <DatePicker
|
||||
dateFormat="yyyy-MM-dd hh:mm"
|
||||
showTimeSelect
|
||||
selected={lessons.release_date ?
|
||||
new Date(
|
||||
dayjs(lessons.release_date).format('YYYY-MM-DD hh:mm'),
|
||||
) : null
|
||||
}
|
||||
disabled
|
||||
/> : <p>No ReleaseDate</p>}
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -375,7 +232,7 @@ const LessonsView = () => {
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Status</p>
|
||||
<p>{lessons?.status ?? 'No data'}</p>
|
||||
<p>{leads?.status ?? 'No data'}</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -390,6 +247,126 @@ const LessonsView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Owner</p>
|
||||
|
||||
|
||||
<p>{leads?.owner?.firstName ?? 'No data'}</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>EstimatedValue</p>
|
||||
<p>{leads?.estimated_value || 'No data'}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Notes</p>
|
||||
{leads.notes
|
||||
? <p dangerouslySetInnerHTML={{__html: leads.notes}}/>
|
||||
: <p>No data</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -398,7 +375,7 @@ const LessonsView = () => {
|
||||
|
||||
|
||||
<>
|
||||
<p className={'block font-bold mb-2'}>Progress Lesson</p>
|
||||
<p className={'block font-bold mb-2'}>Activities RelatedLead</p>
|
||||
<CardBox
|
||||
className='mb-6 border border-gray-300 rounded overflow-hidden'
|
||||
hasTable
|
||||
@ -409,46 +386,64 @@ const LessonsView = () => {
|
||||
<tr>
|
||||
|
||||
|
||||
<th>Note</th>
|
||||
<th>Subject</th>
|
||||
|
||||
|
||||
|
||||
<th>ActivityType</th>
|
||||
|
||||
|
||||
|
||||
<th>Start</th>
|
||||
|
||||
|
||||
|
||||
<th>End</th>
|
||||
|
||||
|
||||
|
||||
<th>Completed</th>
|
||||
|
||||
|
||||
|
||||
<th>CompletedAt</th>
|
||||
|
||||
|
||||
|
||||
<th>Score</th>
|
||||
|
||||
|
||||
|
||||
<th>Attempts</th>
|
||||
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{lessons.progress_lesson && Array.isArray(lessons.progress_lesson) &&
|
||||
lessons.progress_lesson.map((item: any) => (
|
||||
<tr key={item.id} onClick={() => router.push(`/progress/progress-view/?id=${item.id}`)}>
|
||||
{leads.activities_related_lead && Array.isArray(leads.activities_related_lead) &&
|
||||
leads.activities_related_lead.map((item: any) => (
|
||||
<tr key={item.id} onClick={() => router.push(`/activities/activities-view/?id=${item.id}`)}>
|
||||
|
||||
|
||||
<td data-label="note">
|
||||
{ item.note }
|
||||
<td data-label="subject">
|
||||
{ item.subject }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="activity_type">
|
||||
{ item.activity_type }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="start">
|
||||
{ dataFormatter.dateTimeFormatter(item.start) }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="end">
|
||||
{ dataFormatter.dateTimeFormatter(item.end) }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="completed">
|
||||
{ dataFormatter.booleanFormatter(item.completed) }
|
||||
@ -456,29 +451,19 @@ const LessonsView = () => {
|
||||
|
||||
|
||||
|
||||
<td data-label="completed_at">
|
||||
{ dataFormatter.dateTimeFormatter(item.completed_at) }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="score">
|
||||
{ item.score }
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td data-label="attempts">
|
||||
{ item.attempts }
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{!lessons?.progress_lesson?.length && <div className={'text-center py-4'}>No data</div>}
|
||||
{!leads?.activities_related_lead?.length && <div className={'text-center py-4'}>No data</div>}
|
||||
</CardBox>
|
||||
</>
|
||||
|
||||
@ -489,7 +474,7 @@ const LessonsView = () => {
|
||||
<BaseButton
|
||||
color='info'
|
||||
label='Back'
|
||||
onClick={() => router.push('/lessons/lessons-list')}
|
||||
onClick={() => router.push('/leads/leads-list')}
|
||||
/>
|
||||
</CardBox>
|
||||
</SectionMain>
|
||||
@ -497,11 +482,11 @@ const LessonsView = () => {
|
||||
);
|
||||
};
|
||||
|
||||
LessonsView.getLayout = function getLayout(page: ReactElement) {
|
||||
LeadsView.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'READ_LESSONS'}
|
||||
permission={'READ_LEADS'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -509,4 +494,4 @@ LessonsView.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default LessonsView;
|
||||
export default LeadsView;
|
||||
@ -34,17 +34,17 @@ export default function Login() {
|
||||
photographer_url: undefined,
|
||||
})
|
||||
const [ illustrationVideo, setIllustrationVideo ] = useState({video_files: []})
|
||||
const [contentType, setContentType] = useState('image');
|
||||
const [contentType, setContentType] = useState('video');
|
||||
const [contentPosition, setContentPosition] = useState('left');
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
const { currentUser, isFetching, errorMessage, token, notify:notifyState } = useAppSelector(
|
||||
(state) => state.auth,
|
||||
);
|
||||
const [initialValues, setInitialValues] = React.useState({ email:'admin@flatlogic.com',
|
||||
password: 'e52941c5',
|
||||
password: '72a5084e',
|
||||
remember: true })
|
||||
|
||||
const title = 'Instructor-Student LMS'
|
||||
const title = 'Sales Pipeline CRM'
|
||||
|
||||
// Fetch Pexels image/video
|
||||
useEffect( () => {
|
||||
@ -172,15 +172,15 @@ export default function Login() {
|
||||
|
||||
<p className='mb-2'>Use{' '}
|
||||
<code className={`cursor-pointer ${textColor} `}
|
||||
data-password="e52941c5"
|
||||
data-password="72a5084e"
|
||||
onClick={(e) => setLogin(e.target)}>admin@flatlogic.com</code>{' / '}
|
||||
<code className={`${textColor}`}>e52941c5</code>{' / '}
|
||||
<code className={`${textColor}`}>72a5084e</code>{' / '}
|
||||
to login as Admin</p>
|
||||
<p>Use <code
|
||||
className={`cursor-pointer ${textColor} `}
|
||||
data-password="20ceb5eda155"
|
||||
data-password="c6ada26bc4fa"
|
||||
onClick={(e) => setLogin(e.target)}>client@hello.com</code>{' / '}
|
||||
<code className={`${textColor}`}>20ceb5eda155</code>{' / '}
|
||||
<code className={`${textColor}`}>c6ada26bc4fa</code>{' / '}
|
||||
to login as User</p>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@ -93,6 +93,7 @@ const PermissionsView = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
383
frontend/src/pages/pipeline_stages/[pipeline_stagesId].tsx
Normal file
383
frontend/src/pages/pipeline_stages/[pipeline_stagesId].tsx
Normal file
@ -0,0 +1,383 @@
|
||||
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/pipeline_stages/pipeline_stagesSlice'
|
||||
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";
|
||||
|
||||
|
||||
|
||||
const EditPipeline_stages = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const initVals = {
|
||||
|
||||
|
||||
'title': '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
order: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
probability: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
is_default: false,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
const { pipeline_stages } = useAppSelector((state) => state.pipeline_stages)
|
||||
|
||||
|
||||
const { pipeline_stagesId } = router.query
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetch({ id: pipeline_stagesId }))
|
||||
}, [pipeline_stagesId])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof pipeline_stages === 'object') {
|
||||
setInitialValues(pipeline_stages)
|
||||
}
|
||||
}, [pipeline_stages])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof pipeline_stages === 'object') {
|
||||
|
||||
const newInitialVal = {...initVals};
|
||||
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (pipeline_stages)[el])
|
||||
|
||||
setInitialValues(newInitialVal);
|
||||
}
|
||||
}, [pipeline_stages])
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(update({ id: pipeline_stagesId, data }))
|
||||
await router.push('/pipeline_stages/pipeline_stages-list')
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Edit pipeline_stages')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit pipeline_stages'} main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
<Formik
|
||||
enableReinitialize
|
||||
initialValues={initialValues}
|
||||
onSubmit={(values) => handleSubmit(values)}
|
||||
>
|
||||
<Form>
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Title"
|
||||
>
|
||||
<Field
|
||||
name="title"
|
||||
placeholder="Title"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Order"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="order"
|
||||
placeholder="Order"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Probability"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="probability"
|
||||
placeholder="Probability"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='IsDefault' labelFor='is_default'>
|
||||
<Field
|
||||
name='is_default'
|
||||
id='is_default'
|
||||
component={SwitchField}
|
||||
></Field>
|
||||
</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('/pipeline_stages/pipeline_stages-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
</CardBox>
|
||||
</SectionMain>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
EditPipeline_stages.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'UPDATE_PIPELINE_STAGES'}
|
||||
|
||||
>
|
||||
{page}
|
||||
</LayoutAuthenticated>
|
||||
)
|
||||
}
|
||||
|
||||
export default EditPipeline_stages
|
||||
380
frontend/src/pages/pipeline_stages/pipeline_stages-edit.tsx
Normal file
380
frontend/src/pages/pipeline_stages/pipeline_stages-edit.tsx
Normal file
@ -0,0 +1,380 @@
|
||||
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/pipeline_stages/pipeline_stagesSlice'
|
||||
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";
|
||||
|
||||
|
||||
|
||||
const EditPipeline_stagesPage = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const initVals = {
|
||||
|
||||
|
||||
'title': '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
order: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
probability: '',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
is_default: false,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
const { pipeline_stages } = useAppSelector((state) => state.pipeline_stages)
|
||||
|
||||
|
||||
const { id } = router.query
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetch({ id: id }))
|
||||
}, [id])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof pipeline_stages === 'object') {
|
||||
setInitialValues(pipeline_stages)
|
||||
}
|
||||
}, [pipeline_stages])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof pipeline_stages === 'object') {
|
||||
const newInitialVal = {...initVals};
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (pipeline_stages)[el])
|
||||
setInitialValues(newInitialVal);
|
||||
}
|
||||
}, [pipeline_stages])
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(update({ id: id, data }))
|
||||
await router.push('/pipeline_stages/pipeline_stages-list')
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Edit pipeline_stages')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit pipeline_stages'} main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
<Formik
|
||||
enableReinitialize
|
||||
initialValues={initialValues}
|
||||
onSubmit={(values) => handleSubmit(values)}
|
||||
>
|
||||
<Form>
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Title"
|
||||
>
|
||||
<Field
|
||||
name="title"
|
||||
placeholder="Title"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Order"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="order"
|
||||
placeholder="Order"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField
|
||||
label="Probability"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="probability"
|
||||
placeholder="Probability"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<FormField label='IsDefault' labelFor='is_default'>
|
||||
<Field
|
||||
name='is_default'
|
||||
id='is_default'
|
||||
component={SwitchField}
|
||||
></Field>
|
||||
</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('/pipeline_stages/pipeline_stages-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
</CardBox>
|
||||
</SectionMain>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
EditPipeline_stagesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'UPDATE_PIPELINE_STAGES'}
|
||||
|
||||
>
|
||||
{page}
|
||||
</LayoutAuthenticated>
|
||||
)
|
||||
}
|
||||
|
||||
export default EditPipeline_stagesPage
|
||||
@ -7,21 +7,21 @@ import LayoutAuthenticated from '../../layouts/Authenticated'
|
||||
import SectionMain from '../../components/SectionMain'
|
||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||
import { getPageTitle } from '../../config'
|
||||
import TableLessons from '../../components/Lessons/TableLessons'
|
||||
import TablePipeline_stages from '../../components/Pipeline_stages/TablePipeline_stages'
|
||||
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/lessons/lessonsSlice';
|
||||
import {setRefetch, uploadCsv} from '../../stores/pipeline_stages/pipeline_stagesSlice';
|
||||
|
||||
|
||||
import {hasPermission} from "../../helpers/userPermissions";
|
||||
|
||||
|
||||
|
||||
const LessonsTablesPage = () => {
|
||||
const Pipeline_stagesTablesPage = () => {
|
||||
const [filterItems, setFilterItems] = useState([]);
|
||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||
const [isModalActive, setIsModalActive] = useState(false);
|
||||
@ -34,20 +34,16 @@ const LessonsTablesPage = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
|
||||
const [filters] = useState([{label: 'Title', title: 'title'},{label: 'Content', title: 'content'},
|
||||
{label: 'Order', title: 'order', number: 'true'},{label: 'Duration(minutes)', title: 'duration_minutes', number: 'true'},
|
||||
const [filters] = useState([{label: 'Title', title: 'title'},
|
||||
{label: 'Order', title: 'order', number: 'true'},{label: 'Probability', title: 'probability', number: 'true'},
|
||||
|
||||
|
||||
{label: 'ReleaseDate', title: 'release_date', date: 'true'},
|
||||
|
||||
|
||||
{label: 'Course', title: 'course'},
|
||||
|
||||
|
||||
|
||||
{label: 'Status', title: 'status', type: 'enum', options: ['draft','published','archived']},
|
||||
|
||||
]);
|
||||
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_LESSONS');
|
||||
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_PIPELINE_STAGES');
|
||||
|
||||
|
||||
const addFilter = () => {
|
||||
@ -64,13 +60,13 @@ const LessonsTablesPage = () => {
|
||||
setFilterItems([...filterItems, newItem]);
|
||||
};
|
||||
|
||||
const getLessonsCSV = async () => {
|
||||
const response = await axios({url: '/lessons?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||
const getPipeline_stagesCSV = async () => {
|
||||
const response = await axios({url: '/pipeline_stages?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 = 'lessonsCSV.csv'
|
||||
link.download = 'pipeline_stagesCSV.csv'
|
||||
link.click()
|
||||
};
|
||||
|
||||
@ -90,15 +86,15 @@ const LessonsTablesPage = () => {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Lessons')}</title>
|
||||
<title>{getPageTitle('Pipeline_stages')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Lessons" main>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Pipeline_stages" main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
||||
|
||||
{hasCreatePermission && <BaseButton className={'mr-3'} href={'/lessons/lessons-new'} color='info' label='New Item'/>}
|
||||
{hasCreatePermission && <BaseButton className={'mr-3'} href={'/pipeline_stages/pipeline_stages-new'} color='info' label='New Item'/>}
|
||||
|
||||
<BaseButton
|
||||
className={'mr-3'}
|
||||
@ -106,7 +102,7 @@ const LessonsTablesPage = () => {
|
||||
label='Filter'
|
||||
onClick={addFilter}
|
||||
/>
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getLessonsCSV} />
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getPipeline_stagesCSV} />
|
||||
|
||||
{hasCreatePermission && (
|
||||
<BaseButton
|
||||
@ -120,18 +116,16 @@ const LessonsTablesPage = () => {
|
||||
<div id='delete-rows-button'></div>
|
||||
</div>
|
||||
|
||||
<div className='md:inline-flex items-center ms-auto'>
|
||||
<Link href={'/lessons/lessons-table'}>Switch to Table</Link>
|
||||
</div>
|
||||
|
||||
</CardBox>
|
||||
|
||||
<TableLessons
|
||||
<CardBox className="mb-6" hasTable>
|
||||
<TablePipeline_stages
|
||||
filterItems={filterItems}
|
||||
setFilterItems={setFilterItems}
|
||||
filters={filters}
|
||||
showGrid={false}
|
||||
/>
|
||||
/>
|
||||
</CardBox>
|
||||
|
||||
</SectionMain>
|
||||
<CardBoxModal
|
||||
@ -153,11 +147,11 @@ const LessonsTablesPage = () => {
|
||||
)
|
||||
}
|
||||
|
||||
LessonsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
Pipeline_stagesTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated
|
||||
|
||||
permission={'READ_LESSONS'}
|
||||
permission={'READ_PIPELINE_STAGES'}
|
||||
|
||||
>
|
||||
{page}
|
||||
@ -165,4 +159,4 @@ LessonsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
)
|
||||
}
|
||||
|
||||
export default LessonsTablesPage
|
||||
export default Pipeline_stagesTablesPage
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user