v1
This commit is contained in:
parent
64d7379d57
commit
d4a5e6b45c
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,6 @@
|
|||||||
|
/backend/node_modules
|
||||||
|
/frontend/node_modules
|
||||||
node_modules/
|
node_modules/
|
||||||
*/node_modules/
|
*/node_modules/
|
||||||
|
**/node_modules/
|
||||||
*/build/
|
*/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
|
<p class="tip">The application is currently launching. The page will automatically refresh once site is
|
||||||
available.</p>
|
available.</p>
|
||||||
<div class="project-info">
|
<div class="project-info">
|
||||||
<h2>Instructor-Student LMS</h2>
|
<h2>Sales Pipeline CRM</h2>
|
||||||
<p>Instructor-student LMS for courses, lessons, enrollments, and progress tracking.</p>
|
<p>Sales Pipeline CRM for managing leads, deals, contacts, activities and automated follow-ups.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="loader-container">
|
<div class="loader-container">
|
||||||
<img src="https://flatlogic.com/blog/wp-content/uploads/2025/05/logo-bot-1.png" alt="App Logo"
|
<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).
|
## This project was generated by [Flatlogic Platform](https://flatlogic.com).
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
DB_NAME=app_37612
|
DB_NAME=app_37742
|
||||||
DB_USER=app_37612
|
DB_USER=app_37742
|
||||||
DB_PASS=e52941c5-df65-471d-838b-20ceb5eda155
|
DB_PASS=72a5084e-302a-4f10-bdae-c6ada26bc4fa
|
||||||
DB_HOST=127.0.0.1
|
DB_HOST=127.0.0.1
|
||||||
DB_PORT=5432
|
DB_PORT=5432
|
||||||
PORT=3000
|
PORT=3000
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#Instructor-Student LMS - template backend,
|
#Sales Pipeline CRM - template backend,
|
||||||
|
|
||||||
#### Run App on local machine:
|
#### Run App on local machine:
|
||||||
|
|
||||||
@ -30,10 +30,10 @@
|
|||||||
- `psql postgres -U admin`
|
- `psql postgres -U admin`
|
||||||
|
|
||||||
- Type this command to creating a new database.
|
- 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`.
|
- 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`
|
- `postgres=> \q`
|
||||||
|
|
||||||
------------
|
------------
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "instructorstudentlms",
|
"name": "salespipelinecrm",
|
||||||
"description": "Instructor-Student LMS - template backend",
|
"description": "Sales Pipeline CRM - template backend",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "npm run db:migrate && npm run db:seed && npm run watch",
|
"start": "npm run db:migrate && npm run db:seed && npm run watch",
|
||||||
"lint": "eslint . --ext .js",
|
"lint": "eslint . --ext .js",
|
||||||
|
|||||||
@ -11,15 +11,15 @@ const config = {
|
|||||||
bcrypt: {
|
bcrypt: {
|
||||||
saltRounds: 12
|
saltRounds: 12
|
||||||
},
|
},
|
||||||
admin_pass: "e52941c5",
|
admin_pass: "72a5084e",
|
||||||
user_pass: "20ceb5eda155",
|
user_pass: "c6ada26bc4fa",
|
||||||
admin_email: "admin@flatlogic.com",
|
admin_email: "admin@flatlogic.com",
|
||||||
providers: {
|
providers: {
|
||||||
LOCAL: 'local',
|
LOCAL: 'local',
|
||||||
GOOGLE: 'google',
|
GOOGLE: 'google',
|
||||||
MICROSOFT: 'microsoft'
|
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: '',
|
remote: '',
|
||||||
port: process.env.NODE_ENV === "production" ? "" : "8080",
|
port: process.env.NODE_ENV === "production" ? "" : "8080",
|
||||||
hostUI: process.env.NODE_ENV === "production" ? "" : "http://localhost",
|
hostUI: process.env.NODE_ENV === "production" ? "" : "http://localhost",
|
||||||
@ -39,7 +39,7 @@ const config = {
|
|||||||
},
|
},
|
||||||
uploadDir: os.tmpdir(),
|
uploadDir: os.tmpdir(),
|
||||||
email: {
|
email: {
|
||||||
from: 'Instructor-Student LMS <app@flatlogic.app>',
|
from: 'Sales Pipeline CRM <app@flatlogic.app>',
|
||||||
host: 'email-smtp.us-east-1.amazonaws.com',
|
host: 'email-smtp.us-east-1.amazonaws.com',
|
||||||
port: 587,
|
port: 587,
|
||||||
auth: {
|
auth: {
|
||||||
@ -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',
|
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.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.host = process.env.NODE_ENV === "production" ? config.remote : "http://localhost";
|
||||||
config.apiUrl = `${config.host}${config.port ? `:${config.port}` : ``}/api`;
|
config.apiUrl = `${config.host}${config.port ? `:${config.port}` : ``}/api`;
|
||||||
config.swaggerUrl = `${config.swaggerUI}${config.swaggerPort}`;
|
config.swaggerUrl = `${config.swaggerUI}${config.swaggerPort}`;
|
||||||
|
|||||||
@ -9,7 +9,7 @@ const Utils = require('../utils');
|
|||||||
const Sequelize = db.Sequelize;
|
const Sequelize = db.Sequelize;
|
||||||
const Op = Sequelize.Op;
|
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 currentUser = (options && options.currentUser) || { id: null };
|
||||||
const transaction = (options && options.transaction) || undefined;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
const progress = await db.progress.create(
|
const activities = await db.activities.create(
|
||||||
{
|
{
|
||||||
id: data.id || undefined,
|
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
|
null
|
||||||
,
|
,
|
||||||
@ -32,17 +47,7 @@ module.exports = class ProgressDBApi {
|
|||||||
|
|
||||||
,
|
,
|
||||||
|
|
||||||
completed_at: data.completed_at
|
notes: data.notes
|
||||||
||
|
|
||||||
null
|
|
||||||
,
|
|
||||||
|
|
||||||
score: data.score
|
|
||||||
||
|
|
||||||
null
|
|
||||||
,
|
|
||||||
|
|
||||||
attempts: data.attempts
|
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
@ -55,11 +60,15 @@ module.exports = class ProgressDBApi {
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
await progress.setEnrollment( data.enrollment || null, {
|
await activities.setOwner( data.owner || null, {
|
||||||
transaction,
|
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,
|
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;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
// Prepare data - wrapping individual data transformations in a map() method
|
// 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,
|
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
|
null
|
||||||
,
|
,
|
||||||
@ -91,17 +115,7 @@ module.exports = class ProgressDBApi {
|
|||||||
|
|
||||||
,
|
,
|
||||||
|
|
||||||
completed_at: item.completed_at
|
notes: item.notes
|
||||||
||
|
|
||||||
null
|
|
||||||
,
|
|
||||||
|
|
||||||
score: item.score
|
|
||||||
||
|
|
||||||
null
|
|
||||||
,
|
|
||||||
|
|
||||||
attempts: item.attempts
|
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
@ -113,12 +127,12 @@ module.exports = class ProgressDBApi {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// Bulk create items
|
// 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
|
// For each item created, replace relation files
|
||||||
|
|
||||||
|
|
||||||
return progress;
|
return activities;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async update(id, data, options) {
|
static async update(id, data, options) {
|
||||||
@ -126,47 +140,59 @@ module.exports = class ProgressDBApi {
|
|||||||
const transaction = (options && options.transaction) || undefined;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
|
|
||||||
const progress = await db.progress.findByPk(id, {}, {transaction});
|
const activities = await db.activities.findByPk(id, {}, {transaction});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const updatePayload = {};
|
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 !== undefined) updatePayload.completed = data.completed;
|
||||||
|
|
||||||
|
|
||||||
if (data.completed_at !== undefined) updatePayload.completed_at = data.completed_at;
|
if (data.notes !== undefined) updatePayload.notes = data.notes;
|
||||||
|
|
||||||
|
|
||||||
if (data.score !== undefined) updatePayload.score = data.score;
|
|
||||||
|
|
||||||
|
|
||||||
if (data.attempts !== undefined) updatePayload.attempts = data.attempts;
|
|
||||||
|
|
||||||
|
|
||||||
updatePayload.updatedById = currentUser.id;
|
updatePayload.updatedById = currentUser.id;
|
||||||
|
|
||||||
await progress.update(updatePayload, {transaction});
|
await activities.update(updatePayload, {transaction});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (data.enrollment !== undefined) {
|
if (data.owner !== undefined) {
|
||||||
await progress.setEnrollment(
|
await activities.setOwner(
|
||||||
|
|
||||||
data.enrollment,
|
data.owner,
|
||||||
|
|
||||||
{ transaction }
|
{ transaction }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.lesson !== undefined) {
|
if (data.related_deal !== undefined) {
|
||||||
await progress.setLesson(
|
await activities.setRelated_deal(
|
||||||
|
|
||||||
data.lesson,
|
data.related_deal,
|
||||||
|
|
||||||
|
{ transaction }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.related_lead !== undefined) {
|
||||||
|
await activities.setRelated_lead(
|
||||||
|
|
||||||
|
data.related_lead,
|
||||||
|
|
||||||
{ transaction }
|
{ transaction }
|
||||||
);
|
);
|
||||||
@ -178,14 +204,14 @@ module.exports = class ProgressDBApi {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
return progress;
|
return activities;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async deleteByIds(ids, options) {
|
static async deleteByIds(ids, options) {
|
||||||
const currentUser = (options && options.currentUser) || { id: null };
|
const currentUser = (options && options.currentUser) || { id: null };
|
||||||
const transaction = (options && options.transaction) || undefined;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
const progress = await db.progress.findAll({
|
const activities = await db.activities.findAll({
|
||||||
where: {
|
where: {
|
||||||
id: {
|
id: {
|
||||||
[Op.in]: ids,
|
[Op.in]: ids,
|
||||||
@ -195,53 +221,53 @@ module.exports = class ProgressDBApi {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await db.sequelize.transaction(async (transaction) => {
|
await db.sequelize.transaction(async (transaction) => {
|
||||||
for (const record of progress) {
|
for (const record of activities) {
|
||||||
await record.update(
|
await record.update(
|
||||||
{deletedBy: currentUser.id},
|
{deletedBy: currentUser.id},
|
||||||
{transaction}
|
{transaction}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (const record of progress) {
|
for (const record of activities) {
|
||||||
await record.destroy({transaction});
|
await record.destroy({transaction});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return progress;
|
return activities;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async remove(id, options) {
|
static async remove(id, options) {
|
||||||
const currentUser = (options && options.currentUser) || {id: null};
|
const currentUser = (options && options.currentUser) || {id: null};
|
||||||
const transaction = (options && options.transaction) || undefined;
|
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
|
deletedBy: currentUser.id
|
||||||
}, {
|
}, {
|
||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
|
|
||||||
await progress.destroy({
|
await activities.destroy({
|
||||||
transaction
|
transaction
|
||||||
});
|
});
|
||||||
|
|
||||||
return progress;
|
return activities;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async findBy(where, options) {
|
static async findBy(where, options) {
|
||||||
const transaction = (options && options.transaction) || undefined;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
const progress = await db.progress.findOne(
|
const activities = await db.activities.findOne(
|
||||||
{ where },
|
{ where },
|
||||||
{ transaction },
|
{ transaction },
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!progress) {
|
if (!activities) {
|
||||||
return progress;
|
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
|
transaction
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
output.lesson = await progress.getLesson({
|
output.related_deal = await activities.getRelated_deal({
|
||||||
|
transaction
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
output.related_lead = await activities.getRelated_lead({
|
||||||
transaction
|
transaction
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -288,15 +320,15 @@ module.exports = class ProgressDBApi {
|
|||||||
let include = [
|
let include = [
|
||||||
|
|
||||||
{
|
{
|
||||||
model: db.enrollments,
|
model: db.users,
|
||||||
as: 'enrollment',
|
as: 'owner',
|
||||||
|
|
||||||
where: filter.enrollment ? {
|
where: filter.owner ? {
|
||||||
[Op.or]: [
|
[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: {
|
firstName: {
|
||||||
[Op.or]: filter.enrollment.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
[Op.or]: filter.owner.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@ -305,15 +337,32 @@ module.exports = class ProgressDBApi {
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
model: db.lessons,
|
model: db.deals,
|
||||||
as: 'lesson',
|
as: 'related_deal',
|
||||||
|
|
||||||
where: filter.lesson ? {
|
where: filter.related_deal ? {
|
||||||
[Op.or]: [
|
[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: {
|
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 = {
|
||||||
...where,
|
...where,
|
||||||
[Op.and]: Utils.ilike(
|
[Op.and]: Utils.ilike(
|
||||||
'progress',
|
'activities',
|
||||||
'note',
|
'subject',
|
||||||
filter.note,
|
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 !== '') {
|
if (start !== undefined && start !== null && start !== '') {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
completed_at: {
|
start: {
|
||||||
...where.completed_at,
|
...where.start,
|
||||||
[Op.gte]: start,
|
[Op.gte]: start,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -366,22 +444,22 @@ module.exports = class ProgressDBApi {
|
|||||||
if (end !== undefined && end !== null && end !== '') {
|
if (end !== undefined && end !== null && end !== '') {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
completed_at: {
|
start: {
|
||||||
...where.completed_at,
|
...where.start,
|
||||||
[Op.lte]: end,
|
[Op.lte]: end,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.scoreRange) {
|
if (filter.endRange) {
|
||||||
const [start, end] = filter.scoreRange;
|
const [start, end] = filter.endRange;
|
||||||
|
|
||||||
if (start !== undefined && start !== null && start !== '') {
|
if (start !== undefined && start !== null && start !== '') {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
score: {
|
end: {
|
||||||
...where.score,
|
...where.end,
|
||||||
[Op.gte]: start,
|
[Op.gte]: start,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -390,32 +468,8 @@ module.exports = class ProgressDBApi {
|
|||||||
if (end !== undefined && end !== null && end !== '') {
|
if (end !== undefined && end !== null && end !== '') {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
score: {
|
end: {
|
||||||
...where.score,
|
...where.end,
|
||||||
[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,
|
|
||||||
[Op.lte]: 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) {
|
if (filter.completed) {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
@ -446,6 +507,8 @@ module.exports = class ProgressDBApi {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (filter.createdAtRange) {
|
if (filter.createdAtRange) {
|
||||||
const [start, end] = filter.createdAtRange;
|
const [start, end] = filter.createdAtRange;
|
||||||
|
|
||||||
@ -491,7 +554,7 @@ module.exports = class ProgressDBApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { rows, count } = await db.progress.findAndCountAll(queryOptions);
|
const { rows, count } = await db.activities.findAndCountAll(queryOptions);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
rows: options?.countOnly ? [] : rows,
|
rows: options?.countOnly ? [] : rows,
|
||||||
@ -513,25 +576,25 @@ module.exports = class ProgressDBApi {
|
|||||||
[Op.or]: [
|
[Op.or]: [
|
||||||
{ ['id']: Utils.uuid(query) },
|
{ ['id']: Utils.uuid(query) },
|
||||||
Utils.ilike(
|
Utils.ilike(
|
||||||
'progress',
|
'activities',
|
||||||
'note',
|
'subject',
|
||||||
query,
|
query,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const records = await db.progress.findAll({
|
const records = await db.activities.findAll({
|
||||||
attributes: [ 'id', 'note' ],
|
attributes: [ 'id', 'subject' ],
|
||||||
where,
|
where,
|
||||||
limit: limit ? Number(limit) : undefined,
|
limit: limit ? Number(limit) : undefined,
|
||||||
offset: offset ? Number(offset) : undefined,
|
offset: offset ? Number(offset) : undefined,
|
||||||
orderBy: [['note', 'ASC']],
|
orderBy: [['subject', 'ASC']],
|
||||||
});
|
});
|
||||||
|
|
||||||
return records.map((record) => ({
|
return records.map((record) => ({
|
||||||
id: record.id,
|
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 Sequelize = db.Sequelize;
|
||||||
const Op = Sequelize.Op;
|
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 currentUser = (options && options.currentUser) || { id: null };
|
||||||
const transaction = (options && options.transaction) || undefined;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
const lessons = await db.lessons.create(
|
const deals = await db.deals.create(
|
||||||
{
|
{
|
||||||
id: data.id || undefined,
|
id: data.id || undefined,
|
||||||
|
|
||||||
@ -26,28 +26,33 @@ module.exports = class LessonsDBApi {
|
|||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
content: data.content
|
deal_number: data.deal_number
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
order: data.order
|
value: data.value
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
duration_minutes: data.duration_minutes
|
currency: data.currency
|
||||||
||
|
|
||||||
null
|
|
||||||
,
|
|
||||||
|
|
||||||
release_date: data.release_date
|
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
status: data.status
|
status: data.status
|
||||||
||
|
||
|
||||||
|
null
|
||||||
|
,
|
||||||
|
|
||||||
|
close_date: data.close_date
|
||||||
|
||
|
||||||
|
null
|
||||||
|
,
|
||||||
|
|
||||||
|
description: data.description
|
||||||
|
||
|
||||||
null
|
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,
|
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(
|
return deals;
|
||||||
{
|
|
||||||
belongsTo: db.lessons.getTableName(),
|
|
||||||
belongsToColumn: 'resources',
|
|
||||||
belongsToId: lessons.id,
|
|
||||||
},
|
|
||||||
data.resources,
|
|
||||||
options,
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
return lessons;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,7 +90,7 @@ module.exports = class LessonsDBApi {
|
|||||||
const transaction = (options && options.transaction) || undefined;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
// Prepare data - wrapping individual data transformations in a map() method
|
// 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,
|
id: item.id || undefined,
|
||||||
|
|
||||||
title: item.title
|
title: item.title
|
||||||
@ -105,22 +98,17 @@ module.exports = class LessonsDBApi {
|
|||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
content: item.content
|
deal_number: item.deal_number
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
order: item.order
|
value: item.value
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
duration_minutes: item.duration_minutes
|
currency: item.currency
|
||||||
||
|
|
||||||
null
|
|
||||||
,
|
|
||||||
|
|
||||||
release_date: item.release_date
|
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
@ -128,6 +116,16 @@ module.exports = class LessonsDBApi {
|
|||||||
status: item.status
|
status: item.status
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
|
,
|
||||||
|
|
||||||
|
close_date: item.close_date
|
||||||
|
||
|
||||||
|
null
|
||||||
|
,
|
||||||
|
|
||||||
|
description: item.description
|
||||||
|
||
|
||||||
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
importHash: item.importHash || null,
|
importHash: item.importHash || null,
|
||||||
@ -137,36 +135,12 @@ module.exports = class LessonsDBApi {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// Bulk create items
|
// 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 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++) {
|
return deals;
|
||||||
await FileDBApi.replaceRelationFiles(
|
|
||||||
{
|
|
||||||
belongsTo: db.lessons.getTableName(),
|
|
||||||
belongsToColumn: 'resources',
|
|
||||||
belongsToId: lessons[i].id,
|
|
||||||
},
|
|
||||||
data[i].resources,
|
|
||||||
options,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return lessons;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async update(id, data, options) {
|
static async update(id, data, options) {
|
||||||
@ -174,7 +148,7 @@ module.exports = class LessonsDBApi {
|
|||||||
const transaction = (options && options.transaction) || undefined;
|
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.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.currency !== undefined) updatePayload.currency = data.currency;
|
||||||
|
|
||||||
|
|
||||||
if (data.release_date !== undefined) updatePayload.release_date = data.release_date;
|
|
||||||
|
|
||||||
|
|
||||||
if (data.status !== undefined) updatePayload.status = data.status;
|
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;
|
updatePayload.updatedById = currentUser.id;
|
||||||
|
|
||||||
await lessons.update(updatePayload, {transaction});
|
await deals.update(updatePayload, {transaction});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (data.course !== undefined) {
|
if (data.stage !== undefined) {
|
||||||
await lessons.setCourse(
|
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 }
|
{ 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(
|
return deals;
|
||||||
{
|
|
||||||
belongsTo: db.lessons.getTableName(),
|
|
||||||
belongsToColumn: 'resources',
|
|
||||||
belongsToId: lessons.id,
|
|
||||||
},
|
|
||||||
data.resources,
|
|
||||||
options,
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
return lessons;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async deleteByIds(ids, options) {
|
static async deleteByIds(ids, options) {
|
||||||
const currentUser = (options && options.currentUser) || { id: null };
|
const currentUser = (options && options.currentUser) || { id: null };
|
||||||
const transaction = (options && options.transaction) || undefined;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
const lessons = await db.lessons.findAll({
|
const deals = await db.deals.findAll({
|
||||||
where: {
|
where: {
|
||||||
id: {
|
id: {
|
||||||
[Op.in]: ids,
|
[Op.in]: ids,
|
||||||
@ -257,53 +232,53 @@ module.exports = class LessonsDBApi {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await db.sequelize.transaction(async (transaction) => {
|
await db.sequelize.transaction(async (transaction) => {
|
||||||
for (const record of lessons) {
|
for (const record of deals) {
|
||||||
await record.update(
|
await record.update(
|
||||||
{deletedBy: currentUser.id},
|
{deletedBy: currentUser.id},
|
||||||
{transaction}
|
{transaction}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (const record of lessons) {
|
for (const record of deals) {
|
||||||
await record.destroy({transaction});
|
await record.destroy({transaction});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return lessons;
|
return deals;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async remove(id, options) {
|
static async remove(id, options) {
|
||||||
const currentUser = (options && options.currentUser) || {id: null};
|
const currentUser = (options && options.currentUser) || {id: null};
|
||||||
const transaction = (options && options.transaction) || undefined;
|
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
|
deletedBy: currentUser.id
|
||||||
}, {
|
}, {
|
||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
|
|
||||||
await lessons.destroy({
|
await deals.destroy({
|
||||||
transaction
|
transaction
|
||||||
});
|
});
|
||||||
|
|
||||||
return lessons;
|
return deals;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async findBy(where, options) {
|
static async findBy(where, options) {
|
||||||
const transaction = (options && options.transaction) || undefined;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
const lessons = await db.lessons.findOne(
|
const deals = await db.deals.findOne(
|
||||||
{ where },
|
{ where },
|
||||||
{ transaction },
|
{ transaction },
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!lessons) {
|
if (!deals) {
|
||||||
return lessons;
|
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
|
transaction
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
output.course = await lessons.getCourse({
|
output.stage = await deals.getStage({
|
||||||
transaction
|
transaction
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
output.video_files = await lessons.getVideo_files({
|
output.owner = await deals.getOwner({
|
||||||
transaction
|
transaction
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
output.resources = await lessons.getResources({
|
output.primary_contact = await deals.getPrimary_contact({
|
||||||
transaction
|
transaction
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -359,15 +335,49 @@ module.exports = class LessonsDBApi {
|
|||||||
let include = [
|
let include = [
|
||||||
|
|
||||||
{
|
{
|
||||||
model: db.courses,
|
model: db.pipeline_stages,
|
||||||
as: 'course',
|
as: 'stage',
|
||||||
|
|
||||||
where: filter.course ? {
|
where: filter.stage ? {
|
||||||
[Op.or]: [
|
[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: {
|
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) {
|
if (filter) {
|
||||||
@ -402,20 +402,42 @@ module.exports = class LessonsDBApi {
|
|||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
[Op.and]: Utils.ilike(
|
[Op.and]: Utils.ilike(
|
||||||
'lessons',
|
'deals',
|
||||||
'title',
|
'title',
|
||||||
filter.title,
|
filter.title,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.content) {
|
if (filter.deal_number) {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
[Op.and]: Utils.ilike(
|
[Op.and]: Utils.ilike(
|
||||||
'lessons',
|
'deals',
|
||||||
'content',
|
'deal_number',
|
||||||
filter.content,
|
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) {
|
if (filter.valueRange) {
|
||||||
const [start, end] = filter.orderRange;
|
const [start, end] = filter.valueRange;
|
||||||
|
|
||||||
if (start !== undefined && start !== null && start !== '') {
|
if (start !== undefined && start !== null && start !== '') {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
order: {
|
value: {
|
||||||
...where.order,
|
...where.value,
|
||||||
[Op.gte]: start,
|
[Op.gte]: start,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -441,22 +463,22 @@ module.exports = class LessonsDBApi {
|
|||||||
if (end !== undefined && end !== null && end !== '') {
|
if (end !== undefined && end !== null && end !== '') {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
order: {
|
value: {
|
||||||
...where.order,
|
...where.value,
|
||||||
[Op.lte]: end,
|
[Op.lte]: end,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.duration_minutesRange) {
|
if (filter.close_dateRange) {
|
||||||
const [start, end] = filter.duration_minutesRange;
|
const [start, end] = filter.close_dateRange;
|
||||||
|
|
||||||
if (start !== undefined && start !== null && start !== '') {
|
if (start !== undefined && start !== null && start !== '') {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
duration_minutes: {
|
close_date: {
|
||||||
...where.duration_minutes,
|
...where.close_date,
|
||||||
[Op.gte]: start,
|
[Op.gte]: start,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -465,32 +487,8 @@ module.exports = class LessonsDBApi {
|
|||||||
if (end !== undefined && end !== null && end !== '') {
|
if (end !== undefined && end !== null && end !== '') {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
duration_minutes: {
|
close_date: {
|
||||||
...where.duration_minutes,
|
...where.close_date,
|
||||||
[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,
|
|
||||||
[Op.lte]: end,
|
[Op.lte]: end,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -519,6 +517,10 @@ module.exports = class LessonsDBApi {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (filter.createdAtRange) {
|
if (filter.createdAtRange) {
|
||||||
const [start, end] = filter.createdAtRange;
|
const [start, end] = filter.createdAtRange;
|
||||||
|
|
||||||
@ -564,7 +566,7 @@ module.exports = class LessonsDBApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { rows, count } = await db.lessons.findAndCountAll(queryOptions);
|
const { rows, count } = await db.deals.findAndCountAll(queryOptions);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
rows: options?.countOnly ? [] : rows,
|
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, ) {
|
static async findAllAutocomplete(query, limit, offset, ) {
|
||||||
let where = {};
|
let where = {};
|
||||||
|
|
||||||
@ -586,7 +603,7 @@ module.exports = class LessonsDBApi {
|
|||||||
[Op.or]: [
|
[Op.or]: [
|
||||||
{ ['id']: Utils.uuid(query) },
|
{ ['id']: Utils.uuid(query) },
|
||||||
Utils.ilike(
|
Utils.ilike(
|
||||||
'lessons',
|
'deals',
|
||||||
'title',
|
'title',
|
||||||
query,
|
query,
|
||||||
),
|
),
|
||||||
@ -594,7 +611,7 @@ module.exports = class LessonsDBApi {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const records = await db.lessons.findAll({
|
const records = await db.deals.findAll({
|
||||||
attributes: [ 'id', 'title' ],
|
attributes: [ 'id', 'title' ],
|
||||||
where,
|
where,
|
||||||
limit: limit ? Number(limit) : undefined,
|
limit: limit ? Number(limit) : undefined,
|
||||||
@ -9,7 +9,7 @@ const Utils = require('../utils');
|
|||||||
const Sequelize = db.Sequelize;
|
const Sequelize = db.Sequelize;
|
||||||
const Op = Sequelize.Op;
|
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 currentUser = (options && options.currentUser) || { id: null };
|
||||||
const transaction = (options && options.transaction) || undefined;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
const enrollments = await db.enrollments.create(
|
const leads = await db.leads.create(
|
||||||
{
|
{
|
||||||
id: data.id || undefined,
|
id: data.id || undefined,
|
||||||
|
|
||||||
enrollment_label: data.enrollment_label
|
name: data.name
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
enrolled_at: data.enrolled_at
|
company: data.company
|
||||||
|
||
|
||||||
|
null
|
||||||
|
,
|
||||||
|
|
||||||
|
email: data.email
|
||||||
|
||
|
||||||
|
null
|
||||||
|
,
|
||||||
|
|
||||||
|
phone: data.phone
|
||||||
|
||
|
||||||
|
null
|
||||||
|
,
|
||||||
|
|
||||||
|
source: data.source
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
@ -36,12 +51,12 @@ module.exports = class EnrollmentsDBApi {
|
|||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
progress_percent: data.progress_percent
|
estimated_value: data.estimated_value
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
price_paid: data.price_paid
|
notes: data.notes
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
@ -54,11 +69,7 @@ module.exports = class EnrollmentsDBApi {
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
await enrollments.setStudent( data.student || null, {
|
await leads.setOwner( data.owner || null, {
|
||||||
transaction,
|
|
||||||
});
|
|
||||||
|
|
||||||
await enrollments.setCourse( data.course || null, {
|
|
||||||
transaction,
|
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;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
// Prepare data - wrapping individual data transformations in a map() method
|
// 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,
|
id: item.id || undefined,
|
||||||
|
|
||||||
enrollment_label: item.enrollment_label
|
name: item.name
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
enrolled_at: item.enrolled_at
|
company: item.company
|
||||||
|
||
|
||||||
|
null
|
||||||
|
,
|
||||||
|
|
||||||
|
email: item.email
|
||||||
|
||
|
||||||
|
null
|
||||||
|
,
|
||||||
|
|
||||||
|
phone: item.phone
|
||||||
|
||
|
||||||
|
null
|
||||||
|
,
|
||||||
|
|
||||||
|
source: item.source
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
@ -94,12 +120,12 @@ module.exports = class EnrollmentsDBApi {
|
|||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
progress_percent: item.progress_percent
|
estimated_value: item.estimated_value
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
price_paid: item.price_paid
|
notes: item.notes
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
@ -111,12 +137,12 @@ module.exports = class EnrollmentsDBApi {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// Bulk create items
|
// 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
|
// For each item created, replace relation files
|
||||||
|
|
||||||
|
|
||||||
return enrollments;
|
return leads;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async update(id, data, options) {
|
static async update(id, data, options) {
|
||||||
@ -124,47 +150,47 @@ module.exports = class EnrollmentsDBApi {
|
|||||||
const transaction = (options && options.transaction) || undefined;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
|
|
||||||
const enrollments = await db.enrollments.findByPk(id, {}, {transaction});
|
const leads = await db.leads.findByPk(id, {}, {transaction});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const updatePayload = {};
|
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.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;
|
updatePayload.updatedById = currentUser.id;
|
||||||
|
|
||||||
await enrollments.update(updatePayload, {transaction});
|
await leads.update(updatePayload, {transaction});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (data.student !== undefined) {
|
if (data.owner !== undefined) {
|
||||||
await enrollments.setStudent(
|
await leads.setOwner(
|
||||||
|
|
||||||
data.student,
|
data.owner,
|
||||||
|
|
||||||
{ transaction }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.course !== undefined) {
|
|
||||||
await enrollments.setCourse(
|
|
||||||
|
|
||||||
data.course,
|
|
||||||
|
|
||||||
{ transaction }
|
{ transaction }
|
||||||
);
|
);
|
||||||
@ -176,14 +202,14 @@ module.exports = class EnrollmentsDBApi {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
return enrollments;
|
return leads;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async deleteByIds(ids, options) {
|
static async deleteByIds(ids, options) {
|
||||||
const currentUser = (options && options.currentUser) || { id: null };
|
const currentUser = (options && options.currentUser) || { id: null };
|
||||||
const transaction = (options && options.transaction) || undefined;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
const enrollments = await db.enrollments.findAll({
|
const leads = await db.leads.findAll({
|
||||||
where: {
|
where: {
|
||||||
id: {
|
id: {
|
||||||
[Op.in]: ids,
|
[Op.in]: ids,
|
||||||
@ -193,53 +219,53 @@ module.exports = class EnrollmentsDBApi {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await db.sequelize.transaction(async (transaction) => {
|
await db.sequelize.transaction(async (transaction) => {
|
||||||
for (const record of enrollments) {
|
for (const record of leads) {
|
||||||
await record.update(
|
await record.update(
|
||||||
{deletedBy: currentUser.id},
|
{deletedBy: currentUser.id},
|
||||||
{transaction}
|
{transaction}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (const record of enrollments) {
|
for (const record of leads) {
|
||||||
await record.destroy({transaction});
|
await record.destroy({transaction});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return enrollments;
|
return leads;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async remove(id, options) {
|
static async remove(id, options) {
|
||||||
const currentUser = (options && options.currentUser) || {id: null};
|
const currentUser = (options && options.currentUser) || {id: null};
|
||||||
const transaction = (options && options.transaction) || undefined;
|
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
|
deletedBy: currentUser.id
|
||||||
}, {
|
}, {
|
||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
|
|
||||||
await enrollments.destroy({
|
await leads.destroy({
|
||||||
transaction
|
transaction
|
||||||
});
|
});
|
||||||
|
|
||||||
return enrollments;
|
return leads;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async findBy(where, options) {
|
static async findBy(where, options) {
|
||||||
const transaction = (options && options.transaction) || undefined;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
const enrollments = await db.enrollments.findOne(
|
const leads = await db.leads.findOne(
|
||||||
{ where },
|
{ where },
|
||||||
{ transaction },
|
{ transaction },
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!enrollments) {
|
if (!leads) {
|
||||||
return enrollments;
|
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
|
transaction
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
output.student = await enrollments.getStudent({
|
output.owner = await leads.getOwner({
|
||||||
transaction
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
output.course = await enrollments.getCourse({
|
|
||||||
transaction
|
transaction
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -291,31 +313,14 @@ module.exports = class EnrollmentsDBApi {
|
|||||||
|
|
||||||
{
|
{
|
||||||
model: db.users,
|
model: db.users,
|
||||||
as: 'student',
|
as: 'owner',
|
||||||
|
|
||||||
where: filter.student ? {
|
where: filter.owner ? {
|
||||||
[Op.or]: [
|
[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: {
|
firstName: {
|
||||||
[Op.or]: filter.student.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
|
[Op.or]: filter.owner.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}%` }))
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@ -336,13 +341,57 @@ module.exports = class EnrollmentsDBApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (filter.enrollment_label) {
|
if (filter.name) {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
[Op.and]: Utils.ilike(
|
[Op.and]: Utils.ilike(
|
||||||
'enrollments',
|
'leads',
|
||||||
'enrollment_label',
|
'name',
|
||||||
filter.enrollment_label,
|
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) {
|
if (filter.estimated_valueRange) {
|
||||||
const [start, end] = filter.enrolled_atRange;
|
const [start, end] = filter.estimated_valueRange;
|
||||||
|
|
||||||
if (start !== undefined && start !== null && start !== '') {
|
if (start !== undefined && start !== null && start !== '') {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
enrolled_at: {
|
estimated_value: {
|
||||||
...where.enrolled_at,
|
...where.estimated_value,
|
||||||
[Op.gte]: start,
|
[Op.gte]: start,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -368,56 +417,8 @@ module.exports = class EnrollmentsDBApi {
|
|||||||
if (end !== undefined && end !== null && end !== '') {
|
if (end !== undefined && end !== null && end !== '') {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
enrolled_at: {
|
estimated_value: {
|
||||||
...where.enrolled_at,
|
...where.estimated_value,
|
||||||
[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,
|
|
||||||
[Op.lte]: end,
|
[Op.lte]: end,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -433,6 +434,13 @@ module.exports = class EnrollmentsDBApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (filter.source) {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
source: filter.source,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (filter.status) {
|
if (filter.status) {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
@ -446,8 +454,6 @@ module.exports = class EnrollmentsDBApi {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (filter.createdAtRange) {
|
if (filter.createdAtRange) {
|
||||||
const [start, end] = filter.createdAtRange;
|
const [start, end] = filter.createdAtRange;
|
||||||
|
|
||||||
@ -493,7 +499,7 @@ module.exports = class EnrollmentsDBApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { rows, count } = await db.enrollments.findAndCountAll(queryOptions);
|
const { rows, count } = await db.leads.findAndCountAll(queryOptions);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
rows: options?.countOnly ? [] : rows,
|
rows: options?.countOnly ? [] : rows,
|
||||||
@ -515,25 +521,25 @@ module.exports = class EnrollmentsDBApi {
|
|||||||
[Op.or]: [
|
[Op.or]: [
|
||||||
{ ['id']: Utils.uuid(query) },
|
{ ['id']: Utils.uuid(query) },
|
||||||
Utils.ilike(
|
Utils.ilike(
|
||||||
'enrollments',
|
'leads',
|
||||||
'enrollment_label',
|
'name',
|
||||||
query,
|
query,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const records = await db.enrollments.findAll({
|
const records = await db.leads.findAll({
|
||||||
attributes: [ 'id', 'enrollment_label' ],
|
attributes: [ 'id', 'name' ],
|
||||||
where,
|
where,
|
||||||
limit: limit ? Number(limit) : undefined,
|
limit: limit ? Number(limit) : undefined,
|
||||||
offset: offset ? Number(offset) : undefined,
|
offset: offset ? Number(offset) : undefined,
|
||||||
orderBy: [['enrollment_label', 'ASC']],
|
orderBy: [['name', 'ASC']],
|
||||||
});
|
});
|
||||||
|
|
||||||
return records.map((record) => ({
|
return records.map((record) => ({
|
||||||
id: record.id,
|
id: record.id,
|
||||||
label: record.enrollment_label,
|
label: record.name,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,6 +173,7 @@ module.exports = class PermissionsDBApi {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ const Utils = require('../utils');
|
|||||||
const Sequelize = db.Sequelize;
|
const Sequelize = db.Sequelize;
|
||||||
const Op = Sequelize.Op;
|
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 currentUser = (options && options.currentUser) || { id: null };
|
||||||
const transaction = (options && options.transaction) || undefined;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
const courses = await db.courses.create(
|
const pipeline_stages = await db.pipeline_stages.create(
|
||||||
{
|
{
|
||||||
id: data.id || undefined,
|
id: data.id || undefined,
|
||||||
|
|
||||||
@ -26,47 +26,22 @@ module.exports = class CoursesDBApi {
|
|||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
description: data.description
|
order: data.order
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
category: data.category
|
probability: data.probability
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
level: data.level
|
is_default: data.is_default
|
||||||
||
|
|
||||||
null
|
|
||||||
,
|
|
||||||
|
|
||||||
published: data.published
|
|
||||||
||
|
||
|
||||||
false
|
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,
|
importHash: data.importHash || null,
|
||||||
createdById: currentUser.id,
|
createdById: currentUser.id,
|
||||||
updatedById: currentUser.id,
|
updatedById: currentUser.id,
|
||||||
@ -75,26 +50,12 @@ module.exports = class CoursesDBApi {
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
await courses.setInstructor( data.instructor || null, {
|
|
||||||
transaction,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
await FileDBApi.replaceRelationFiles(
|
return pipeline_stages;
|
||||||
{
|
|
||||||
belongsTo: db.courses.getTableName(),
|
|
||||||
belongsToColumn: 'thumbnail',
|
|
||||||
belongsToId: courses.id,
|
|
||||||
},
|
|
||||||
data.thumbnail,
|
|
||||||
options,
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
return courses;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -103,7 +64,7 @@ module.exports = class CoursesDBApi {
|
|||||||
const transaction = (options && options.transaction) || undefined;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
// Prepare data - wrapping individual data transformations in a map() method
|
// 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,
|
id: item.id || undefined,
|
||||||
|
|
||||||
title: item.title
|
title: item.title
|
||||||
@ -111,45 +72,20 @@ module.exports = class CoursesDBApi {
|
|||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
description: item.description
|
order: item.order
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
category: item.category
|
probability: item.probability
|
||||||
||
|
||
|
||||||
null
|
null
|
||||||
,
|
,
|
||||||
|
|
||||||
level: item.level
|
is_default: item.is_default
|
||||||
||
|
|
||||||
null
|
|
||||||
,
|
|
||||||
|
|
||||||
published: item.published
|
|
||||||
||
|
||
|
||||||
false
|
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,
|
importHash: item.importHash || null,
|
||||||
@ -159,24 +95,12 @@ module.exports = class CoursesDBApi {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// Bulk create items
|
// 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 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 pipeline_stages;
|
||||||
return courses;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async update(id, data, options) {
|
static async update(id, data, options) {
|
||||||
@ -184,7 +108,7 @@ module.exports = class CoursesDBApi {
|
|||||||
const transaction = (options && options.transaction) || undefined;
|
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.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.is_default !== undefined) updatePayload.is_default = data.is_default;
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
|
|
||||||
updatePayload.updatedById = currentUser.id;
|
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) {
|
static async deleteByIds(ids, options) {
|
||||||
const currentUser = (options && options.currentUser) || { id: null };
|
const currentUser = (options && options.currentUser) || { id: null };
|
||||||
const transaction = (options && options.transaction) || undefined;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
const courses = await db.courses.findAll({
|
const pipeline_stages = await db.pipeline_stages.findAll({
|
||||||
where: {
|
where: {
|
||||||
id: {
|
id: {
|
||||||
[Op.in]: ids,
|
[Op.in]: ids,
|
||||||
@ -266,79 +156,66 @@ module.exports = class CoursesDBApi {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await db.sequelize.transaction(async (transaction) => {
|
await db.sequelize.transaction(async (transaction) => {
|
||||||
for (const record of courses) {
|
for (const record of pipeline_stages) {
|
||||||
await record.update(
|
await record.update(
|
||||||
{deletedBy: currentUser.id},
|
{deletedBy: currentUser.id},
|
||||||
{transaction}
|
{transaction}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (const record of courses) {
|
for (const record of pipeline_stages) {
|
||||||
await record.destroy({transaction});
|
await record.destroy({transaction});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return courses;
|
return pipeline_stages;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async remove(id, options) {
|
static async remove(id, options) {
|
||||||
const currentUser = (options && options.currentUser) || {id: null};
|
const currentUser = (options && options.currentUser) || {id: null};
|
||||||
const transaction = (options && options.transaction) || undefined;
|
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
|
deletedBy: currentUser.id
|
||||||
}, {
|
}, {
|
||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
|
|
||||||
await courses.destroy({
|
await pipeline_stages.destroy({
|
||||||
transaction
|
transaction
|
||||||
});
|
});
|
||||||
|
|
||||||
return courses;
|
return pipeline_stages;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async findBy(where, options) {
|
static async findBy(where, options) {
|
||||||
const transaction = (options && options.transaction) || undefined;
|
const transaction = (options && options.transaction) || undefined;
|
||||||
|
|
||||||
const courses = await db.courses.findOne(
|
const pipeline_stages = await db.pipeline_stages.findOne(
|
||||||
{ where },
|
{ where },
|
||||||
{ transaction },
|
{ transaction },
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!courses) {
|
if (!pipeline_stages) {
|
||||||
return courses;
|
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
|
transaction
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
output.enrollments_course = await courses.getEnrollments_course({
|
|
||||||
transaction
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
output.instructor = await courses.getInstructor({
|
|
||||||
transaction
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
output.thumbnail = await courses.getThumbnail({
|
|
||||||
transaction
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -366,29 +243,7 @@ module.exports = class CoursesDBApi {
|
|||||||
|
|
||||||
let include = [
|
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',
|
|
||||||
},
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -405,66 +260,26 @@ module.exports = class CoursesDBApi {
|
|||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
[Op.and]: Utils.ilike(
|
[Op.and]: Utils.ilike(
|
||||||
'courses',
|
'pipeline_stages',
|
||||||
'title',
|
'title',
|
||||||
filter.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.orderRange) {
|
||||||
|
const [start, end] = filter.orderRange;
|
||||||
if (filter.start_dateRange) {
|
|
||||||
const [start, end] = filter.start_dateRange;
|
|
||||||
|
|
||||||
if (start !== undefined && start !== null && start !== '') {
|
if (start !== undefined && start !== null && start !== '') {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
start_date: {
|
order: {
|
||||||
...where.start_date,
|
...where.order,
|
||||||
[Op.gte]: start,
|
[Op.gte]: start,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -473,22 +288,22 @@ module.exports = class CoursesDBApi {
|
|||||||
if (end !== undefined && end !== null && end !== '') {
|
if (end !== undefined && end !== null && end !== '') {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
start_date: {
|
order: {
|
||||||
...where.start_date,
|
...where.order,
|
||||||
[Op.lte]: end,
|
[Op.lte]: end,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.end_dateRange) {
|
if (filter.probabilityRange) {
|
||||||
const [start, end] = filter.end_dateRange;
|
const [start, end] = filter.probabilityRange;
|
||||||
|
|
||||||
if (start !== undefined && start !== null && start !== '') {
|
if (start !== undefined && start !== null && start !== '') {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
end_date: {
|
probability: {
|
||||||
...where.end_date,
|
...where.probability,
|
||||||
[Op.gte]: start,
|
[Op.gte]: start,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -497,32 +312,8 @@ module.exports = class CoursesDBApi {
|
|||||||
if (end !== undefined && end !== null && end !== '') {
|
if (end !== undefined && end !== null && end !== '') {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
end_date: {
|
probability: {
|
||||||
...where.end_date,
|
...where.probability,
|
||||||
[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,
|
|
||||||
[Op.lte]: end,
|
[Op.lte]: end,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -538,29 +329,13 @@ module.exports = class CoursesDBApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (filter.category) {
|
if (filter.is_default) {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
category: filter.category,
|
is_default: filter.is_default,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.level) {
|
|
||||||
where = {
|
|
||||||
...where,
|
|
||||||
level: filter.level,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filter.published) {
|
|
||||||
where = {
|
|
||||||
...where,
|
|
||||||
published: filter.published,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -610,7 +385,7 @@ module.exports = class CoursesDBApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { rows, count } = await db.courses.findAndCountAll(queryOptions);
|
const { rows, count } = await db.pipeline_stages.findAndCountAll(queryOptions);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
rows: options?.countOnly ? [] : rows,
|
rows: options?.countOnly ? [] : rows,
|
||||||
@ -632,7 +407,7 @@ module.exports = class CoursesDBApi {
|
|||||||
[Op.or]: [
|
[Op.or]: [
|
||||||
{ ['id']: Utils.uuid(query) },
|
{ ['id']: Utils.uuid(query) },
|
||||||
Utils.ilike(
|
Utils.ilike(
|
||||||
'courses',
|
'pipeline_stages',
|
||||||
'title',
|
'title',
|
||||||
query,
|
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' ],
|
attributes: [ 'id', 'title' ],
|
||||||
where,
|
where,
|
||||||
limit: limit ? Number(limit) : undefined,
|
limit: limit ? Number(limit) : undefined,
|
||||||
@ -197,6 +197,7 @@ module.exports = class RolesDBApi {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
output.permissions = await roles.getPermissions({
|
output.permissions = await roles.getPermissions({
|
||||||
transaction
|
transaction
|
||||||
});
|
});
|
||||||
|
|||||||
@ -403,17 +403,26 @@ module.exports = class UsersDBApi {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
output.courses_instructor = await users.getCourses_instructor({
|
|
||||||
|
output.leads_owner = await users.getLeads_owner({
|
||||||
transaction
|
transaction
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
output.contacts_owner = await users.getContacts_owner({
|
||||||
output.enrollments_student = await users.getEnrollments_student({
|
|
||||||
transaction
|
transaction
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
output.deals_owner = await users.getDeals_owner({
|
||||||
|
transaction
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
output.activities_owner = await users.getActivities_owner({
|
||||||
|
transaction
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
output.avatar = await users.getAvatar({
|
output.avatar = await users.getAvatar({
|
||||||
|
|||||||
@ -15,7 +15,7 @@ module.exports = {
|
|||||||
username: 'postgres',
|
username: 'postgres',
|
||||||
dialect: 'postgres',
|
dialect: 'postgres',
|
||||||
password: '',
|
password: '',
|
||||||
database: 'db_instructor_student_lms',
|
database: 'db_sales_pipeline_crm',
|
||||||
host: process.env.DB_HOST || 'localhost',
|
host: process.env.DB_HOST || 'localhost',
|
||||||
logging: console.log,
|
logging: console.log,
|
||||||
seederStorage: 'sequelize',
|
seederStorage: 'sequelize',
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -5,8 +5,8 @@ const bcrypt = require('bcrypt');
|
|||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
|
||||||
module.exports = function(sequelize, DataTypes) {
|
module.exports = function(sequelize, DataTypes) {
|
||||||
const enrollments = sequelize.define(
|
const activities = sequelize.define(
|
||||||
'enrollments',
|
'activities',
|
||||||
{
|
{
|
||||||
id: {
|
id: {
|
||||||
type: DataTypes.UUID,
|
type: DataTypes.UUID,
|
||||||
@ -14,48 +14,64 @@ module.exports = function(sequelize, DataTypes) {
|
|||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
enrollment_label: {
|
subject: {
|
||||||
type: DataTypes.TEXT,
|
type: DataTypes.TEXT,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
enrolled_at: {
|
activity_type: {
|
||||||
type: DataTypes.DATE,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
status: {
|
|
||||||
type: DataTypes.ENUM,
|
type: DataTypes.ENUM,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
values: [
|
values: [
|
||||||
|
|
||||||
"active",
|
"Call",
|
||||||
|
|
||||||
|
|
||||||
"completed",
|
"Meeting",
|
||||||
|
|
||||||
|
|
||||||
"cancelled"
|
"Email",
|
||||||
|
|
||||||
|
|
||||||
|
"Task",
|
||||||
|
|
||||||
|
|
||||||
|
"FollowUp"
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
progress_percent: {
|
start: {
|
||||||
type: DataTypes.DECIMAL,
|
type: DataTypes.DATE,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
price_paid: {
|
end: {
|
||||||
type: DataTypes.DECIMAL,
|
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
|
/// 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, {
|
db.activities.belongsTo(db.users, {
|
||||||
as: 'student',
|
as: 'owner',
|
||||||
foreignKey: {
|
foreignKey: {
|
||||||
name: 'studentId',
|
name: 'ownerId',
|
||||||
},
|
},
|
||||||
constraints: false,
|
constraints: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
db.enrollments.belongsTo(db.courses, {
|
db.activities.belongsTo(db.deals, {
|
||||||
as: 'course',
|
as: 'related_deal',
|
||||||
foreignKey: {
|
foreignKey: {
|
||||||
name: 'courseId',
|
name: 'related_dealId',
|
||||||
|
},
|
||||||
|
constraints: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
db.activities.belongsTo(db.leads, {
|
||||||
|
as: 'related_lead',
|
||||||
|
foreignKey: {
|
||||||
|
name: 'related_leadId',
|
||||||
},
|
},
|
||||||
constraints: false,
|
constraints: false,
|
||||||
});
|
});
|
||||||
@ -119,18 +136,18 @@ price_paid: {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
db.enrollments.belongsTo(db.users, {
|
db.activities.belongsTo(db.users, {
|
||||||
as: 'createdBy',
|
as: 'createdBy',
|
||||||
});
|
});
|
||||||
|
|
||||||
db.enrollments.belongsTo(db.users, {
|
db.activities.belongsTo(db.users, {
|
||||||
as: 'updatedBy',
|
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');
|
const moment = require('moment');
|
||||||
|
|
||||||
module.exports = function(sequelize, DataTypes) {
|
module.exports = function(sequelize, DataTypes) {
|
||||||
const lessons = sequelize.define(
|
const deals = sequelize.define(
|
||||||
'lessons',
|
'deals',
|
||||||
{
|
{
|
||||||
id: {
|
id: {
|
||||||
type: DataTypes.UUID,
|
type: DataTypes.UUID,
|
||||||
@ -21,29 +21,22 @@ title: {
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
content: {
|
deal_number: {
|
||||||
type: DataTypes.TEXT,
|
type: DataTypes.TEXT,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
order: {
|
value: {
|
||||||
type: DataTypes.INTEGER,
|
type: DataTypes.DECIMAL,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
duration_minutes: {
|
currency: {
|
||||||
type: DataTypes.INTEGER,
|
type: DataTypes.TEXT,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
release_date: {
|
|
||||||
type: DataTypes.DATE,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -56,18 +49,32 @@ status: {
|
|||||||
|
|
||||||
values: [
|
values: [
|
||||||
|
|
||||||
"draft",
|
"Open",
|
||||||
|
|
||||||
|
|
||||||
"published",
|
"Won",
|
||||||
|
|
||||||
|
|
||||||
"archived"
|
"Lost"
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
close_date: {
|
||||||
|
type: DataTypes.DATE,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
description: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
importHash: {
|
importHash: {
|
||||||
type: DataTypes.STRING(255),
|
type: DataTypes.STRING(255),
|
||||||
allowNull: true,
|
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
|
/// 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: {
|
foreignKey: {
|
||||||
name: 'lessonId',
|
name: 'related_dealId',
|
||||||
},
|
},
|
||||||
constraints: false,
|
constraints: false,
|
||||||
});
|
});
|
||||||
@ -107,49 +115,45 @@ status: {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
db.lessons.belongsTo(db.courses, {
|
db.deals.belongsTo(db.pipeline_stages, {
|
||||||
as: 'course',
|
as: 'stage',
|
||||||
foreignKey: {
|
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,
|
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, {
|
db.deals.belongsTo(db.users, {
|
||||||
as: 'resources',
|
|
||||||
foreignKey: 'belongsToId',
|
|
||||||
constraints: false,
|
|
||||||
scope: {
|
|
||||||
belongsTo: db.lessons.getTableName(),
|
|
||||||
belongsToColumn: 'resources',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
db.lessons.belongsTo(db.users, {
|
|
||||||
as: 'createdBy',
|
as: 'createdBy',
|
||||||
});
|
});
|
||||||
|
|
||||||
db.lessons.belongsTo(db.users, {
|
db.deals.belongsTo(db.users, {
|
||||||
as: 'updatedBy',
|
as: 'updatedBy',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return lessons;
|
return deals;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -5,8 +5,8 @@ const bcrypt = require('bcrypt');
|
|||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
|
||||||
module.exports = function(sequelize, DataTypes) {
|
module.exports = function(sequelize, DataTypes) {
|
||||||
const courses = sequelize.define(
|
const leads = sequelize.define(
|
||||||
'courses',
|
'leads',
|
||||||
{
|
{
|
||||||
id: {
|
id: {
|
||||||
type: DataTypes.UUID,
|
type: DataTypes.UUID,
|
||||||
@ -14,99 +14,89 @@ module.exports = function(sequelize, DataTypes) {
|
|||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
title: {
|
name: {
|
||||||
type: DataTypes.TEXT,
|
type: DataTypes.TEXT,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
description: {
|
company: {
|
||||||
type: DataTypes.TEXT,
|
type: DataTypes.TEXT,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
category: {
|
email: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
phone: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
source: {
|
||||||
type: DataTypes.ENUM,
|
type: DataTypes.ENUM,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
values: [
|
values: [
|
||||||
|
|
||||||
"Programming",
|
"Website",
|
||||||
|
|
||||||
|
|
||||||
"Design",
|
"Referral",
|
||||||
|
|
||||||
|
|
||||||
"Math",
|
"Email",
|
||||||
|
|
||||||
|
|
||||||
"Language",
|
"ColdCall",
|
||||||
|
|
||||||
|
|
||||||
"Business",
|
"SocialMedia"
|
||||||
|
|
||||||
|
|
||||||
"Other"
|
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
level: {
|
status: {
|
||||||
type: DataTypes.ENUM,
|
type: DataTypes.ENUM,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
values: [
|
values: [
|
||||||
|
|
||||||
"Beginner",
|
"New",
|
||||||
|
|
||||||
|
|
||||||
"Intermediate",
|
"Contacted",
|
||||||
|
|
||||||
|
|
||||||
"Advanced"
|
"Qualified",
|
||||||
|
|
||||||
|
|
||||||
|
"Unqualified"
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
published: {
|
estimated_value: {
|
||||||
type: DataTypes.BOOLEAN,
|
|
||||||
|
|
||||||
allowNull: false,
|
|
||||||
defaultValue: false,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
start_date: {
|
|
||||||
type: DataTypes.DATE,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
end_date: {
|
|
||||||
type: DataTypes.DATE,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
price: {
|
|
||||||
type: DataTypes.DECIMAL,
|
type: DataTypes.DECIMAL,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
language: {
|
notes: {
|
||||||
type: DataTypes.TEXT,
|
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
|
/// 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: {
|
foreignKey: {
|
||||||
name: 'courseId',
|
name: 'related_leadId',
|
||||||
},
|
},
|
||||||
constraints: false,
|
constraints: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
db.courses.hasMany(db.enrollments, {
|
|
||||||
as: 'enrollments_course',
|
|
||||||
foreignKey: {
|
|
||||||
name: 'courseId',
|
|
||||||
},
|
|
||||||
constraints: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//end loop
|
//end loop
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
db.courses.belongsTo(db.users, {
|
db.leads.belongsTo(db.users, {
|
||||||
as: 'instructor',
|
as: 'owner',
|
||||||
foreignKey: {
|
foreignKey: {
|
||||||
name: 'instructorId',
|
name: 'ownerId',
|
||||||
},
|
},
|
||||||
constraints: false,
|
constraints: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
db.courses.hasMany(db.file, {
|
|
||||||
as: 'thumbnail',
|
|
||||||
foreignKey: 'belongsToId',
|
|
||||||
constraints: false,
|
|
||||||
scope: {
|
|
||||||
belongsTo: db.courses.getTableName(),
|
|
||||||
belongsToColumn: 'thumbnail',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
|
db.leads.belongsTo(db.users, {
|
||||||
db.courses.belongsTo(db.users, {
|
|
||||||
as: 'createdBy',
|
as: 'createdBy',
|
||||||
});
|
});
|
||||||
|
|
||||||
db.courses.belongsTo(db.users, {
|
db.leads.belongsTo(db.users, {
|
||||||
as: 'updatedBy',
|
as: 'updatedBy',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return courses;
|
return leads;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -48,6 +48,7 @@ name: {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//end loop
|
//end loop
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,8 +5,8 @@ const bcrypt = require('bcrypt');
|
|||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
|
||||||
module.exports = function(sequelize, DataTypes) {
|
module.exports = function(sequelize, DataTypes) {
|
||||||
const progress = sequelize.define(
|
const pipeline_stages = sequelize.define(
|
||||||
'progress',
|
'pipeline_stages',
|
||||||
{
|
{
|
||||||
id: {
|
id: {
|
||||||
type: DataTypes.UUID,
|
type: DataTypes.UUID,
|
||||||
@ -14,14 +14,28 @@ module.exports = function(sequelize, DataTypes) {
|
|||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
note: {
|
title: {
|
||||||
type: DataTypes.TEXT,
|
type: DataTypes.TEXT,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
completed: {
|
order: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
probability: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
is_default: {
|
||||||
type: DataTypes.BOOLEAN,
|
type: DataTypes.BOOLEAN,
|
||||||
|
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
@ -29,27 +43,6 @@ completed: {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
completed_at: {
|
|
||||||
type: DataTypes.DATE,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
score: {
|
|
||||||
type: DataTypes.DECIMAL,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
attempts: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
importHash: {
|
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
|
/// 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
|
//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.pipeline_stages.belongsTo(db.users, {
|
||||||
db.progress.belongsTo(db.users, {
|
|
||||||
as: 'createdBy',
|
as: 'createdBy',
|
||||||
});
|
});
|
||||||
|
|
||||||
db.progress.belongsTo(db.users, {
|
db.pipeline_stages.belongsTo(db.users, {
|
||||||
as: 'updatedBy',
|
as: 'updatedBy',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return progress;
|
return pipeline_stages;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -81,6 +81,7 @@ role_customization: {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//end loop
|
//end loop
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -144,25 +144,42 @@ provider: {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
db.users.hasMany(db.courses, {
|
|
||||||
as: 'courses_instructor',
|
db.users.hasMany(db.leads, {
|
||||||
|
as: 'leads_owner',
|
||||||
foreignKey: {
|
foreignKey: {
|
||||||
name: 'instructorId',
|
name: 'ownerId',
|
||||||
},
|
},
|
||||||
constraints: false,
|
constraints: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
db.users.hasMany(db.contacts, {
|
||||||
db.users.hasMany(db.enrollments, {
|
as: 'contacts_owner',
|
||||||
as: 'enrollments_student',
|
|
||||||
foreignKey: {
|
foreignKey: {
|
||||||
name: 'studentId',
|
name: 'ownerId',
|
||||||
},
|
},
|
||||||
constraints: false,
|
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
|
//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 = [
|
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", entities.flatMap(createPermissions));
|
||||||
await queryInterface.bulkInsert("permissions", [{ id: getId(`READ_API_DOCS`), createdAt, updatedAt, name: `READ_API_DOCS` }]);
|
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,19 +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("SalesManager"), permissionId: getId('DELETE_PIPELINE_STAGES') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -227,15 +227,13 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('CREATE_COURSES') },
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('READ_PIPELINE_STAGES') },
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_COURSES') },
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_COURSES') },
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -246,9 +244,9 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('READ_PIPELINE_STAGES') },
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("TeachingAssistant"), permissionId: getId('READ_COURSES') },
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -261,9 +259,9 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('READ_PIPELINE_STAGES') },
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Student"), permissionId: getId('READ_COURSES') },
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -284,59 +282,59 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('CREATE_LEADS') },
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('CREATE_LESSONS') },
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('READ_LEADS') },
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('READ_LESSONS') },
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('UPDATE_LEADS') },
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('UPDATE_LESSONS') },
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('DELETE_LEADS') },
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('DELETE_LESSONS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('CREATE_LEADS') },
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('CREATE_LESSONS') },
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('READ_LEADS') },
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('READ_LESSONS') },
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('UPDATE_LEADS') },
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('UPDATE_LESSONS') },
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('DELETE_LEADS') },
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('DELETE_LESSONS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('CREATE_LEADS') },
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('CREATE_LESSONS') },
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('READ_LEADS') },
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_LESSONS') },
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('UPDATE_LEADS') },
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_LESSONS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -345,15 +343,16 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ 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("TeachingAssistant"), permissionId: getId('READ_LESSONS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('UPDATE_LEADS') },
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("TeachingAssistant"), permissionId: getId('UPDATE_LESSONS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -365,8 +364,8 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('READ_LEADS') },
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Student"), permissionId: getId('READ_LESSONS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -388,20 +387,20 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('CREATE_CONTACTS') },
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('CREATE_ENROLLMENTS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('READ_CONTACTS') },
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('READ_ENROLLMENTS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('UPDATE_CONTACTS') },
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('UPDATE_ENROLLMENTS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('DELETE_CONTACTS') },
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('DELETE_ENROLLMENTS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -409,20 +408,20 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('CREATE_CONTACTS') },
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('CREATE_ENROLLMENTS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('READ_CONTACTS') },
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('READ_ENROLLMENTS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('UPDATE_CONTACTS') },
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('UPDATE_ENROLLMENTS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('DELETE_CONTACTS') },
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('DELETE_ENROLLMENTS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -430,14 +429,15 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('CREATE_CONTACTS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_ENROLLMENTS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('READ_CONTACTS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_ENROLLMENTS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('UPDATE_CONTACTS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -448,13 +448,15 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('CREATE_CONTACTS') },
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("TeachingAssistant"), permissionId: getId('READ_ENROLLMENTS') },
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('READ_CONTACTS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('UPDATE_CONTACTS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -463,16 +465,17 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Student"), permissionId: getId('CREATE_ENROLLMENTS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('CREATE_CONTACTS') },
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Student"), permissionId: getId('READ_ENROLLMENTS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('READ_CONTACTS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('UPDATE_CONTACTS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -490,61 +493,60 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('CREATE_PROGRESS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('READ_PROGRESS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('CREATE_DEALS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('UPDATE_PROGRESS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('READ_DEALS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('DELETE_PROGRESS') },
|
{ 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("InstructorLead"), permissionId: getId('CREATE_PROGRESS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('READ_PROGRESS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('CREATE_DEALS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('UPDATE_PROGRESS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('READ_DEALS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('DELETE_PROGRESS') },
|
{ 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("Instructor"), permissionId: getId('CREATE_PROGRESS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_PROGRESS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('CREATE_DEALS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_PROGRESS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('READ_DEALS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('DELETE_PROGRESS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('UPDATE_DEALS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -555,11 +557,11 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("TeachingAssistant"), permissionId: getId('READ_PROGRESS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('CREATE_DEALS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("TeachingAssistant"), permissionId: getId('UPDATE_PROGRESS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('READ_DEALS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -570,12 +572,11 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Student"), permissionId: getId('CREATE_PROGRESS') },
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Student"), permissionId: getId('READ_PROGRESS') },
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SupportSpecialist"), permissionId: getId('READ_DEALS') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -592,15 +593,127 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("PlatformManager"), permissionId: getId('CREATE_SEARCH') },
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("InstructorLead"), permissionId: getId('CREATE_SEARCH') },
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('CREATE_SEARCH') },
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("TeachingAssistant"), permissionId: getId('CREATE_SEARCH') },
|
|
||||||
|
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Student"), permissionId: getId('CREATE_SEARCH') },
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('CREATE_ACTIVITIES') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('READ_ACTIVITIES') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('UPDATE_ACTIVITIES') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('DELETE_ACTIVITIES') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('CREATE_ACTIVITIES') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('READ_ACTIVITIES') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('UPDATE_ACTIVITIES') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('DELETE_ACTIVITIES') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('CREATE_ACTIVITIES') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('READ_ACTIVITIES') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('UPDATE_ACTIVITIES') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), permissionId: getId('CREATE_ACTIVITIES') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ 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') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("OrganizationOwner"), permissionId: getId('CREATE_SEARCH') },
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesManager"), permissionId: getId('CREATE_SEARCH') },
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SeniorSalesRep"), permissionId: getId('CREATE_SEARCH') },
|
||||||
|
|
||||||
|
{ createdAt, updatedAt, roles_permissionsId: getId("SalesRep"), 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('UPDATE_PERMISSIONS') },
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_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('CREATE_PIPELINE_STAGES') },
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_COURSES') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_PIPELINE_STAGES') },
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_COURSES') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_PIPELINE_STAGES') },
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_COURSES') },
|
{ 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('CREATE_LEADS') },
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_LESSONS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_LEADS') },
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_LESSONS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_LEADS') },
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_LESSONS') },
|
{ 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('CREATE_CONTACTS') },
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_ENROLLMENTS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_CONTACTS') },
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_ENROLLMENTS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_CONTACTS') },
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_ENROLLMENTS') },
|
{ 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('CREATE_DEALS') },
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_PROGRESS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_DEALS') },
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_PROGRESS') },
|
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_DEALS') },
|
||||||
{ createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_PROGRESS') },
|
{ 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("OrganizationOwner")}' 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("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 authRoutes = require('./routes/auth');
|
||||||
const fileRoutes = require('./routes/file');
|
const fileRoutes = require('./routes/file');
|
||||||
const searchRoutes = require('./routes/search');
|
const searchRoutes = require('./routes/search');
|
||||||
|
const sqlRoutes = require('./routes/sql');
|
||||||
const pexelsRoutes = require('./routes/pexels');
|
const pexelsRoutes = require('./routes/pexels');
|
||||||
|
|
||||||
const openaiRoutes = require('./routes/openai');
|
const openaiRoutes = require('./routes/openai');
|
||||||
@ -26,13 +27,15 @@ const rolesRoutes = require('./routes/roles');
|
|||||||
|
|
||||||
const permissionsRoutes = require('./routes/permissions');
|
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) => {
|
const getBaseUrl = (url) => {
|
||||||
@ -45,8 +48,8 @@ const options = {
|
|||||||
openapi: "3.0.0",
|
openapi: "3.0.0",
|
||||||
info: {
|
info: {
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
title: "Instructor-Student LMS",
|
title: "Sales Pipeline CRM",
|
||||||
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.",
|
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: [
|
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/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(
|
app.use(
|
||||||
'/api/openai',
|
'/api/openai',
|
||||||
@ -121,6 +126,10 @@ app.use(
|
|||||||
'/api/search',
|
'/api/search',
|
||||||
passport.authenticate('jwt', { session: false }),
|
passport.authenticate('jwt', { session: false }),
|
||||||
searchRoutes);
|
searchRoutes);
|
||||||
|
app.use(
|
||||||
|
'/api/sql',
|
||||||
|
passport.authenticate('jwt', { session: false }),
|
||||||
|
sqlRoutes);
|
||||||
|
|
||||||
|
|
||||||
const publicDir = path.join(
|
const publicDir = path.join(
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
|
|
||||||
const LessonsService = require('../services/lessons');
|
const ActivitiesService = require('../services/activities');
|
||||||
const LessonsDBApi = require('../db/api/lessons');
|
const ActivitiesDBApi = require('../db/api/activities');
|
||||||
const wrapAsync = require('../helpers').wrapAsync;
|
const wrapAsync = require('../helpers').wrapAsync;
|
||||||
|
|
||||||
|
|
||||||
@ -15,30 +15,24 @@ const {
|
|||||||
checkCrudPermissions,
|
checkCrudPermissions,
|
||||||
} = require('../middlewares/check-permissions');
|
} = require('../middlewares/check-permissions');
|
||||||
|
|
||||||
router.use(checkCrudPermissions('lessons'));
|
router.use(checkCrudPermissions('activities'));
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* components:
|
* components:
|
||||||
* schemas:
|
* schemas:
|
||||||
* Lessons:
|
* Activities:
|
||||||
* type: object
|
* type: object
|
||||||
* properties:
|
* properties:
|
||||||
|
|
||||||
* title:
|
* subject:
|
||||||
* type: string
|
* type: string
|
||||||
* default: title
|
* default: subject
|
||||||
* content:
|
* notes:
|
||||||
* type: string
|
* 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
|
* @swagger
|
||||||
* tags:
|
* tags:
|
||||||
* name: Lessons
|
* name: Activities
|
||||||
* description: The Lessons managing API
|
* description: The Activities managing API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/lessons:
|
* /api/activities:
|
||||||
* post:
|
* post:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Lessons]
|
* tags: [Activities]
|
||||||
* summary: Add new item
|
* summary: Add new item
|
||||||
* description: Add new item
|
* description: Add new item
|
||||||
* requestBody:
|
* requestBody:
|
||||||
@ -69,14 +63,14 @@ router.use(checkCrudPermissions('lessons'));
|
|||||||
* data:
|
* data:
|
||||||
* description: Data of the updated item
|
* description: Data of the updated item
|
||||||
* type: object
|
* type: object
|
||||||
* $ref: "#/components/schemas/Lessons"
|
* $ref: "#/components/schemas/Activities"
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: The item was successfully added
|
* description: The item was successfully added
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Lessons"
|
* $ref: "#/components/schemas/Activities"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 405:
|
* 405:
|
||||||
@ -87,7 +81,7 @@ router.use(checkCrudPermissions('lessons'));
|
|||||||
router.post('/', wrapAsync(async (req, res) => {
|
router.post('/', wrapAsync(async (req, res) => {
|
||||||
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
||||||
const link = new URL(referer);
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
@ -98,7 +92,7 @@ router.post('/', wrapAsync(async (req, res) => {
|
|||||||
* post:
|
* post:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Lessons]
|
* tags: [Activities]
|
||||||
* summary: Bulk import items
|
* summary: Bulk import items
|
||||||
* description: Bulk import items
|
* description: Bulk import items
|
||||||
* requestBody:
|
* requestBody:
|
||||||
@ -111,14 +105,14 @@ router.post('/', wrapAsync(async (req, res) => {
|
|||||||
* description: Data of the updated items
|
* description: Data of the updated items
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/Lessons"
|
* $ref: "#/components/schemas/Activities"
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: The items were successfully imported
|
* description: The items were successfully imported
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Lessons"
|
* $ref: "#/components/schemas/Activities"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 405:
|
* 405:
|
||||||
@ -130,18 +124,18 @@ router.post('/', wrapAsync(async (req, res) => {
|
|||||||
router.post('/bulk-import', wrapAsync(async (req, res) => {
|
router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||||
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
||||||
const link = new URL(referer);
|
const link = new URL(referer);
|
||||||
await LessonsService.bulkImport(req, res, true, link.host);
|
await ActivitiesService.bulkImport(req, res, true, link.host);
|
||||||
const payload = true;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/lessons/{id}:
|
* /api/activities/{id}:
|
||||||
* put:
|
* put:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Lessons]
|
* tags: [Activities]
|
||||||
* summary: Update the data of the selected item
|
* summary: Update the data of the selected item
|
||||||
* description: Update the data of the selected item
|
* description: Update the data of the selected item
|
||||||
* parameters:
|
* parameters:
|
||||||
@ -164,7 +158,7 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
|||||||
* data:
|
* data:
|
||||||
* description: Data of the updated item
|
* description: Data of the updated item
|
||||||
* type: object
|
* type: object
|
||||||
* $ref: "#/components/schemas/Lessons"
|
* $ref: "#/components/schemas/Activities"
|
||||||
* required:
|
* required:
|
||||||
* - id
|
* - id
|
||||||
* responses:
|
* responses:
|
||||||
@ -173,7 +167,7 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Lessons"
|
* $ref: "#/components/schemas/Activities"
|
||||||
* 400:
|
* 400:
|
||||||
* description: Invalid ID supplied
|
* description: Invalid ID supplied
|
||||||
* 401:
|
* 401:
|
||||||
@ -184,18 +178,18 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
|||||||
* description: Some server error
|
* description: Some server error
|
||||||
*/
|
*/
|
||||||
router.put('/:id', wrapAsync(async (req, res) => {
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/lessons/{id}:
|
* /api/activities/{id}:
|
||||||
* delete:
|
* delete:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Lessons]
|
* tags: [Activities]
|
||||||
* summary: Delete the selected item
|
* summary: Delete the selected item
|
||||||
* description: Delete the selected item
|
* description: Delete the selected item
|
||||||
* parameters:
|
* parameters:
|
||||||
@ -211,7 +205,7 @@ router.put('/:id', wrapAsync(async (req, res) => {
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Lessons"
|
* $ref: "#/components/schemas/Activities"
|
||||||
* 400:
|
* 400:
|
||||||
* description: Invalid ID supplied
|
* description: Invalid ID supplied
|
||||||
* 401:
|
* 401:
|
||||||
@ -222,18 +216,18 @@ router.put('/:id', wrapAsync(async (req, res) => {
|
|||||||
* description: Some server error
|
* description: Some server error
|
||||||
*/
|
*/
|
||||||
router.delete('/:id', wrapAsync(async (req, res) => {
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/lessons/deleteByIds:
|
* /api/activities/deleteByIds:
|
||||||
* post:
|
* post:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Lessons]
|
* tags: [Activities]
|
||||||
* summary: Delete the selected item list
|
* summary: Delete the selected item list
|
||||||
* description: Delete the selected item list
|
* description: Delete the selected item list
|
||||||
* requestBody:
|
* requestBody:
|
||||||
@ -251,7 +245,7 @@ router.delete('/:id', wrapAsync(async (req, res) => {
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Lessons"
|
* $ref: "#/components/schemas/Activities"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 404:
|
* 404:
|
||||||
@ -260,29 +254,29 @@ router.delete('/:id', wrapAsync(async (req, res) => {
|
|||||||
* description: Some server error
|
* description: Some server error
|
||||||
*/
|
*/
|
||||||
router.post('/deleteByIds', wrapAsync(async (req, res) => {
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/lessons:
|
* /api/activities:
|
||||||
* get:
|
* get:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Lessons]
|
* tags: [Activities]
|
||||||
* summary: Get all lessons
|
* summary: Get all activities
|
||||||
* description: Get all lessons
|
* description: Get all activities
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Lessons list successfully received
|
* description: Activities list successfully received
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/Lessons"
|
* $ref: "#/components/schemas/Activities"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 404:
|
* 404:
|
||||||
@ -294,14 +288,14 @@ router.get('/', wrapAsync(async (req, res) => {
|
|||||||
const filetype = req.query.filetype
|
const filetype = req.query.filetype
|
||||||
|
|
||||||
const currentUser = req.currentUser;
|
const currentUser = req.currentUser;
|
||||||
const payload = await LessonsDBApi.findAll(
|
const payload = await ActivitiesDBApi.findAll(
|
||||||
req.query, { currentUser }
|
req.query, { currentUser }
|
||||||
);
|
);
|
||||||
if (filetype && filetype === 'csv') {
|
if (filetype && filetype === 'csv') {
|
||||||
const fields = ['id','title','content',
|
const fields = ['id','subject','notes',
|
||||||
'order','duration_minutes',
|
|
||||||
|
|
||||||
'release_date',
|
|
||||||
|
'start','end',
|
||||||
];
|
];
|
||||||
const opts = { fields };
|
const opts = { fields };
|
||||||
try {
|
try {
|
||||||
@ -320,22 +314,22 @@ router.get('/', wrapAsync(async (req, res) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/lessons/count:
|
* /api/activities/count:
|
||||||
* get:
|
* get:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Lessons]
|
* tags: [Activities]
|
||||||
* summary: Count all lessons
|
* summary: Count all activities
|
||||||
* description: Count all lessons
|
* description: Count all activities
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Lessons count successfully received
|
* description: Activities count successfully received
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/Lessons"
|
* $ref: "#/components/schemas/Activities"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 404:
|
* 404:
|
||||||
@ -346,7 +340,7 @@ router.get('/', wrapAsync(async (req, res) => {
|
|||||||
router.get('/count', wrapAsync(async (req, res) => {
|
router.get('/count', wrapAsync(async (req, res) => {
|
||||||
|
|
||||||
const currentUser = req.currentUser;
|
const currentUser = req.currentUser;
|
||||||
const payload = await LessonsDBApi.findAll(
|
const payload = await ActivitiesDBApi.findAll(
|
||||||
req.query,
|
req.query,
|
||||||
null,
|
null,
|
||||||
{ countOnly: true, currentUser }
|
{ countOnly: true, currentUser }
|
||||||
@ -357,22 +351,22 @@ router.get('/count', wrapAsync(async (req, res) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/lessons/autocomplete:
|
* /api/activities/autocomplete:
|
||||||
* get:
|
* get:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Lessons]
|
* tags: [Activities]
|
||||||
* summary: Find all lessons that match search criteria
|
* summary: Find all activities that match search criteria
|
||||||
* description: Find all lessons that match search criteria
|
* description: Find all activities that match search criteria
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Lessons list successfully received
|
* description: Activities list successfully received
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/Lessons"
|
* $ref: "#/components/schemas/Activities"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 404:
|
* 404:
|
||||||
@ -382,7 +376,7 @@ router.get('/count', wrapAsync(async (req, res) => {
|
|||||||
*/
|
*/
|
||||||
router.get('/autocomplete', async (req, res) => {
|
router.get('/autocomplete', async (req, res) => {
|
||||||
|
|
||||||
const payload = await LessonsDBApi.findAllAutocomplete(
|
const payload = await ActivitiesDBApi.findAllAutocomplete(
|
||||||
req.query.query,
|
req.query.query,
|
||||||
req.query.limit,
|
req.query.limit,
|
||||||
req.query.offset,
|
req.query.offset,
|
||||||
@ -394,11 +388,11 @@ router.get('/autocomplete', async (req, res) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/lessons/{id}:
|
* /api/activities/{id}:
|
||||||
* get:
|
* get:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Lessons]
|
* tags: [Activities]
|
||||||
* summary: Get selected item
|
* summary: Get selected item
|
||||||
* description: Get selected item
|
* description: Get selected item
|
||||||
* parameters:
|
* parameters:
|
||||||
@ -414,7 +408,7 @@ router.get('/autocomplete', async (req, res) => {
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Lessons"
|
* $ref: "#/components/schemas/Activities"
|
||||||
* 400:
|
* 400:
|
||||||
* description: Invalid ID supplied
|
* description: Invalid ID supplied
|
||||||
* 401:
|
* 401:
|
||||||
@ -425,7 +419,7 @@ router.get('/autocomplete', async (req, res) => {
|
|||||||
* description: Some server error
|
* description: Some server error
|
||||||
*/
|
*/
|
||||||
router.get('/:id', wrapAsync(async (req, res) => {
|
router.get('/:id', wrapAsync(async (req, res) => {
|
||||||
const payload = await LessonsDBApi.findBy(
|
const payload = await ActivitiesDBApi.findBy(
|
||||||
{ id: req.params.id },
|
{ id: req.params.id },
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
|
|
||||||
const ProgressService = require('../services/progress');
|
const ContactsService = require('../services/contacts');
|
||||||
const ProgressDBApi = require('../db/api/progress');
|
const ContactsDBApi = require('../db/api/contacts');
|
||||||
const wrapAsync = require('../helpers').wrapAsync;
|
const wrapAsync = require('../helpers').wrapAsync;
|
||||||
|
|
||||||
|
|
||||||
@ -15,45 +15,54 @@ const {
|
|||||||
checkCrudPermissions,
|
checkCrudPermissions,
|
||||||
} = require('../middlewares/check-permissions');
|
} = require('../middlewares/check-permissions');
|
||||||
|
|
||||||
router.use(checkCrudPermissions('progress'));
|
router.use(checkCrudPermissions('contacts'));
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* components:
|
* components:
|
||||||
* schemas:
|
* schemas:
|
||||||
* Progress:
|
* Contacts:
|
||||||
* type: object
|
* type: object
|
||||||
* properties:
|
* properties:
|
||||||
|
|
||||||
* note:
|
* name:
|
||||||
* type: string
|
* 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
|
* @swagger
|
||||||
* tags:
|
* tags:
|
||||||
* name: Progress
|
* name: Contacts
|
||||||
* description: The Progress managing API
|
* description: The Contacts managing API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/progress:
|
* /api/contacts:
|
||||||
* post:
|
* post:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Progress]
|
* tags: [Contacts]
|
||||||
* summary: Add new item
|
* summary: Add new item
|
||||||
* description: Add new item
|
* description: Add new item
|
||||||
* requestBody:
|
* requestBody:
|
||||||
@ -65,14 +74,14 @@ router.use(checkCrudPermissions('progress'));
|
|||||||
* data:
|
* data:
|
||||||
* description: Data of the updated item
|
* description: Data of the updated item
|
||||||
* type: object
|
* type: object
|
||||||
* $ref: "#/components/schemas/Progress"
|
* $ref: "#/components/schemas/Contacts"
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: The item was successfully added
|
* description: The item was successfully added
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Progress"
|
* $ref: "#/components/schemas/Contacts"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 405:
|
* 405:
|
||||||
@ -83,7 +92,7 @@ router.use(checkCrudPermissions('progress'));
|
|||||||
router.post('/', wrapAsync(async (req, res) => {
|
router.post('/', wrapAsync(async (req, res) => {
|
||||||
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
||||||
const link = new URL(referer);
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
@ -94,7 +103,7 @@ router.post('/', wrapAsync(async (req, res) => {
|
|||||||
* post:
|
* post:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Progress]
|
* tags: [Contacts]
|
||||||
* summary: Bulk import items
|
* summary: Bulk import items
|
||||||
* description: Bulk import items
|
* description: Bulk import items
|
||||||
* requestBody:
|
* requestBody:
|
||||||
@ -107,14 +116,14 @@ router.post('/', wrapAsync(async (req, res) => {
|
|||||||
* description: Data of the updated items
|
* description: Data of the updated items
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/Progress"
|
* $ref: "#/components/schemas/Contacts"
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: The items were successfully imported
|
* description: The items were successfully imported
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Progress"
|
* $ref: "#/components/schemas/Contacts"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 405:
|
* 405:
|
||||||
@ -126,18 +135,18 @@ router.post('/', wrapAsync(async (req, res) => {
|
|||||||
router.post('/bulk-import', wrapAsync(async (req, res) => {
|
router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||||
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
||||||
const link = new URL(referer);
|
const link = new URL(referer);
|
||||||
await ProgressService.bulkImport(req, res, true, link.host);
|
await ContactsService.bulkImport(req, res, true, link.host);
|
||||||
const payload = true;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/progress/{id}:
|
* /api/contacts/{id}:
|
||||||
* put:
|
* put:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Progress]
|
* tags: [Contacts]
|
||||||
* summary: Update the data of the selected item
|
* summary: Update the data of the selected item
|
||||||
* description: Update the data of the selected item
|
* description: Update the data of the selected item
|
||||||
* parameters:
|
* parameters:
|
||||||
@ -160,7 +169,7 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
|||||||
* data:
|
* data:
|
||||||
* description: Data of the updated item
|
* description: Data of the updated item
|
||||||
* type: object
|
* type: object
|
||||||
* $ref: "#/components/schemas/Progress"
|
* $ref: "#/components/schemas/Contacts"
|
||||||
* required:
|
* required:
|
||||||
* - id
|
* - id
|
||||||
* responses:
|
* responses:
|
||||||
@ -169,7 +178,7 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Progress"
|
* $ref: "#/components/schemas/Contacts"
|
||||||
* 400:
|
* 400:
|
||||||
* description: Invalid ID supplied
|
* description: Invalid ID supplied
|
||||||
* 401:
|
* 401:
|
||||||
@ -180,18 +189,18 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
|||||||
* description: Some server error
|
* description: Some server error
|
||||||
*/
|
*/
|
||||||
router.put('/:id', wrapAsync(async (req, res) => {
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/progress/{id}:
|
* /api/contacts/{id}:
|
||||||
* delete:
|
* delete:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Progress]
|
* tags: [Contacts]
|
||||||
* summary: Delete the selected item
|
* summary: Delete the selected item
|
||||||
* description: Delete the selected item
|
* description: Delete the selected item
|
||||||
* parameters:
|
* parameters:
|
||||||
@ -207,7 +216,7 @@ router.put('/:id', wrapAsync(async (req, res) => {
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Progress"
|
* $ref: "#/components/schemas/Contacts"
|
||||||
* 400:
|
* 400:
|
||||||
* description: Invalid ID supplied
|
* description: Invalid ID supplied
|
||||||
* 401:
|
* 401:
|
||||||
@ -218,18 +227,18 @@ router.put('/:id', wrapAsync(async (req, res) => {
|
|||||||
* description: Some server error
|
* description: Some server error
|
||||||
*/
|
*/
|
||||||
router.delete('/:id', wrapAsync(async (req, res) => {
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/progress/deleteByIds:
|
* /api/contacts/deleteByIds:
|
||||||
* post:
|
* post:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Progress]
|
* tags: [Contacts]
|
||||||
* summary: Delete the selected item list
|
* summary: Delete the selected item list
|
||||||
* description: Delete the selected item list
|
* description: Delete the selected item list
|
||||||
* requestBody:
|
* requestBody:
|
||||||
@ -247,7 +256,7 @@ router.delete('/:id', wrapAsync(async (req, res) => {
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Progress"
|
* $ref: "#/components/schemas/Contacts"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 404:
|
* 404:
|
||||||
@ -256,29 +265,29 @@ router.delete('/:id', wrapAsync(async (req, res) => {
|
|||||||
* description: Some server error
|
* description: Some server error
|
||||||
*/
|
*/
|
||||||
router.post('/deleteByIds', wrapAsync(async (req, res) => {
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/progress:
|
* /api/contacts:
|
||||||
* get:
|
* get:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Progress]
|
* tags: [Contacts]
|
||||||
* summary: Get all progress
|
* summary: Get all contacts
|
||||||
* description: Get all progress
|
* description: Get all contacts
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Progress list successfully received
|
* description: Contacts list successfully received
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/Progress"
|
* $ref: "#/components/schemas/Contacts"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 404:
|
* 404:
|
||||||
@ -290,14 +299,14 @@ router.get('/', wrapAsync(async (req, res) => {
|
|||||||
const filetype = req.query.filetype
|
const filetype = req.query.filetype
|
||||||
|
|
||||||
const currentUser = req.currentUser;
|
const currentUser = req.currentUser;
|
||||||
const payload = await ProgressDBApi.findAll(
|
const payload = await ContactsDBApi.findAll(
|
||||||
req.query, { currentUser }
|
req.query, { currentUser }
|
||||||
);
|
);
|
||||||
if (filetype && filetype === 'csv') {
|
if (filetype && filetype === 'csv') {
|
||||||
const fields = ['id','note',
|
const fields = ['id','name','email','phone','title','company','notes',
|
||||||
'attempts',
|
|
||||||
'score',
|
|
||||||
'completed_at',
|
|
||||||
];
|
];
|
||||||
const opts = { fields };
|
const opts = { fields };
|
||||||
try {
|
try {
|
||||||
@ -316,22 +325,22 @@ router.get('/', wrapAsync(async (req, res) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/progress/count:
|
* /api/contacts/count:
|
||||||
* get:
|
* get:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Progress]
|
* tags: [Contacts]
|
||||||
* summary: Count all progress
|
* summary: Count all contacts
|
||||||
* description: Count all progress
|
* description: Count all contacts
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Progress count successfully received
|
* description: Contacts count successfully received
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/Progress"
|
* $ref: "#/components/schemas/Contacts"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 404:
|
* 404:
|
||||||
@ -342,7 +351,7 @@ router.get('/', wrapAsync(async (req, res) => {
|
|||||||
router.get('/count', wrapAsync(async (req, res) => {
|
router.get('/count', wrapAsync(async (req, res) => {
|
||||||
|
|
||||||
const currentUser = req.currentUser;
|
const currentUser = req.currentUser;
|
||||||
const payload = await ProgressDBApi.findAll(
|
const payload = await ContactsDBApi.findAll(
|
||||||
req.query,
|
req.query,
|
||||||
null,
|
null,
|
||||||
{ countOnly: true, currentUser }
|
{ countOnly: true, currentUser }
|
||||||
@ -353,22 +362,22 @@ router.get('/count', wrapAsync(async (req, res) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/progress/autocomplete:
|
* /api/contacts/autocomplete:
|
||||||
* get:
|
* get:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Progress]
|
* tags: [Contacts]
|
||||||
* summary: Find all progress that match search criteria
|
* summary: Find all contacts that match search criteria
|
||||||
* description: Find all progress that match search criteria
|
* description: Find all contacts that match search criteria
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Progress list successfully received
|
* description: Contacts list successfully received
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/Progress"
|
* $ref: "#/components/schemas/Contacts"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 404:
|
* 404:
|
||||||
@ -378,7 +387,7 @@ router.get('/count', wrapAsync(async (req, res) => {
|
|||||||
*/
|
*/
|
||||||
router.get('/autocomplete', async (req, res) => {
|
router.get('/autocomplete', async (req, res) => {
|
||||||
|
|
||||||
const payload = await ProgressDBApi.findAllAutocomplete(
|
const payload = await ContactsDBApi.findAllAutocomplete(
|
||||||
req.query.query,
|
req.query.query,
|
||||||
req.query.limit,
|
req.query.limit,
|
||||||
req.query.offset,
|
req.query.offset,
|
||||||
@ -390,11 +399,11 @@ router.get('/autocomplete', async (req, res) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/progress/{id}:
|
* /api/contacts/{id}:
|
||||||
* get:
|
* get:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Progress]
|
* tags: [Contacts]
|
||||||
* summary: Get selected item
|
* summary: Get selected item
|
||||||
* description: Get selected item
|
* description: Get selected item
|
||||||
* parameters:
|
* parameters:
|
||||||
@ -410,7 +419,7 @@ router.get('/autocomplete', async (req, res) => {
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Progress"
|
* $ref: "#/components/schemas/Contacts"
|
||||||
* 400:
|
* 400:
|
||||||
* description: Invalid ID supplied
|
* description: Invalid ID supplied
|
||||||
* 401:
|
* 401:
|
||||||
@ -421,7 +430,7 @@ router.get('/autocomplete', async (req, res) => {
|
|||||||
* description: Some server error
|
* description: Some server error
|
||||||
*/
|
*/
|
||||||
router.get('/:id', wrapAsync(async (req, res) => {
|
router.get('/:id', wrapAsync(async (req, res) => {
|
||||||
const payload = await ProgressDBApi.findBy(
|
const payload = await ContactsDBApi.findBy(
|
||||||
{ id: req.params.id },
|
{ 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 express = require('express');
|
||||||
|
|
||||||
const CoursesService = require('../services/courses');
|
const LeadsService = require('../services/leads');
|
||||||
const CoursesDBApi = require('../db/api/courses');
|
const LeadsDBApi = require('../db/api/leads');
|
||||||
const wrapAsync = require('../helpers').wrapAsync;
|
const wrapAsync = require('../helpers').wrapAsync;
|
||||||
|
|
||||||
|
|
||||||
@ -15,29 +15,35 @@ const {
|
|||||||
checkCrudPermissions,
|
checkCrudPermissions,
|
||||||
} = require('../middlewares/check-permissions');
|
} = require('../middlewares/check-permissions');
|
||||||
|
|
||||||
router.use(checkCrudPermissions('courses'));
|
router.use(checkCrudPermissions('leads'));
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* components:
|
* components:
|
||||||
* schemas:
|
* schemas:
|
||||||
* Courses:
|
* Leads:
|
||||||
* type: object
|
* type: object
|
||||||
* properties:
|
* properties:
|
||||||
|
|
||||||
* title:
|
* name:
|
||||||
* type: string
|
* type: string
|
||||||
* default: title
|
* default: name
|
||||||
* description:
|
* company:
|
||||||
* type: string
|
* type: string
|
||||||
* default: description
|
* default: company
|
||||||
* language:
|
* email:
|
||||||
* type: string
|
* type: string
|
||||||
* default: language
|
* default: email
|
||||||
|
* phone:
|
||||||
|
* type: string
|
||||||
|
* default: phone
|
||||||
|
* notes:
|
||||||
|
* type: string
|
||||||
|
* default: notes
|
||||||
|
|
||||||
|
|
||||||
* price:
|
* estimated_value:
|
||||||
* type: integer
|
* type: integer
|
||||||
* format: int64
|
* format: int64
|
||||||
|
|
||||||
@ -48,17 +54,17 @@ router.use(checkCrudPermissions('courses'));
|
|||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* tags:
|
* tags:
|
||||||
* name: Courses
|
* name: Leads
|
||||||
* description: The Courses managing API
|
* description: The Leads managing API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/courses:
|
* /api/leads:
|
||||||
* post:
|
* post:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Courses]
|
* tags: [Leads]
|
||||||
* summary: Add new item
|
* summary: Add new item
|
||||||
* description: Add new item
|
* description: Add new item
|
||||||
* requestBody:
|
* requestBody:
|
||||||
@ -70,14 +76,14 @@ router.use(checkCrudPermissions('courses'));
|
|||||||
* data:
|
* data:
|
||||||
* description: Data of the updated item
|
* description: Data of the updated item
|
||||||
* type: object
|
* type: object
|
||||||
* $ref: "#/components/schemas/Courses"
|
* $ref: "#/components/schemas/Leads"
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: The item was successfully added
|
* description: The item was successfully added
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Courses"
|
* $ref: "#/components/schemas/Leads"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 405:
|
* 405:
|
||||||
@ -88,7 +94,7 @@ router.use(checkCrudPermissions('courses'));
|
|||||||
router.post('/', wrapAsync(async (req, res) => {
|
router.post('/', wrapAsync(async (req, res) => {
|
||||||
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
||||||
const link = new URL(referer);
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
@ -99,7 +105,7 @@ router.post('/', wrapAsync(async (req, res) => {
|
|||||||
* post:
|
* post:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Courses]
|
* tags: [Leads]
|
||||||
* summary: Bulk import items
|
* summary: Bulk import items
|
||||||
* description: Bulk import items
|
* description: Bulk import items
|
||||||
* requestBody:
|
* requestBody:
|
||||||
@ -112,14 +118,14 @@ router.post('/', wrapAsync(async (req, res) => {
|
|||||||
* description: Data of the updated items
|
* description: Data of the updated items
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/Courses"
|
* $ref: "#/components/schemas/Leads"
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: The items were successfully imported
|
* description: The items were successfully imported
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Courses"
|
* $ref: "#/components/schemas/Leads"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 405:
|
* 405:
|
||||||
@ -131,18 +137,18 @@ router.post('/', wrapAsync(async (req, res) => {
|
|||||||
router.post('/bulk-import', wrapAsync(async (req, res) => {
|
router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||||
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
||||||
const link = new URL(referer);
|
const link = new URL(referer);
|
||||||
await CoursesService.bulkImport(req, res, true, link.host);
|
await LeadsService.bulkImport(req, res, true, link.host);
|
||||||
const payload = true;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/courses/{id}:
|
* /api/leads/{id}:
|
||||||
* put:
|
* put:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Courses]
|
* tags: [Leads]
|
||||||
* summary: Update the data of the selected item
|
* summary: Update the data of the selected item
|
||||||
* description: Update the data of the selected item
|
* description: Update the data of the selected item
|
||||||
* parameters:
|
* parameters:
|
||||||
@ -165,7 +171,7 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
|||||||
* data:
|
* data:
|
||||||
* description: Data of the updated item
|
* description: Data of the updated item
|
||||||
* type: object
|
* type: object
|
||||||
* $ref: "#/components/schemas/Courses"
|
* $ref: "#/components/schemas/Leads"
|
||||||
* required:
|
* required:
|
||||||
* - id
|
* - id
|
||||||
* responses:
|
* responses:
|
||||||
@ -174,7 +180,7 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Courses"
|
* $ref: "#/components/schemas/Leads"
|
||||||
* 400:
|
* 400:
|
||||||
* description: Invalid ID supplied
|
* description: Invalid ID supplied
|
||||||
* 401:
|
* 401:
|
||||||
@ -185,18 +191,18 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
|||||||
* description: Some server error
|
* description: Some server error
|
||||||
*/
|
*/
|
||||||
router.put('/:id', wrapAsync(async (req, res) => {
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/courses/{id}:
|
* /api/leads/{id}:
|
||||||
* delete:
|
* delete:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Courses]
|
* tags: [Leads]
|
||||||
* summary: Delete the selected item
|
* summary: Delete the selected item
|
||||||
* description: Delete the selected item
|
* description: Delete the selected item
|
||||||
* parameters:
|
* parameters:
|
||||||
@ -212,7 +218,7 @@ router.put('/:id', wrapAsync(async (req, res) => {
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Courses"
|
* $ref: "#/components/schemas/Leads"
|
||||||
* 400:
|
* 400:
|
||||||
* description: Invalid ID supplied
|
* description: Invalid ID supplied
|
||||||
* 401:
|
* 401:
|
||||||
@ -223,18 +229,18 @@ router.put('/:id', wrapAsync(async (req, res) => {
|
|||||||
* description: Some server error
|
* description: Some server error
|
||||||
*/
|
*/
|
||||||
router.delete('/:id', wrapAsync(async (req, res) => {
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/courses/deleteByIds:
|
* /api/leads/deleteByIds:
|
||||||
* post:
|
* post:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Courses]
|
* tags: [Leads]
|
||||||
* summary: Delete the selected item list
|
* summary: Delete the selected item list
|
||||||
* description: Delete the selected item list
|
* description: Delete the selected item list
|
||||||
* requestBody:
|
* requestBody:
|
||||||
@ -252,7 +258,7 @@ router.delete('/:id', wrapAsync(async (req, res) => {
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Courses"
|
* $ref: "#/components/schemas/Leads"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 404:
|
* 404:
|
||||||
@ -261,29 +267,29 @@ router.delete('/:id', wrapAsync(async (req, res) => {
|
|||||||
* description: Some server error
|
* description: Some server error
|
||||||
*/
|
*/
|
||||||
router.post('/deleteByIds', wrapAsync(async (req, res) => {
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/courses:
|
* /api/leads:
|
||||||
* get:
|
* get:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Courses]
|
* tags: [Leads]
|
||||||
* summary: Get all courses
|
* summary: Get all leads
|
||||||
* description: Get all courses
|
* description: Get all leads
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Courses list successfully received
|
* description: Leads list successfully received
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/Courses"
|
* $ref: "#/components/schemas/Leads"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 404:
|
* 404:
|
||||||
@ -295,14 +301,14 @@ router.get('/', wrapAsync(async (req, res) => {
|
|||||||
const filetype = req.query.filetype
|
const filetype = req.query.filetype
|
||||||
|
|
||||||
const currentUser = req.currentUser;
|
const currentUser = req.currentUser;
|
||||||
const payload = await CoursesDBApi.findAll(
|
const payload = await LeadsDBApi.findAll(
|
||||||
req.query, { currentUser }
|
req.query, { currentUser }
|
||||||
);
|
);
|
||||||
if (filetype && filetype === 'csv') {
|
if (filetype && filetype === 'csv') {
|
||||||
const fields = ['id','title','description','language',
|
const fields = ['id','name','company','email','phone','notes',
|
||||||
|
|
||||||
|
'estimated_value',
|
||||||
|
|
||||||
'price',
|
|
||||||
'start_date','end_date',
|
|
||||||
];
|
];
|
||||||
const opts = { fields };
|
const opts = { fields };
|
||||||
try {
|
try {
|
||||||
@ -321,22 +327,22 @@ router.get('/', wrapAsync(async (req, res) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/courses/count:
|
* /api/leads/count:
|
||||||
* get:
|
* get:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Courses]
|
* tags: [Leads]
|
||||||
* summary: Count all courses
|
* summary: Count all leads
|
||||||
* description: Count all courses
|
* description: Count all leads
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Courses count successfully received
|
* description: Leads count successfully received
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/Courses"
|
* $ref: "#/components/schemas/Leads"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 404:
|
* 404:
|
||||||
@ -347,7 +353,7 @@ router.get('/', wrapAsync(async (req, res) => {
|
|||||||
router.get('/count', wrapAsync(async (req, res) => {
|
router.get('/count', wrapAsync(async (req, res) => {
|
||||||
|
|
||||||
const currentUser = req.currentUser;
|
const currentUser = req.currentUser;
|
||||||
const payload = await CoursesDBApi.findAll(
|
const payload = await LeadsDBApi.findAll(
|
||||||
req.query,
|
req.query,
|
||||||
null,
|
null,
|
||||||
{ countOnly: true, currentUser }
|
{ countOnly: true, currentUser }
|
||||||
@ -358,22 +364,22 @@ router.get('/count', wrapAsync(async (req, res) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/courses/autocomplete:
|
* /api/leads/autocomplete:
|
||||||
* get:
|
* get:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Courses]
|
* tags: [Leads]
|
||||||
* summary: Find all courses that match search criteria
|
* summary: Find all leads that match search criteria
|
||||||
* description: Find all courses that match search criteria
|
* description: Find all leads that match search criteria
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Courses list successfully received
|
* description: Leads list successfully received
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/Courses"
|
* $ref: "#/components/schemas/Leads"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 404:
|
* 404:
|
||||||
@ -383,7 +389,7 @@ router.get('/count', wrapAsync(async (req, res) => {
|
|||||||
*/
|
*/
|
||||||
router.get('/autocomplete', async (req, res) => {
|
router.get('/autocomplete', async (req, res) => {
|
||||||
|
|
||||||
const payload = await CoursesDBApi.findAllAutocomplete(
|
const payload = await LeadsDBApi.findAllAutocomplete(
|
||||||
req.query.query,
|
req.query.query,
|
||||||
req.query.limit,
|
req.query.limit,
|
||||||
req.query.offset,
|
req.query.offset,
|
||||||
@ -395,11 +401,11 @@ router.get('/autocomplete', async (req, res) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/courses/{id}:
|
* /api/leads/{id}:
|
||||||
* get:
|
* get:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Courses]
|
* tags: [Leads]
|
||||||
* summary: Get selected item
|
* summary: Get selected item
|
||||||
* description: Get selected item
|
* description: Get selected item
|
||||||
* parameters:
|
* parameters:
|
||||||
@ -415,7 +421,7 @@ router.get('/autocomplete', async (req, res) => {
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Courses"
|
* $ref: "#/components/schemas/Leads"
|
||||||
* 400:
|
* 400:
|
||||||
* description: Invalid ID supplied
|
* description: Invalid ID supplied
|
||||||
* 401:
|
* 401:
|
||||||
@ -426,7 +432,7 @@ router.get('/autocomplete', async (req, res) => {
|
|||||||
* description: Some server error
|
* description: Some server error
|
||||||
*/
|
*/
|
||||||
router.get('/:id', wrapAsync(async (req, res) => {
|
router.get('/:id', wrapAsync(async (req, res) => {
|
||||||
const payload = await CoursesDBApi.findBy(
|
const payload = await LeadsDBApi.findBy(
|
||||||
{ id: req.params.id },
|
{ id: req.params.id },
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
|
|
||||||
const EnrollmentsService = require('../services/enrollments');
|
const Pipeline_stagesService = require('../services/pipeline_stages');
|
||||||
const EnrollmentsDBApi = require('../db/api/enrollments');
|
const Pipeline_stagesDBApi = require('../db/api/pipeline_stages');
|
||||||
const wrapAsync = require('../helpers').wrapAsync;
|
const wrapAsync = require('../helpers').wrapAsync;
|
||||||
|
|
||||||
|
|
||||||
@ -15,46 +15,45 @@ const {
|
|||||||
checkCrudPermissions,
|
checkCrudPermissions,
|
||||||
} = require('../middlewares/check-permissions');
|
} = require('../middlewares/check-permissions');
|
||||||
|
|
||||||
router.use(checkCrudPermissions('enrollments'));
|
router.use(checkCrudPermissions('pipeline_stages'));
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* components:
|
* components:
|
||||||
* schemas:
|
* schemas:
|
||||||
* Enrollments:
|
* Pipeline_stages:
|
||||||
* type: object
|
* type: object
|
||||||
* properties:
|
* properties:
|
||||||
|
|
||||||
* enrollment_label:
|
* title:
|
||||||
* type: string
|
* type: string
|
||||||
* default: enrollment_label
|
* default: title
|
||||||
|
|
||||||
|
* order:
|
||||||
* progress_percent:
|
|
||||||
* type: integer
|
* type: integer
|
||||||
* format: int64
|
* format: int64
|
||||||
* price_paid:
|
* probability:
|
||||||
* type: integer
|
* type: integer
|
||||||
* format: int64
|
* format: int64
|
||||||
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* tags:
|
* tags:
|
||||||
* name: Enrollments
|
* name: Pipeline_stages
|
||||||
* description: The Enrollments managing API
|
* description: The Pipeline_stages managing API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/enrollments:
|
* /api/pipeline_stages:
|
||||||
* post:
|
* post:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Enrollments]
|
* tags: [Pipeline_stages]
|
||||||
* summary: Add new item
|
* summary: Add new item
|
||||||
* description: Add new item
|
* description: Add new item
|
||||||
* requestBody:
|
* requestBody:
|
||||||
@ -66,14 +65,14 @@ router.use(checkCrudPermissions('enrollments'));
|
|||||||
* data:
|
* data:
|
||||||
* description: Data of the updated item
|
* description: Data of the updated item
|
||||||
* type: object
|
* type: object
|
||||||
* $ref: "#/components/schemas/Enrollments"
|
* $ref: "#/components/schemas/Pipeline_stages"
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: The item was successfully added
|
* description: The item was successfully added
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Enrollments"
|
* $ref: "#/components/schemas/Pipeline_stages"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 405:
|
* 405:
|
||||||
@ -84,7 +83,7 @@ router.use(checkCrudPermissions('enrollments'));
|
|||||||
router.post('/', wrapAsync(async (req, res) => {
|
router.post('/', wrapAsync(async (req, res) => {
|
||||||
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
||||||
const link = new URL(referer);
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
@ -95,7 +94,7 @@ router.post('/', wrapAsync(async (req, res) => {
|
|||||||
* post:
|
* post:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Enrollments]
|
* tags: [Pipeline_stages]
|
||||||
* summary: Bulk import items
|
* summary: Bulk import items
|
||||||
* description: Bulk import items
|
* description: Bulk import items
|
||||||
* requestBody:
|
* requestBody:
|
||||||
@ -108,14 +107,14 @@ router.post('/', wrapAsync(async (req, res) => {
|
|||||||
* description: Data of the updated items
|
* description: Data of the updated items
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/Enrollments"
|
* $ref: "#/components/schemas/Pipeline_stages"
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: The items were successfully imported
|
* description: The items were successfully imported
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Enrollments"
|
* $ref: "#/components/schemas/Pipeline_stages"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 405:
|
* 405:
|
||||||
@ -127,18 +126,18 @@ router.post('/', wrapAsync(async (req, res) => {
|
|||||||
router.post('/bulk-import', wrapAsync(async (req, res) => {
|
router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||||
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
||||||
const link = new URL(referer);
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/enrollments/{id}:
|
* /api/pipeline_stages/{id}:
|
||||||
* put:
|
* put:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Enrollments]
|
* tags: [Pipeline_stages]
|
||||||
* summary: Update the data of the selected item
|
* summary: Update the data of the selected item
|
||||||
* description: Update the data of the selected item
|
* description: Update the data of the selected item
|
||||||
* parameters:
|
* parameters:
|
||||||
@ -161,7 +160,7 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
|||||||
* data:
|
* data:
|
||||||
* description: Data of the updated item
|
* description: Data of the updated item
|
||||||
* type: object
|
* type: object
|
||||||
* $ref: "#/components/schemas/Enrollments"
|
* $ref: "#/components/schemas/Pipeline_stages"
|
||||||
* required:
|
* required:
|
||||||
* - id
|
* - id
|
||||||
* responses:
|
* responses:
|
||||||
@ -170,7 +169,7 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Enrollments"
|
* $ref: "#/components/schemas/Pipeline_stages"
|
||||||
* 400:
|
* 400:
|
||||||
* description: Invalid ID supplied
|
* description: Invalid ID supplied
|
||||||
* 401:
|
* 401:
|
||||||
@ -181,18 +180,18 @@ router.post('/bulk-import', wrapAsync(async (req, res) => {
|
|||||||
* description: Some server error
|
* description: Some server error
|
||||||
*/
|
*/
|
||||||
router.put('/:id', wrapAsync(async (req, res) => {
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/enrollments/{id}:
|
* /api/pipeline_stages/{id}:
|
||||||
* delete:
|
* delete:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Enrollments]
|
* tags: [Pipeline_stages]
|
||||||
* summary: Delete the selected item
|
* summary: Delete the selected item
|
||||||
* description: Delete the selected item
|
* description: Delete the selected item
|
||||||
* parameters:
|
* parameters:
|
||||||
@ -208,7 +207,7 @@ router.put('/:id', wrapAsync(async (req, res) => {
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Enrollments"
|
* $ref: "#/components/schemas/Pipeline_stages"
|
||||||
* 400:
|
* 400:
|
||||||
* description: Invalid ID supplied
|
* description: Invalid ID supplied
|
||||||
* 401:
|
* 401:
|
||||||
@ -219,18 +218,18 @@ router.put('/:id', wrapAsync(async (req, res) => {
|
|||||||
* description: Some server error
|
* description: Some server error
|
||||||
*/
|
*/
|
||||||
router.delete('/:id', wrapAsync(async (req, res) => {
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/enrollments/deleteByIds:
|
* /api/pipeline_stages/deleteByIds:
|
||||||
* post:
|
* post:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Enrollments]
|
* tags: [Pipeline_stages]
|
||||||
* summary: Delete the selected item list
|
* summary: Delete the selected item list
|
||||||
* description: Delete the selected item list
|
* description: Delete the selected item list
|
||||||
* requestBody:
|
* requestBody:
|
||||||
@ -248,7 +247,7 @@ router.delete('/:id', wrapAsync(async (req, res) => {
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Enrollments"
|
* $ref: "#/components/schemas/Pipeline_stages"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 404:
|
* 404:
|
||||||
@ -257,29 +256,29 @@ router.delete('/:id', wrapAsync(async (req, res) => {
|
|||||||
* description: Some server error
|
* description: Some server error
|
||||||
*/
|
*/
|
||||||
router.post('/deleteByIds', wrapAsync(async (req, res) => {
|
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;
|
const payload = true;
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/enrollments:
|
* /api/pipeline_stages:
|
||||||
* get:
|
* get:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Enrollments]
|
* tags: [Pipeline_stages]
|
||||||
* summary: Get all enrollments
|
* summary: Get all pipeline_stages
|
||||||
* description: Get all enrollments
|
* description: Get all pipeline_stages
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Enrollments list successfully received
|
* description: Pipeline_stages list successfully received
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/Enrollments"
|
* $ref: "#/components/schemas/Pipeline_stages"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 404:
|
* 404:
|
||||||
@ -291,14 +290,14 @@ router.get('/', wrapAsync(async (req, res) => {
|
|||||||
const filetype = req.query.filetype
|
const filetype = req.query.filetype
|
||||||
|
|
||||||
const currentUser = req.currentUser;
|
const currentUser = req.currentUser;
|
||||||
const payload = await EnrollmentsDBApi.findAll(
|
const payload = await Pipeline_stagesDBApi.findAll(
|
||||||
req.query, { currentUser }
|
req.query, { currentUser }
|
||||||
);
|
);
|
||||||
if (filetype && filetype === 'csv') {
|
if (filetype && filetype === 'csv') {
|
||||||
const fields = ['id','enrollment_label',
|
const fields = ['id','title',
|
||||||
|
'order','probability',
|
||||||
|
|
||||||
|
|
||||||
'progress_percent','price_paid',
|
|
||||||
'enrolled_at',
|
|
||||||
];
|
];
|
||||||
const opts = { fields };
|
const opts = { fields };
|
||||||
try {
|
try {
|
||||||
@ -317,22 +316,22 @@ router.get('/', wrapAsync(async (req, res) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/enrollments/count:
|
* /api/pipeline_stages/count:
|
||||||
* get:
|
* get:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Enrollments]
|
* tags: [Pipeline_stages]
|
||||||
* summary: Count all enrollments
|
* summary: Count all pipeline_stages
|
||||||
* description: Count all enrollments
|
* description: Count all pipeline_stages
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Enrollments count successfully received
|
* description: Pipeline_stages count successfully received
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/Enrollments"
|
* $ref: "#/components/schemas/Pipeline_stages"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 404:
|
* 404:
|
||||||
@ -343,7 +342,7 @@ router.get('/', wrapAsync(async (req, res) => {
|
|||||||
router.get('/count', wrapAsync(async (req, res) => {
|
router.get('/count', wrapAsync(async (req, res) => {
|
||||||
|
|
||||||
const currentUser = req.currentUser;
|
const currentUser = req.currentUser;
|
||||||
const payload = await EnrollmentsDBApi.findAll(
|
const payload = await Pipeline_stagesDBApi.findAll(
|
||||||
req.query,
|
req.query,
|
||||||
null,
|
null,
|
||||||
{ countOnly: true, currentUser }
|
{ countOnly: true, currentUser }
|
||||||
@ -354,22 +353,22 @@ router.get('/count', wrapAsync(async (req, res) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/enrollments/autocomplete:
|
* /api/pipeline_stages/autocomplete:
|
||||||
* get:
|
* get:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Enrollments]
|
* tags: [Pipeline_stages]
|
||||||
* summary: Find all enrollments that match search criteria
|
* summary: Find all pipeline_stages that match search criteria
|
||||||
* description: Find all enrollments that match search criteria
|
* description: Find all pipeline_stages that match search criteria
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Enrollments list successfully received
|
* description: Pipeline_stages list successfully received
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/Enrollments"
|
* $ref: "#/components/schemas/Pipeline_stages"
|
||||||
* 401:
|
* 401:
|
||||||
* $ref: "#/components/responses/UnauthorizedError"
|
* $ref: "#/components/responses/UnauthorizedError"
|
||||||
* 404:
|
* 404:
|
||||||
@ -379,7 +378,7 @@ router.get('/count', wrapAsync(async (req, res) => {
|
|||||||
*/
|
*/
|
||||||
router.get('/autocomplete', 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.query,
|
||||||
req.query.limit,
|
req.query.limit,
|
||||||
req.query.offset,
|
req.query.offset,
|
||||||
@ -391,11 +390,11 @@ router.get('/autocomplete', async (req, res) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/enrollments/{id}:
|
* /api/pipeline_stages/{id}:
|
||||||
* get:
|
* get:
|
||||||
* security:
|
* security:
|
||||||
* - bearerAuth: []
|
* - bearerAuth: []
|
||||||
* tags: [Enrollments]
|
* tags: [Pipeline_stages]
|
||||||
* summary: Get selected item
|
* summary: Get selected item
|
||||||
* description: Get selected item
|
* description: Get selected item
|
||||||
* parameters:
|
* parameters:
|
||||||
@ -411,7 +410,7 @@ router.get('/autocomplete', async (req, res) => {
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/Enrollments"
|
* $ref: "#/components/schemas/Pipeline_stages"
|
||||||
* 400:
|
* 400:
|
||||||
* description: Invalid ID supplied
|
* description: Invalid ID supplied
|
||||||
* 401:
|
* 401:
|
||||||
@ -422,7 +421,7 @@ router.get('/autocomplete', async (req, res) => {
|
|||||||
* description: Some server error
|
* description: Some server error
|
||||||
*/
|
*/
|
||||||
router.get('/:id', wrapAsync(async (req, res) => {
|
router.get('/:id', wrapAsync(async (req, res) => {
|
||||||
const payload = await EnrollmentsDBApi.findBy(
|
const payload = await Pipeline_stagesDBApi.findBy(
|
||||||
{ id: req.params.id },
|
{ 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 db = require('../db/models');
|
||||||
const EnrollmentsDBApi = require('../db/api/enrollments');
|
const ActivitiesDBApi = require('../db/api/activities');
|
||||||
const processFile = require("../middlewares/upload");
|
const processFile = require("../middlewares/upload");
|
||||||
const ValidationError = require('./notifications/errors/validation');
|
const ValidationError = require('./notifications/errors/validation');
|
||||||
const csv = require('csv-parser');
|
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) {
|
static async create(data, currentUser) {
|
||||||
const transaction = await db.sequelize.transaction();
|
const transaction = await db.sequelize.transaction();
|
||||||
try {
|
try {
|
||||||
await EnrollmentsDBApi.create(
|
await ActivitiesDBApi.create(
|
||||||
data,
|
data,
|
||||||
{
|
{
|
||||||
currentUser,
|
currentUser,
|
||||||
@ -51,7 +51,7 @@ module.exports = class EnrollmentsService {
|
|||||||
.on('error', (error) => reject(error));
|
.on('error', (error) => reject(error));
|
||||||
})
|
})
|
||||||
|
|
||||||
await EnrollmentsDBApi.bulkImport(results, {
|
await ActivitiesDBApi.bulkImport(results, {
|
||||||
transaction,
|
transaction,
|
||||||
ignoreDuplicates: true,
|
ignoreDuplicates: true,
|
||||||
validate: true,
|
validate: true,
|
||||||
@ -68,18 +68,18 @@ module.exports = class EnrollmentsService {
|
|||||||
static async update(data, id, currentUser) {
|
static async update(data, id, currentUser) {
|
||||||
const transaction = await db.sequelize.transaction();
|
const transaction = await db.sequelize.transaction();
|
||||||
try {
|
try {
|
||||||
let enrollments = await EnrollmentsDBApi.findBy(
|
let activities = await ActivitiesDBApi.findBy(
|
||||||
{id},
|
{id},
|
||||||
{transaction},
|
{transaction},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!enrollments) {
|
if (!activities) {
|
||||||
throw new ValidationError(
|
throw new ValidationError(
|
||||||
'enrollmentsNotFound',
|
'activitiesNotFound',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedEnrollments = await EnrollmentsDBApi.update(
|
const updatedActivities = await ActivitiesDBApi.update(
|
||||||
id,
|
id,
|
||||||
data,
|
data,
|
||||||
{
|
{
|
||||||
@ -89,7 +89,7 @@ module.exports = class EnrollmentsService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await transaction.commit();
|
await transaction.commit();
|
||||||
return updatedEnrollments;
|
return updatedActivities;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await transaction.rollback();
|
await transaction.rollback();
|
||||||
@ -101,7 +101,7 @@ module.exports = class EnrollmentsService {
|
|||||||
const transaction = await db.sequelize.transaction();
|
const transaction = await db.sequelize.transaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await EnrollmentsDBApi.deleteByIds(ids, {
|
await ActivitiesDBApi.deleteByIds(ids, {
|
||||||
currentUser,
|
currentUser,
|
||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
@ -117,7 +117,7 @@ module.exports = class EnrollmentsService {
|
|||||||
const transaction = await db.sequelize.transaction();
|
const transaction = await db.sequelize.transaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await EnrollmentsDBApi.remove(
|
await ActivitiesDBApi.remove(
|
||||||
id,
|
id,
|
||||||
{
|
{
|
||||||
currentUser,
|
currentUser,
|
||||||
@ -1,5 +1,5 @@
|
|||||||
const db = require('../db/models');
|
const db = require('../db/models');
|
||||||
const ProgressDBApi = require('../db/api/progress');
|
const ContactsDBApi = require('../db/api/contacts');
|
||||||
const processFile = require("../middlewares/upload");
|
const processFile = require("../middlewares/upload");
|
||||||
const ValidationError = require('./notifications/errors/validation');
|
const ValidationError = require('./notifications/errors/validation');
|
||||||
const csv = require('csv-parser');
|
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) {
|
static async create(data, currentUser) {
|
||||||
const transaction = await db.sequelize.transaction();
|
const transaction = await db.sequelize.transaction();
|
||||||
try {
|
try {
|
||||||
await ProgressDBApi.create(
|
await ContactsDBApi.create(
|
||||||
data,
|
data,
|
||||||
{
|
{
|
||||||
currentUser,
|
currentUser,
|
||||||
@ -51,7 +51,7 @@ module.exports = class ProgressService {
|
|||||||
.on('error', (error) => reject(error));
|
.on('error', (error) => reject(error));
|
||||||
})
|
})
|
||||||
|
|
||||||
await ProgressDBApi.bulkImport(results, {
|
await ContactsDBApi.bulkImport(results, {
|
||||||
transaction,
|
transaction,
|
||||||
ignoreDuplicates: true,
|
ignoreDuplicates: true,
|
||||||
validate: true,
|
validate: true,
|
||||||
@ -68,18 +68,18 @@ module.exports = class ProgressService {
|
|||||||
static async update(data, id, currentUser) {
|
static async update(data, id, currentUser) {
|
||||||
const transaction = await db.sequelize.transaction();
|
const transaction = await db.sequelize.transaction();
|
||||||
try {
|
try {
|
||||||
let progress = await ProgressDBApi.findBy(
|
let contacts = await ContactsDBApi.findBy(
|
||||||
{id},
|
{id},
|
||||||
{transaction},
|
{transaction},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!progress) {
|
if (!contacts) {
|
||||||
throw new ValidationError(
|
throw new ValidationError(
|
||||||
'progressNotFound',
|
'contactsNotFound',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedProgress = await ProgressDBApi.update(
|
const updatedContacts = await ContactsDBApi.update(
|
||||||
id,
|
id,
|
||||||
data,
|
data,
|
||||||
{
|
{
|
||||||
@ -89,7 +89,7 @@ module.exports = class ProgressService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await transaction.commit();
|
await transaction.commit();
|
||||||
return updatedProgress;
|
return updatedContacts;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await transaction.rollback();
|
await transaction.rollback();
|
||||||
@ -101,7 +101,7 @@ module.exports = class ProgressService {
|
|||||||
const transaction = await db.sequelize.transaction();
|
const transaction = await db.sequelize.transaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ProgressDBApi.deleteByIds(ids, {
|
await ContactsDBApi.deleteByIds(ids, {
|
||||||
currentUser,
|
currentUser,
|
||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
@ -117,7 +117,7 @@ module.exports = class ProgressService {
|
|||||||
const transaction = await db.sequelize.transaction();
|
const transaction = await db.sequelize.transaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ProgressDBApi.remove(
|
await ContactsDBApi.remove(
|
||||||
id,
|
id,
|
||||||
{
|
{
|
||||||
currentUser,
|
currentUser,
|
||||||
@ -1,5 +1,5 @@
|
|||||||
const db = require('../db/models');
|
const db = require('../db/models');
|
||||||
const CoursesDBApi = require('../db/api/courses');
|
const DealsDBApi = require('../db/api/deals');
|
||||||
const processFile = require("../middlewares/upload");
|
const processFile = require("../middlewares/upload");
|
||||||
const ValidationError = require('./notifications/errors/validation');
|
const ValidationError = require('./notifications/errors/validation');
|
||||||
const csv = require('csv-parser');
|
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) {
|
static async create(data, currentUser) {
|
||||||
const transaction = await db.sequelize.transaction();
|
const transaction = await db.sequelize.transaction();
|
||||||
try {
|
try {
|
||||||
await CoursesDBApi.create(
|
await DealsDBApi.create(
|
||||||
data,
|
data,
|
||||||
{
|
{
|
||||||
currentUser,
|
currentUser,
|
||||||
@ -51,7 +51,7 @@ module.exports = class CoursesService {
|
|||||||
.on('error', (error) => reject(error));
|
.on('error', (error) => reject(error));
|
||||||
})
|
})
|
||||||
|
|
||||||
await CoursesDBApi.bulkImport(results, {
|
await DealsDBApi.bulkImport(results, {
|
||||||
transaction,
|
transaction,
|
||||||
ignoreDuplicates: true,
|
ignoreDuplicates: true,
|
||||||
validate: true,
|
validate: true,
|
||||||
@ -68,18 +68,18 @@ module.exports = class CoursesService {
|
|||||||
static async update(data, id, currentUser) {
|
static async update(data, id, currentUser) {
|
||||||
const transaction = await db.sequelize.transaction();
|
const transaction = await db.sequelize.transaction();
|
||||||
try {
|
try {
|
||||||
let courses = await CoursesDBApi.findBy(
|
let deals = await DealsDBApi.findBy(
|
||||||
{id},
|
{id},
|
||||||
{transaction},
|
{transaction},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!courses) {
|
if (!deals) {
|
||||||
throw new ValidationError(
|
throw new ValidationError(
|
||||||
'coursesNotFound',
|
'dealsNotFound',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedCourses = await CoursesDBApi.update(
|
const updatedDeals = await DealsDBApi.update(
|
||||||
id,
|
id,
|
||||||
data,
|
data,
|
||||||
{
|
{
|
||||||
@ -89,7 +89,7 @@ module.exports = class CoursesService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await transaction.commit();
|
await transaction.commit();
|
||||||
return updatedCourses;
|
return updatedDeals;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await transaction.rollback();
|
await transaction.rollback();
|
||||||
@ -101,7 +101,7 @@ module.exports = class CoursesService {
|
|||||||
const transaction = await db.sequelize.transaction();
|
const transaction = await db.sequelize.transaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await CoursesDBApi.deleteByIds(ids, {
|
await DealsDBApi.deleteByIds(ids, {
|
||||||
currentUser,
|
currentUser,
|
||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
@ -117,7 +117,7 @@ module.exports = class CoursesService {
|
|||||||
const transaction = await db.sequelize.transaction();
|
const transaction = await db.sequelize.transaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await CoursesDBApi.remove(
|
await DealsDBApi.remove(
|
||||||
id,
|
id,
|
||||||
{
|
{
|
||||||
currentUser,
|
currentUser,
|
||||||
@ -1,5 +1,5 @@
|
|||||||
const db = require('../db/models');
|
const db = require('../db/models');
|
||||||
const LessonsDBApi = require('../db/api/lessons');
|
const LeadsDBApi = require('../db/api/leads');
|
||||||
const processFile = require("../middlewares/upload");
|
const processFile = require("../middlewares/upload");
|
||||||
const ValidationError = require('./notifications/errors/validation');
|
const ValidationError = require('./notifications/errors/validation');
|
||||||
const csv = require('csv-parser');
|
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) {
|
static async create(data, currentUser) {
|
||||||
const transaction = await db.sequelize.transaction();
|
const transaction = await db.sequelize.transaction();
|
||||||
try {
|
try {
|
||||||
await LessonsDBApi.create(
|
await LeadsDBApi.create(
|
||||||
data,
|
data,
|
||||||
{
|
{
|
||||||
currentUser,
|
currentUser,
|
||||||
@ -51,7 +51,7 @@ module.exports = class LessonsService {
|
|||||||
.on('error', (error) => reject(error));
|
.on('error', (error) => reject(error));
|
||||||
})
|
})
|
||||||
|
|
||||||
await LessonsDBApi.bulkImport(results, {
|
await LeadsDBApi.bulkImport(results, {
|
||||||
transaction,
|
transaction,
|
||||||
ignoreDuplicates: true,
|
ignoreDuplicates: true,
|
||||||
validate: true,
|
validate: true,
|
||||||
@ -68,18 +68,18 @@ module.exports = class LessonsService {
|
|||||||
static async update(data, id, currentUser) {
|
static async update(data, id, currentUser) {
|
||||||
const transaction = await db.sequelize.transaction();
|
const transaction = await db.sequelize.transaction();
|
||||||
try {
|
try {
|
||||||
let lessons = await LessonsDBApi.findBy(
|
let leads = await LeadsDBApi.findBy(
|
||||||
{id},
|
{id},
|
||||||
{transaction},
|
{transaction},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!lessons) {
|
if (!leads) {
|
||||||
throw new ValidationError(
|
throw new ValidationError(
|
||||||
'lessonsNotFound',
|
'leadsNotFound',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedLessons = await LessonsDBApi.update(
|
const updatedLeads = await LeadsDBApi.update(
|
||||||
id,
|
id,
|
||||||
data,
|
data,
|
||||||
{
|
{
|
||||||
@ -89,7 +89,7 @@ module.exports = class LessonsService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await transaction.commit();
|
await transaction.commit();
|
||||||
return updatedLessons;
|
return updatedLeads;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await transaction.rollback();
|
await transaction.rollback();
|
||||||
@ -101,7 +101,7 @@ module.exports = class LessonsService {
|
|||||||
const transaction = await db.sequelize.transaction();
|
const transaction = await db.sequelize.transaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await LessonsDBApi.deleteByIds(ids, {
|
await LeadsDBApi.deleteByIds(ids, {
|
||||||
currentUser,
|
currentUser,
|
||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
@ -117,7 +117,7 @@ module.exports = class LessonsService {
|
|||||||
const transaction = await db.sequelize.transaction();
|
const transaction = await db.sequelize.transaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await LessonsDBApi.remove(
|
await LeadsDBApi.remove(
|
||||||
id,
|
id,
|
||||||
{
|
{
|
||||||
currentUser,
|
currentUser,
|
||||||
@ -1,6 +1,6 @@
|
|||||||
const errors = {
|
const errors = {
|
||||||
app: {
|
app: {
|
||||||
title: 'Instructor-Student LMS',
|
title: 'Sales Pipeline CRM',
|
||||||
},
|
},
|
||||||
|
|
||||||
auth: {
|
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",
|
"title",
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"leads": [
|
||||||
|
|
||||||
|
"name",
|
||||||
|
|
||||||
|
"company",
|
||||||
|
|
||||||
|
"email",
|
||||||
|
|
||||||
|
"phone",
|
||||||
|
|
||||||
|
"notes",
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"contacts": [
|
||||||
|
|
||||||
|
"name",
|
||||||
|
|
||||||
|
"email",
|
||||||
|
|
||||||
|
"phone",
|
||||||
|
|
||||||
|
"title",
|
||||||
|
|
||||||
|
"company",
|
||||||
|
|
||||||
|
"notes",
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"deals": [
|
||||||
|
|
||||||
|
"title",
|
||||||
|
|
||||||
|
"deal_number",
|
||||||
|
|
||||||
|
"currency",
|
||||||
|
|
||||||
"description",
|
"description",
|
||||||
|
|
||||||
"language",
|
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
||||||
@ -81,33 +134,11 @@ module.exports = class SearchService {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
"lessons": [
|
"activities": [
|
||||||
|
|
||||||
"title",
|
"subject",
|
||||||
|
|
||||||
"content",
|
"notes",
|
||||||
|
|
||||||
],
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"enrollments": [
|
|
||||||
|
|
||||||
"enrollment_label",
|
|
||||||
|
|
||||||
],
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"progress": [
|
|
||||||
|
|
||||||
"note",
|
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
@ -124,21 +155,11 @@ module.exports = class SearchService {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
"courses": [
|
"pipeline_stages": [
|
||||||
|
|
||||||
"price",
|
|
||||||
|
|
||||||
],
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"lessons": [
|
|
||||||
|
|
||||||
"order",
|
"order",
|
||||||
|
|
||||||
"duration_minutes",
|
"probability",
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
@ -146,11 +167,9 @@ module.exports = class SearchService {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
"enrollments": [
|
"leads": [
|
||||||
|
|
||||||
"progress_percent",
|
"estimated_value",
|
||||||
|
|
||||||
"price_paid",
|
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
@ -158,15 +177,21 @@ module.exports = class SearchService {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
"progress": [
|
|
||||||
|
|
||||||
"score",
|
|
||||||
|
|
||||||
"attempts",
|
|
||||||
|
|
||||||
|
"deals": [
|
||||||
|
|
||||||
|
"value",
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let allFoundRecords = [];
|
let allFoundRecords = [];
|
||||||
|
|||||||
@ -25,7 +25,7 @@ services:
|
|||||||
- ./data/db:/var/lib/postgresql/data
|
- ./data/db:/var/lib/postgresql/data
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_HOST_AUTH_METHOD=trust
|
- POSTGRES_HOST_AUTH_METHOD=trust
|
||||||
- POSTGRES_DB=db_instructor_student_lms
|
- POSTGRES_DB=db_sales_pipeline_crm
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
logging:
|
logging:
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# Instructor-Student LMS
|
# Sales Pipeline CRM
|
||||||
|
|
||||||
## This project was generated by Flatlogic Platform.
|
## This project was generated by Flatlogic Platform.
|
||||||
## Install
|
## Install
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import {hasPermission} from "../../helpers/userPermissions";
|
|||||||
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
courses: any[];
|
activities: any[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
onDelete: (id: string) => void;
|
onDelete: (id: string) => void;
|
||||||
currentPage: number;
|
currentPage: number;
|
||||||
@ -20,8 +20,8 @@ type Props = {
|
|||||||
onPageChange: (page: number) => void;
|
onPageChange: (page: number) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const CardCourses = ({
|
const CardActivities = ({
|
||||||
courses,
|
activities,
|
||||||
loading,
|
loading,
|
||||||
onDelete,
|
onDelete,
|
||||||
currentPage,
|
currentPage,
|
||||||
@ -37,7 +37,7 @@ const CardCourses = ({
|
|||||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||||
|
|
||||||
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
||||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_COURSES')
|
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_ACTIVITIES')
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -47,7 +47,7 @@ const CardCourses = ({
|
|||||||
role='list'
|
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'
|
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
|
<li
|
||||||
key={item.id}
|
key={item.id}
|
||||||
className={`overflow-hidden ${corners !== 'rounded-full'? corners : 'rounded-3xl'} border ${focusRing} border-gray-200 dark:border-dark-700 ${
|
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
|
<Link href={`/activities/activities-view/?id=${item.id}`} className='text-lg font-bold leading-6 line-clamp-1'>
|
||||||
href={`/courses/courses-view/?id=${item.id}`}
|
{item.subject}
|
||||||
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>
|
</Link>
|
||||||
|
|
||||||
|
|
||||||
<div className='ml-auto md:absolute md:top-0 md:right-0 '>
|
<div className='ml-auto '>
|
||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
itemId={item.id}
|
itemId={item.id}
|
||||||
pathEdit={`/courses/courses-edit/?id=${item.id}`}
|
pathEdit={`/activities/activities-edit/?id=${item.id}`}
|
||||||
pathView={`/courses/courses-view/?id=${item.id}`}
|
pathView={`/activities/activities-view/?id=${item.id}`}
|
||||||
|
|
||||||
hasUpdatePermission={hasUpdatePermission}
|
hasUpdatePermission={hasUpdatePermission}
|
||||||
|
|
||||||
@ -87,10 +78,10 @@ const CardCourses = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ item.title }
|
{ item.subject }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -99,10 +90,10 @@ const CardCourses = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ item.description }
|
{ item.activity_type }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -111,10 +102,10 @@ const CardCourses = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ dataFormatter.usersOneListFormatter(item.instructor) }
|
{ dataFormatter.dateTimeFormatter(item.start) }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -123,10 +114,10 @@ const CardCourses = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ item.category }
|
{ dataFormatter.dateTimeFormatter(item.end) }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -135,10 +126,10 @@ const CardCourses = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ item.level }
|
{ dataFormatter.booleanFormatter(item.completed) }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -147,14 +138,10 @@ const CardCourses = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium'>
|
<div className='font-medium line-clamp-4'>
|
||||||
<ImageField
|
{ dataFormatter.usersOneListFormatter(item.owner) }
|
||||||
name={'Avatar'}
|
|
||||||
image={item.thumbnail}
|
|
||||||
className='mx-auto w-8 h-8'
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -163,10 +150,10 @@ const CardCourses = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ dataFormatter.booleanFormatter(item.published) }
|
{ dataFormatter.dealsOneListFormatter(item.related_deal) }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -175,10 +162,10 @@ const CardCourses = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ dataFormatter.dateTimeFormatter(item.start_date) }
|
{ dataFormatter.leadsOneListFormatter(item.related_lead) }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -187,34 +174,10 @@ const CardCourses = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ dataFormatter.dateTimeFormatter(item.end_date) }
|
{ item.notes }
|
||||||
</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 }
|
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -224,7 +187,7 @@ const CardCourses = ({
|
|||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
{!loading && courses.length === 0 && (
|
{!loading && activities.length === 0 && (
|
||||||
<div className='col-span-full flex items-center justify-center h-40'>
|
<div className='col-span-full flex items-center justify-center h-40'>
|
||||||
<p className=''>No data to display</p>
|
<p className=''>No data to display</p>
|
||||||
</div>
|
</div>
|
||||||
@ -241,4 +204,4 @@ const CardCourses = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CardCourses;
|
export default CardActivities;
|
||||||
@ -13,7 +13,7 @@ import {hasPermission} from "../../helpers/userPermissions";
|
|||||||
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
lessons: any[];
|
activities: any[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
onDelete: (id: string) => void;
|
onDelete: (id: string) => void;
|
||||||
currentPage: number;
|
currentPage: number;
|
||||||
@ -21,10 +21,10 @@ type Props = {
|
|||||||
onPageChange: (page: number) => void;
|
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 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 corners = useAppSelector((state) => state.style.corners);
|
||||||
const bgColor = useAppSelector((state) => state.style.cardsColor);
|
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'>
|
<div className='relative overflow-x-auto p-4 space-y-4'>
|
||||||
{loading && <LoadingSpinner />}
|
{loading && <LoadingSpinner />}
|
||||||
{!loading && lessons.map((item) => (
|
{!loading && activities.map((item) => (
|
||||||
<div key={item.id}>
|
<div key={item.id}>
|
||||||
<CardBox hasTable isList className={'rounded shadow-none'}>
|
<CardBox hasTable isList className={'rounded shadow-none'}>
|
||||||
<div className={`flex rounded dark:bg-dark-900 border border-stone-300 items-center overflow-hidden`}>
|
<div className={`flex rounded dark:bg-dark-900 border border-stone-300 items-center overflow-hidden`}>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
href={`/lessons/lessons-view/?id=${item.id}`}
|
href={`/activities/activities-view/?id=${item.id}`}
|
||||||
className={
|
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'
|
'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'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>Title</p>
|
<p className={'text-xs text-gray-500 '}>Subject</p>
|
||||||
<p className={'line-clamp-2'}>{ item.title }</p>
|
<p className={'line-clamp-2'}>{ item.subject }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>Content</p>
|
<p className={'text-xs text-gray-500 '}>ActivityType</p>
|
||||||
<p className={'line-clamp-2'}>{ item.content }</p>
|
<p className={'line-clamp-2'}>{ item.activity_type }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>Course</p>
|
<p className={'text-xs text-gray-500 '}>Start</p>
|
||||||
<p className={'line-clamp-2'}>{ dataFormatter.coursesOneListFormatter(item.course) }</p>
|
<p className={'line-clamp-2'}>{ dataFormatter.dateTimeFormatter(item.start) }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>Order</p>
|
<p className={'text-xs text-gray-500 '}>End</p>
|
||||||
<p className={'line-clamp-2'}>{ item.order }</p>
|
<p className={'line-clamp-2'}>{ dataFormatter.dateTimeFormatter(item.end) }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>Duration(minutes)</p>
|
<p className={'text-xs text-gray-500 '}>Completed</p>
|
||||||
<p className={'line-clamp-2'}>{ item.duration_minutes }</p>
|
<p className={'line-clamp-2'}>{ dataFormatter.booleanFormatter(item.completed) }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>VideoFiles</p>
|
<p className={'text-xs text-gray-500 '}>Owner</p>
|
||||||
{dataFormatter.filesFormatter(item.video_files).map(link => (
|
<p className={'line-clamp-2'}>{ dataFormatter.usersOneListFormatter(item.owner) }</p>
|
||||||
<button
|
|
||||||
key={link.publicUrl}
|
|
||||||
onClick={(e) => saveFile(e, link.publicUrl, link.name)}
|
|
||||||
>
|
|
||||||
{link.name}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>Resources</p>
|
<p className={'text-xs text-gray-500 '}>RelatedDeal</p>
|
||||||
{dataFormatter.filesFormatter(item.resources).map(link => (
|
<p className={'line-clamp-2'}>{ dataFormatter.dealsOneListFormatter(item.related_deal) }</p>
|
||||||
<button
|
|
||||||
key={link.publicUrl}
|
|
||||||
onClick={(e) => saveFile(e, link.publicUrl, link.name)}
|
|
||||||
>
|
|
||||||
{link.name}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>ReleaseDate</p>
|
<p className={'text-xs text-gray-500 '}>RelatedLead</p>
|
||||||
<p className={'line-clamp-2'}>{ dataFormatter.dateTimeFormatter(item.release_date) }</p>
|
<p className={'line-clamp-2'}>{ dataFormatter.leadsOneListFormatter(item.related_lead) }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>Status</p>
|
<p className={'text-xs text-gray-500 '}>Notes</p>
|
||||||
<p className={'line-clamp-2'}>{ item.status }</p>
|
<p className={'line-clamp-2'}>{ item.notes }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -136,8 +122,8 @@ const ListLessons = ({ lessons, loading, onDelete, currentPage, numPages, onPage
|
|||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
itemId={item.id}
|
itemId={item.id}
|
||||||
pathEdit={`/lessons/lessons-edit/?id=${item.id}`}
|
pathEdit={`/activities/activities-edit/?id=${item.id}`}
|
||||||
pathView={`/lessons/lessons-view/?id=${item.id}`}
|
pathView={`/activities/activities-view/?id=${item.id}`}
|
||||||
|
|
||||||
hasUpdatePermission={hasUpdatePermission}
|
hasUpdatePermission={hasUpdatePermission}
|
||||||
|
|
||||||
@ -146,7 +132,7 @@ const ListLessons = ({ lessons, loading, onDelete, currentPage, numPages, onPage
|
|||||||
</CardBox>
|
</CardBox>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{!loading && lessons.length === 0 && (
|
{!loading && activities.length === 0 && (
|
||||||
<div className='col-span-full flex items-center justify-center h-40'>
|
<div className='col-span-full flex items-center justify-center h-40'>
|
||||||
<p className=''>No data to display</p>
|
<p className=''>No data to display</p>
|
||||||
</div>
|
</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 BaseButton from '../BaseButton'
|
||||||
import CardBoxModal from '../CardBoxModal'
|
import CardBoxModal from '../CardBoxModal'
|
||||||
import CardBox from "../CardBox";
|
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 { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { Field, Form, Formik } from "formik";
|
import { Field, Form, Formik } from "formik";
|
||||||
@ -12,7 +12,7 @@ import {
|
|||||||
DataGrid,
|
DataGrid,
|
||||||
GridColDef,
|
GridColDef,
|
||||||
} from '@mui/x-data-grid';
|
} from '@mui/x-data-grid';
|
||||||
import {loadColumns} from "./configureCoursesCols";
|
import {loadColumns} from "./configureActivitiesCols";
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import dataFormatter from '../../helpers/dataFormatter'
|
import dataFormatter from '../../helpers/dataFormatter'
|
||||||
import {dataGridStyles} from "../../styles";
|
import {dataGridStyles} from "../../styles";
|
||||||
@ -24,7 +24,7 @@ import { SlotInfo } from 'react-big-calendar';
|
|||||||
|
|
||||||
const perPage = 100
|
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 notify = (type, msg) => toast( msg, {type, position: "bottom-center"});
|
||||||
|
|
||||||
const dispatch = useAppDispatch();
|
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 { currentUser } = useAppSelector((state) => state.auth);
|
||||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||||
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
||||||
@ -63,10 +63,10 @@ const TableSampleCourses = ({ filterItems, setFilterItems, filters, showGrid })
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (coursesNotify.showNotification) {
|
if (activitiesNotify.showNotification) {
|
||||||
notify(coursesNotify.typeNotification, coursesNotify.textNotification);
|
notify(activitiesNotify.typeNotification, activitiesNotify.textNotification);
|
||||||
}
|
}
|
||||||
}, [coursesNotify.showNotification]);
|
}, [activitiesNotify.showNotification]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!currentUser) return;
|
if (!currentUser) return;
|
||||||
@ -93,7 +93,7 @@ const TableSampleCourses = ({ filterItems, setFilterItems, filters, showGrid })
|
|||||||
|
|
||||||
const handleCreateEventAction = ({ start, end }: SlotInfo) => {
|
const handleCreateEventAction = ({ start, end }: SlotInfo) => {
|
||||||
router.push(
|
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(
|
loadColumns(
|
||||||
handleDeleteModalAction,
|
handleDeleteModalAction,
|
||||||
`courses`,
|
`activities`,
|
||||||
currentUser,
|
currentUser,
|
||||||
).then((newCols) => setColumns(newCols));
|
).then((newCols) => setColumns(newCols));
|
||||||
}, [currentUser]);
|
}, [currentUser]);
|
||||||
@ -224,7 +224,7 @@ const TableSampleCourses = ({ filterItems, setFilterItems, filters, showGrid })
|
|||||||
sx={dataGridStyles}
|
sx={dataGridStyles}
|
||||||
className={'datagrid--table'}
|
className={'datagrid--table'}
|
||||||
getRowClassName={() => `datagrid--row`}
|
getRowClassName={() => `datagrid--row`}
|
||||||
rows={courses ?? []}
|
rows={activities ?? []}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
initialState={{
|
initialState={{
|
||||||
pagination: {
|
pagination: {
|
||||||
@ -451,18 +451,18 @@ const TableSampleCourses = ({ filterItems, setFilterItems, filters, showGrid })
|
|||||||
|
|
||||||
{!showGrid && (
|
{!showGrid && (
|
||||||
<BigCalendar
|
<BigCalendar
|
||||||
events={courses}
|
events={activities}
|
||||||
showField={'title'}
|
showField={'subject'}
|
||||||
start-data-key={'start_date'}
|
start-data-key={'start'}
|
||||||
end-data-key={'end_date'}
|
end-data-key={'end'}
|
||||||
handleDeleteAction={handleDeleteModalAction}
|
handleDeleteAction={handleDeleteModalAction}
|
||||||
pathEdit={`/courses/courses-edit/?id=`}
|
pathEdit={`/activities/activities-edit/?id=`}
|
||||||
pathView={`/courses/courses-view/?id=`}
|
pathView={`/activities/activities-view/?id=`}
|
||||||
handleCreateEventAction={handleCreateEventAction}
|
handleCreateEventAction={handleCreateEventAction}
|
||||||
onDateRangeChange={(range) => {
|
onDateRangeChange={(range) => {
|
||||||
loadData(0,`&calendarStart=${range.start}&calendarEnd=${range.end}`);
|
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 [
|
return [
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'title',
|
field: 'subject',
|
||||||
headerName: 'Title',
|
headerName: 'Subject',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
@ -57,8 +57,8 @@ export const loadColumns = async (
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'content',
|
field: 'activity_type',
|
||||||
headerName: 'Content',
|
headerName: 'ActivityType',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
@ -72,8 +72,60 @@ export const loadColumns = async (
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'course',
|
field: 'start',
|
||||||
headerName: 'Course',
|
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,
|
flex: 1,
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
@ -87,15 +139,15 @@ export const loadColumns = async (
|
|||||||
type: 'singleSelect',
|
type: 'singleSelect',
|
||||||
getOptionValue: (value: any) => value?.id,
|
getOptionValue: (value: any) => value?.id,
|
||||||
getOptionLabel: (value: any) => value?.label,
|
getOptionLabel: (value: any) => value?.label,
|
||||||
valueOptions: await callOptionsApi('courses'),
|
valueOptions: await callOptionsApi('users'),
|
||||||
valueGetter: (params: GridValueGetterParams) =>
|
valueGetter: (params: GridValueGetterParams) =>
|
||||||
params?.value?.id ?? params?.value,
|
params?.value?.id ?? params?.value,
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'order',
|
field: 'related_deal',
|
||||||
headerName: 'Order',
|
headerName: 'RelatedDeal',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
@ -105,99 +157,41 @@ export const loadColumns = async (
|
|||||||
|
|
||||||
editable: hasUpdatePermission,
|
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,
|
sortable: false,
|
||||||
renderCell: (params: GridValueGetterParams) => (
|
type: 'singleSelect',
|
||||||
<>
|
getOptionValue: (value: any) => value?.id,
|
||||||
{dataFormatter.filesFormatter(params.row.video_files).map(link => (
|
getOptionLabel: (value: any) => value?.label,
|
||||||
<button
|
valueOptions: await callOptionsApi('deals'),
|
||||||
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',
|
|
||||||
valueGetter: (params: GridValueGetterParams) =>
|
valueGetter: (params: GridValueGetterParams) =>
|
||||||
new Date(params.row.release_date),
|
params?.value?.id ?? params?.value,
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'status',
|
field: 'related_lead',
|
||||||
headerName: 'Status',
|
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,
|
flex: 1,
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
@ -223,8 +217,8 @@ export const loadColumns = async (
|
|||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
itemId={params?.row?.id}
|
itemId={params?.row?.id}
|
||||||
pathEdit={`/lessons/lessons-edit/?id=${params?.row?.id}`}
|
pathEdit={`/activities/activities-edit/?id=${params?.row?.id}`}
|
||||||
pathView={`/lessons/lessons-view/?id=${params?.row?.id}`}
|
pathView={`/activities/activities-view/?id=${params?.row?.id}`}
|
||||||
|
|
||||||
hasUpdatePermission={hasUpdatePermission}
|
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">
|
<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>
|
</div>
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import {hasPermission} from "../../helpers/userPermissions";
|
|||||||
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
progress: any[];
|
contacts: any[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
onDelete: (id: string) => void;
|
onDelete: (id: string) => void;
|
||||||
currentPage: number;
|
currentPage: number;
|
||||||
@ -20,8 +20,8 @@ type Props = {
|
|||||||
onPageChange: (page: number) => void;
|
onPageChange: (page: number) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const CardProgress = ({
|
const CardContacts = ({
|
||||||
progress,
|
contacts,
|
||||||
loading,
|
loading,
|
||||||
onDelete,
|
onDelete,
|
||||||
currentPage,
|
currentPage,
|
||||||
@ -37,7 +37,7 @@ const CardProgress = ({
|
|||||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||||
|
|
||||||
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
||||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_PROGRESS')
|
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_CONTACTS')
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -47,7 +47,7 @@ const CardProgress = ({
|
|||||||
role='list'
|
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'
|
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
|
<li
|
||||||
key={item.id}
|
key={item.id}
|
||||||
className={`overflow-hidden ${corners !== 'rounded-full'? corners : 'rounded-3xl'} border ${focusRing} border-gray-200 dark:border-dark-700 ${
|
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`}>
|
<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'>
|
<Link href={`/contacts/contacts-view/?id=${item.id}`} className='text-lg font-bold leading-6 line-clamp-1'>
|
||||||
{item.note}
|
{item.name}
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
|
|
||||||
@ -66,8 +66,8 @@ const CardProgress = ({
|
|||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
itemId={item.id}
|
itemId={item.id}
|
||||||
pathEdit={`/progress/progress-edit/?id=${item.id}`}
|
pathEdit={`/contacts/contacts-edit/?id=${item.id}`}
|
||||||
pathView={`/progress/progress-view/?id=${item.id}`}
|
pathView={`/contacts/contacts-view/?id=${item.id}`}
|
||||||
|
|
||||||
hasUpdatePermission={hasUpdatePermission}
|
hasUpdatePermission={hasUpdatePermission}
|
||||||
|
|
||||||
@ -78,10 +78,10 @@ const CardProgress = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ item.note }
|
{ item.name }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -90,10 +90,10 @@ const CardProgress = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ dataFormatter.enrollmentsOneListFormatter(item.enrollment) }
|
{ item.email }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -102,10 +102,10 @@ const CardProgress = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ dataFormatter.lessonsOneListFormatter(item.lesson) }
|
{ item.phone }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -114,10 +114,10 @@ const CardProgress = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ dataFormatter.booleanFormatter(item.completed) }
|
{ item.title }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -126,10 +126,10 @@ const CardProgress = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ dataFormatter.dateTimeFormatter(item.completed_at) }
|
{ item.company }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -138,10 +138,10 @@ const CardProgress = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ item.score }
|
{ dataFormatter.usersOneListFormatter(item.owner) }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -150,10 +150,10 @@ const CardProgress = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ item.attempts }
|
{ item.notes }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -163,7 +163,7 @@ const CardProgress = ({
|
|||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
{!loading && progress.length === 0 && (
|
{!loading && contacts.length === 0 && (
|
||||||
<div className='col-span-full flex items-center justify-center h-40'>
|
<div className='col-span-full flex items-center justify-center h-40'>
|
||||||
<p className=''>No data to display</p>
|
<p className=''>No data to display</p>
|
||||||
</div>
|
</div>
|
||||||
@ -180,4 +180,4 @@ const CardProgress = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CardProgress;
|
export default CardContacts;
|
||||||
@ -13,7 +13,7 @@ import {hasPermission} from "../../helpers/userPermissions";
|
|||||||
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
progress: any[];
|
contacts: any[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
onDelete: (id: string) => void;
|
onDelete: (id: string) => void;
|
||||||
currentPage: number;
|
currentPage: number;
|
||||||
@ -21,10 +21,10 @@ type Props = {
|
|||||||
onPageChange: (page: number) => void;
|
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 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 corners = useAppSelector((state) => state.style.corners);
|
||||||
const bgColor = useAppSelector((state) => state.style.cardsColor);
|
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'>
|
<div className='relative overflow-x-auto p-4 space-y-4'>
|
||||||
{loading && <LoadingSpinner />}
|
{loading && <LoadingSpinner />}
|
||||||
{!loading && progress.map((item) => (
|
{!loading && contacts.map((item) => (
|
||||||
<div key={item.id}>
|
<div key={item.id}>
|
||||||
<CardBox hasTable isList className={'rounded shadow-none'}>
|
<CardBox hasTable isList className={'rounded shadow-none'}>
|
||||||
<div className={`flex rounded dark:bg-dark-900 border border-stone-300 items-center overflow-hidden`}>
|
<div className={`flex rounded dark:bg-dark-900 border border-stone-300 items-center overflow-hidden`}>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
href={`/progress/progress-view/?id=${item.id}`}
|
href={`/contacts/contacts-view/?id=${item.id}`}
|
||||||
className={
|
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'
|
'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'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>Note</p>
|
<p className={'text-xs text-gray-500 '}>Name</p>
|
||||||
<p className={'line-clamp-2'}>{ item.note }</p>
|
<p className={'line-clamp-2'}>{ item.name }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>Enrollment</p>
|
<p className={'text-xs text-gray-500 '}>Email</p>
|
||||||
<p className={'line-clamp-2'}>{ dataFormatter.enrollmentsOneListFormatter(item.enrollment) }</p>
|
<p className={'line-clamp-2'}>{ item.email }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>Lesson</p>
|
<p className={'text-xs text-gray-500 '}>Phone</p>
|
||||||
<p className={'line-clamp-2'}>{ dataFormatter.lessonsOneListFormatter(item.lesson) }</p>
|
<p className={'line-clamp-2'}>{ item.phone }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>Completed</p>
|
<p className={'text-xs text-gray-500 '}>JobTitle</p>
|
||||||
<p className={'line-clamp-2'}>{ dataFormatter.booleanFormatter(item.completed) }</p>
|
<p className={'line-clamp-2'}>{ item.title }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>CompletedAt</p>
|
<p className={'text-xs text-gray-500 '}>Company</p>
|
||||||
<p className={'line-clamp-2'}>{ dataFormatter.dateTimeFormatter(item.completed_at) }</p>
|
<p className={'line-clamp-2'}>{ item.company }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>Score</p>
|
<p className={'text-xs text-gray-500 '}>Owner</p>
|
||||||
<p className={'line-clamp-2'}>{ item.score }</p>
|
<p className={'line-clamp-2'}>{ dataFormatter.usersOneListFormatter(item.owner) }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>Attempts</p>
|
<p className={'text-xs text-gray-500 '}>Notes</p>
|
||||||
<p className={'line-clamp-2'}>{ item.attempts }</p>
|
<p className={'line-clamp-2'}>{ item.notes }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -106,8 +106,8 @@ const ListProgress = ({ progress, loading, onDelete, currentPage, numPages, onPa
|
|||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
itemId={item.id}
|
itemId={item.id}
|
||||||
pathEdit={`/progress/progress-edit/?id=${item.id}`}
|
pathEdit={`/contacts/contacts-edit/?id=${item.id}`}
|
||||||
pathView={`/progress/progress-view/?id=${item.id}`}
|
pathView={`/contacts/contacts-view/?id=${item.id}`}
|
||||||
|
|
||||||
hasUpdatePermission={hasUpdatePermission}
|
hasUpdatePermission={hasUpdatePermission}
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ const ListProgress = ({ progress, loading, onDelete, currentPage, numPages, onPa
|
|||||||
</CardBox>
|
</CardBox>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{!loading && progress.length === 0 && (
|
{!loading && contacts.length === 0 && (
|
||||||
<div className='col-span-full flex items-center justify-center h-40'>
|
<div className='col-span-full flex items-center justify-center h-40'>
|
||||||
<p className=''>No data to display</p>
|
<p className=''>No data to display</p>
|
||||||
</div>
|
</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 BaseButton from '../BaseButton'
|
||||||
import CardBoxModal from '../CardBoxModal'
|
import CardBoxModal from '../CardBoxModal'
|
||||||
import CardBox from "../CardBox";
|
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 { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { Field, Form, Formik } from "formik";
|
import { Field, Form, Formik } from "formik";
|
||||||
@ -12,18 +12,18 @@ import {
|
|||||||
DataGrid,
|
DataGrid,
|
||||||
GridColDef,
|
GridColDef,
|
||||||
} from '@mui/x-data-grid';
|
} from '@mui/x-data-grid';
|
||||||
import {loadColumns} from "./configureProgressCols";
|
import {loadColumns} from "./configureContactsCols";
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import dataFormatter from '../../helpers/dataFormatter'
|
import dataFormatter from '../../helpers/dataFormatter'
|
||||||
import {dataGridStyles} from "../../styles";
|
import {dataGridStyles} from "../../styles";
|
||||||
|
|
||||||
|
|
||||||
import ListProgress from './ListProgress';
|
import ListContacts from './ListContacts';
|
||||||
|
|
||||||
|
|
||||||
const perPage = 10
|
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 notify = (type, msg) => toast( msg, {type, position: "bottom-center"});
|
||||||
|
|
||||||
const dispatch = useAppDispatch();
|
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 { currentUser } = useAppSelector((state) => state.auth);
|
||||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||||
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
||||||
@ -62,10 +62,10 @@ const TableSampleProgress = ({ filterItems, setFilterItems, filters, showGrid })
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (progressNotify.showNotification) {
|
if (contactsNotify.showNotification) {
|
||||||
notify(progressNotify.typeNotification, progressNotify.textNotification);
|
notify(contactsNotify.typeNotification, contactsNotify.textNotification);
|
||||||
}
|
}
|
||||||
}, [progressNotify.showNotification]);
|
}, [contactsNotify.showNotification]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!currentUser) return;
|
if (!currentUser) return;
|
||||||
@ -179,7 +179,7 @@ const TableSampleProgress = ({ filterItems, setFilterItems, filters, showGrid })
|
|||||||
|
|
||||||
loadColumns(
|
loadColumns(
|
||||||
handleDeleteModalAction,
|
handleDeleteModalAction,
|
||||||
`progress`,
|
`contacts`,
|
||||||
currentUser,
|
currentUser,
|
||||||
).then((newCols) => setColumns(newCols));
|
).then((newCols) => setColumns(newCols));
|
||||||
}, [currentUser]);
|
}, [currentUser]);
|
||||||
@ -217,7 +217,7 @@ const TableSampleProgress = ({ filterItems, setFilterItems, filters, showGrid })
|
|||||||
sx={dataGridStyles}
|
sx={dataGridStyles}
|
||||||
className={'datagrid--table'}
|
className={'datagrid--table'}
|
||||||
getRowClassName={() => `datagrid--row`}
|
getRowClassName={() => `datagrid--row`}
|
||||||
rows={progress ?? []}
|
rows={contacts ?? []}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
initialState={{
|
initialState={{
|
||||||
pagination: {
|
pagination: {
|
||||||
@ -442,9 +442,9 @@ const TableSampleProgress = ({ filterItems, setFilterItems, filters, showGrid })
|
|||||||
</CardBoxModal>
|
</CardBoxModal>
|
||||||
|
|
||||||
|
|
||||||
{progress && Array.isArray(progress) && !showGrid && (
|
{contacts && Array.isArray(contacts) && !showGrid && (
|
||||||
<ListProgress
|
<ListContacts
|
||||||
progress={progress}
|
contacts={contacts}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
onDelete={handleDeleteModalAction}
|
onDelete={handleDeleteModalAction}
|
||||||
currentPage={currentPage}
|
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 [
|
return [
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'note',
|
field: 'name',
|
||||||
headerName: 'Note',
|
headerName: 'Name',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
@ -57,8 +57,68 @@ export const loadColumns = async (
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'enrollment',
|
field: 'email',
|
||||||
headerName: 'Enrollment',
|
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,
|
flex: 1,
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
@ -72,15 +132,15 @@ export const loadColumns = async (
|
|||||||
type: 'singleSelect',
|
type: 'singleSelect',
|
||||||
getOptionValue: (value: any) => value?.id,
|
getOptionValue: (value: any) => value?.id,
|
||||||
getOptionLabel: (value: any) => value?.label,
|
getOptionLabel: (value: any) => value?.label,
|
||||||
valueOptions: await callOptionsApi('enrollments'),
|
valueOptions: await callOptionsApi('users'),
|
||||||
valueGetter: (params: GridValueGetterParams) =>
|
valueGetter: (params: GridValueGetterParams) =>
|
||||||
params?.value?.id ?? params?.value,
|
params?.value?.id ?? params?.value,
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'lesson',
|
field: 'notes',
|
||||||
headerName: 'Lesson',
|
headerName: 'Notes',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
@ -90,79 +150,6 @@ export const loadColumns = async (
|
|||||||
|
|
||||||
editable: hasUpdatePermission,
|
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
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
itemId={params?.row?.id}
|
itemId={params?.row?.id}
|
||||||
pathEdit={`/progress/progress-edit/?id=${params?.row?.id}`}
|
pathEdit={`/contacts/contacts-edit/?id=${params?.row?.id}`}
|
||||||
pathView={`/progress/progress-view/?id=${params?.row?.id}`}
|
pathView={`/contacts/contacts-view/?id=${params?.row?.id}`}
|
||||||
|
|
||||||
hasUpdatePermission={hasUpdatePermission}
|
hasUpdatePermission={hasUpdatePermission}
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ import {hasPermission} from "../../helpers/userPermissions";
|
|||||||
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
lessons: any[];
|
deals: any[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
onDelete: (id: string) => void;
|
onDelete: (id: string) => void;
|
||||||
currentPage: number;
|
currentPage: number;
|
||||||
@ -20,8 +20,8 @@ type Props = {
|
|||||||
onPageChange: (page: number) => void;
|
onPageChange: (page: number) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const CardLessons = ({
|
const CardDeals = ({
|
||||||
lessons,
|
deals,
|
||||||
loading,
|
loading,
|
||||||
onDelete,
|
onDelete,
|
||||||
currentPage,
|
currentPage,
|
||||||
@ -37,7 +37,7 @@ const CardLessons = ({
|
|||||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||||
|
|
||||||
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
||||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_LESSONS')
|
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_DEALS')
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -47,7 +47,7 @@ const CardLessons = ({
|
|||||||
role='list'
|
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'
|
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
|
<li
|
||||||
key={item.id}
|
key={item.id}
|
||||||
className={`overflow-hidden ${corners !== 'rounded-full'? corners : 'rounded-3xl'} border ${focusRing} border-gray-200 dark:border-dark-700 ${
|
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`}>
|
<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}
|
{item.title}
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
@ -66,8 +66,8 @@ const CardLessons = ({
|
|||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
itemId={item.id}
|
itemId={item.id}
|
||||||
pathEdit={`/lessons/lessons-edit/?id=${item.id}`}
|
pathEdit={`/deals/deals-edit/?id=${item.id}`}
|
||||||
pathView={`/lessons/lessons-view/?id=${item.id}`}
|
pathView={`/deals/deals-view/?id=${item.id}`}
|
||||||
|
|
||||||
hasUpdatePermission={hasUpdatePermission}
|
hasUpdatePermission={hasUpdatePermission}
|
||||||
|
|
||||||
@ -90,10 +90,10 @@ const CardLessons = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ item.content }
|
{ item.deal_number }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -102,10 +102,10 @@ const CardLessons = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ dataFormatter.coursesOneListFormatter(item.course) }
|
{ item.value }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -114,10 +114,10 @@ const CardLessons = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ item.order }
|
{ item.currency }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -126,60 +126,10 @@ const CardLessons = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ item.duration_minutes }
|
{ dataFormatter.pipeline_stagesOneListFormatter(item.stage) }
|
||||||
</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) }
|
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</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>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
{!loading && lessons.length === 0 && (
|
{!loading && deals.length === 0 && (
|
||||||
<div className='col-span-full flex items-center justify-center h-40'>
|
<div className='col-span-full flex items-center justify-center h-40'>
|
||||||
<p className=''>No data to display</p>
|
<p className=''>No data to display</p>
|
||||||
</div>
|
</div>
|
||||||
@ -218,4 +216,4 @@ const CardLessons = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CardLessons;
|
export default CardDeals;
|
||||||
@ -13,7 +13,7 @@ import {hasPermission} from "../../helpers/userPermissions";
|
|||||||
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
courses: any[];
|
deals: any[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
onDelete: (id: string) => void;
|
onDelete: (id: string) => void;
|
||||||
currentPage: number;
|
currentPage: number;
|
||||||
@ -21,10 +21,10 @@ type Props = {
|
|||||||
onPageChange: (page: number) => void;
|
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 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 corners = useAppSelector((state) => state.style.corners);
|
||||||
const bgColor = useAppSelector((state) => state.style.cardsColor);
|
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'>
|
<div className='relative overflow-x-auto p-4 space-y-4'>
|
||||||
{loading && <LoadingSpinner />}
|
{loading && <LoadingSpinner />}
|
||||||
{!loading && courses.map((item) => (
|
{!loading && deals.map((item) => (
|
||||||
<div key={item.id}>
|
<div key={item.id}>
|
||||||
<CardBox hasTable isList className={'rounded shadow-none'}>
|
<CardBox hasTable isList className={'rounded shadow-none'}>
|
||||||
<div className={`flex rounded dark:bg-dark-900 border border-stone-300 items-center overflow-hidden`}>
|
<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
|
<Link
|
||||||
href={`/courses/courses-view/?id=${item.id}`}
|
href={`/deals/deals-view/?id=${item.id}`}
|
||||||
className={
|
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'
|
'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'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>Description</p>
|
<p className={'text-xs text-gray-500 '}>Description</p>
|
||||||
<p className={'line-clamp-2'}>{ item.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>
|
</Link>
|
||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
itemId={item.id}
|
itemId={item.id}
|
||||||
pathEdit={`/courses/courses-edit/?id=${item.id}`}
|
pathEdit={`/deals/deals-edit/?id=${item.id}`}
|
||||||
pathView={`/courses/courses-view/?id=${item.id}`}
|
pathView={`/deals/deals-view/?id=${item.id}`}
|
||||||
|
|
||||||
hasUpdatePermission={hasUpdatePermission}
|
hasUpdatePermission={hasUpdatePermission}
|
||||||
|
|
||||||
@ -159,7 +140,7 @@ const ListCourses = ({ courses, loading, onDelete, currentPage, numPages, onPage
|
|||||||
</CardBox>
|
</CardBox>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{!loading && courses.length === 0 && (
|
{!loading && deals.length === 0 && (
|
||||||
<div className='col-span-full flex items-center justify-center h-40'>
|
<div className='col-span-full flex items-center justify-center h-40'>
|
||||||
<p className=''>No data to display</p>
|
<p className=''>No data to display</p>
|
||||||
</div>
|
</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 BaseButton from '../BaseButton'
|
||||||
import CardBoxModal from '../CardBoxModal'
|
import CardBoxModal from '../CardBoxModal'
|
||||||
import CardBox from "../CardBox";
|
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 { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { Field, Form, Formik } from "formik";
|
import { Field, Form, Formik } from "formik";
|
||||||
@ -12,7 +12,7 @@ import {
|
|||||||
DataGrid,
|
DataGrid,
|
||||||
GridColDef,
|
GridColDef,
|
||||||
} from '@mui/x-data-grid';
|
} from '@mui/x-data-grid';
|
||||||
import {loadColumns} from "./configureLessonsCols";
|
import {loadColumns} from "./configureDealsCols";
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import dataFormatter from '../../helpers/dataFormatter'
|
import dataFormatter from '../../helpers/dataFormatter'
|
||||||
import {dataGridStyles} from "../../styles";
|
import {dataGridStyles} from "../../styles";
|
||||||
@ -24,7 +24,7 @@ import axios from 'axios';
|
|||||||
|
|
||||||
const perPage = 10
|
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 notify = (type, msg) => toast( msg, {type, position: "bottom-center"});
|
||||||
|
|
||||||
const dispatch = useAppDispatch();
|
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 [kanbanColumns, setKanbanColumns] = useState<Array<{id: string, label: string}> | null>(null);
|
||||||
const [kanbanFilters, setKanbanFilters] = useState('');
|
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 { currentUser } = useAppSelector((state) => state.auth);
|
||||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||||
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
||||||
@ -66,10 +66,10 @@ const TableSampleLessons = ({ filterItems, setFilterItems, filters, showGrid })
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (lessonsNotify.showNotification) {
|
if (dealsNotify.showNotification) {
|
||||||
notify(lessonsNotify.typeNotification, lessonsNotify.textNotification);
|
notify(dealsNotify.typeNotification, dealsNotify.textNotification);
|
||||||
}
|
}
|
||||||
}, [lessonsNotify.showNotification]);
|
}, [dealsNotify.showNotification]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!currentUser) return;
|
if (!currentUser) return;
|
||||||
@ -96,15 +96,16 @@ const TableSampleLessons = ({ filterItems, setFilterItems, filters, showGrid })
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
setKanbanColumns([
|
|
||||||
|
|
||||||
{ id: "draft", label: "draft" },
|
|
||||||
|
|
||||||
{ id: "published", label: "published" },
|
axios.get('/pipeline_stages/autocomplete?limit=100')
|
||||||
|
.then((res) => {
|
||||||
|
setKanbanColumns(res.data);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error('Error fetching kanban columns:', err);
|
||||||
|
});
|
||||||
|
|
||||||
{ id: "archived", label: "archived" },
|
|
||||||
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
|
||||||
}, []);
|
}, []);
|
||||||
@ -206,7 +207,7 @@ const TableSampleLessons = ({ filterItems, setFilterItems, filters, showGrid })
|
|||||||
|
|
||||||
loadColumns(
|
loadColumns(
|
||||||
handleDeleteModalAction,
|
handleDeleteModalAction,
|
||||||
`lessons`,
|
`deals`,
|
||||||
currentUser,
|
currentUser,
|
||||||
).then((newCols) => setColumns(newCols));
|
).then((newCols) => setColumns(newCols));
|
||||||
}, [currentUser]);
|
}, [currentUser]);
|
||||||
@ -244,7 +245,7 @@ const TableSampleLessons = ({ filterItems, setFilterItems, filters, showGrid })
|
|||||||
sx={dataGridStyles}
|
sx={dataGridStyles}
|
||||||
className={'datagrid--table'}
|
className={'datagrid--table'}
|
||||||
getRowClassName={() => `datagrid--row`}
|
getRowClassName={() => `datagrid--row`}
|
||||||
rows={lessons ?? []}
|
rows={deals ?? []}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
initialState={{
|
initialState={{
|
||||||
pagination: {
|
pagination: {
|
||||||
@ -472,9 +473,9 @@ const TableSampleLessons = ({ filterItems, setFilterItems, filters, showGrid })
|
|||||||
|
|
||||||
{!showGrid && kanbanColumns && (
|
{!showGrid && kanbanColumns && (
|
||||||
<KanbanBoard
|
<KanbanBoard
|
||||||
columnFieldName={'status'}
|
columnFieldName={'stage'}
|
||||||
showFieldName={'title'}
|
showFieldName={'title'}
|
||||||
entityName={'lessons'}
|
entityName={'deals'}
|
||||||
filtersQuery={kanbanFilters}
|
filtersQuery={kanbanFilters}
|
||||||
deleteThunk={deleteItem}
|
deleteThunk={deleteItem}
|
||||||
updateThunk={update}
|
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 [
|
return [
|
||||||
|
|
||||||
@ -57,8 +57,8 @@ export const loadColumns = async (
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'description',
|
field: 'deal_number',
|
||||||
headerName: 'Description',
|
headerName: 'DealNumber',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
@ -72,8 +72,94 @@ export const loadColumns = async (
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'instructor',
|
field: 'value',
|
||||||
headerName: 'Instructor',
|
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,
|
flex: 1,
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
@ -94,8 +180,8 @@ export const loadColumns = async (
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'category',
|
field: 'primary_contact',
|
||||||
headerName: 'Category',
|
headerName: 'PrimaryContact',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
@ -105,116 +191,19 @@ export const loadColumns = async (
|
|||||||
|
|
||||||
editable: hasUpdatePermission,
|
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,
|
sortable: false,
|
||||||
renderCell: (params: GridValueGetterParams) => (
|
type: 'singleSelect',
|
||||||
<ImageField
|
getOptionValue: (value: any) => value?.id,
|
||||||
name={'Avatar'}
|
getOptionLabel: (value: any) => value?.label,
|
||||||
image={params?.row?.thumbnail}
|
valueOptions: await callOptionsApi('contacts'),
|
||||||
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',
|
|
||||||
valueGetter: (params: GridValueGetterParams) =>
|
valueGetter: (params: GridValueGetterParams) =>
|
||||||
new Date(params.row.start_date),
|
params?.value?.id ?? params?.value,
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'end_date',
|
field: 'description',
|
||||||
headerName: 'EndDate',
|
headerName: 'Description',
|
||||||
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',
|
|
||||||
flex: 1,
|
flex: 1,
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
@ -240,8 +229,8 @@ export const loadColumns = async (
|
|||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
itemId={params?.row?.id}
|
itemId={params?.row?.id}
|
||||||
pathEdit={`/courses/courses-edit/?id=${params?.row?.id}`}
|
pathEdit={`/deals/deals-edit/?id=${params?.row?.id}`}
|
||||||
pathView={`/courses/courses-view/?id=${params?.row?.id}`}
|
pathView={`/deals/deals-view/?id=${params?.row?.id}`}
|
||||||
|
|
||||||
hasUpdatePermission={hasUpdatePermission}
|
hasUpdatePermission={hasUpdatePermission}
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ import {hasPermission} from "../../helpers/userPermissions";
|
|||||||
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
enrollments: any[];
|
leads: any[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
onDelete: (id: string) => void;
|
onDelete: (id: string) => void;
|
||||||
currentPage: number;
|
currentPage: number;
|
||||||
@ -20,8 +20,8 @@ type Props = {
|
|||||||
onPageChange: (page: number) => void;
|
onPageChange: (page: number) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const CardEnrollments = ({
|
const CardLeads = ({
|
||||||
enrollments,
|
leads,
|
||||||
loading,
|
loading,
|
||||||
onDelete,
|
onDelete,
|
||||||
currentPage,
|
currentPage,
|
||||||
@ -37,7 +37,7 @@ const CardEnrollments = ({
|
|||||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||||
|
|
||||||
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
const currentUser = useAppSelector((state) => state.auth.currentUser);
|
||||||
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_ENROLLMENTS')
|
const hasUpdatePermission = hasPermission(currentUser, 'UPDATE_LEADS')
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -47,7 +47,7 @@ const CardEnrollments = ({
|
|||||||
role='list'
|
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'
|
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
|
<li
|
||||||
key={item.id}
|
key={item.id}
|
||||||
className={`overflow-hidden ${corners !== 'rounded-full'? corners : 'rounded-3xl'} border ${focusRing} border-gray-200 dark:border-dark-700 ${
|
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`}>
|
<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'>
|
<Link href={`/leads/leads-view/?id=${item.id}`} className='text-lg font-bold leading-6 line-clamp-1'>
|
||||||
{item.enrollment_label}
|
{item.name}
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
|
|
||||||
@ -66,8 +66,8 @@ const CardEnrollments = ({
|
|||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
itemId={item.id}
|
itemId={item.id}
|
||||||
pathEdit={`/enrollments/enrollments-edit/?id=${item.id}`}
|
pathEdit={`/leads/leads-edit/?id=${item.id}`}
|
||||||
pathView={`/enrollments/enrollments-view/?id=${item.id}`}
|
pathView={`/leads/leads-view/?id=${item.id}`}
|
||||||
|
|
||||||
hasUpdatePermission={hasUpdatePermission}
|
hasUpdatePermission={hasUpdatePermission}
|
||||||
|
|
||||||
@ -78,10 +78,10 @@ const CardEnrollments = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ item.enrollment_label }
|
{ item.name }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -90,10 +90,10 @@ const CardEnrollments = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ dataFormatter.usersOneListFormatter(item.student) }
|
{ item.company }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -102,10 +102,10 @@ const CardEnrollments = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ dataFormatter.coursesOneListFormatter(item.course) }
|
{ item.email }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -114,10 +114,22 @@ const CardEnrollments = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<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>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -138,10 +150,10 @@ const CardEnrollments = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<div className='font-medium line-clamp-4'>
|
||||||
{ item.progress_percent }
|
{ dataFormatter.usersOneListFormatter(item.owner) }
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -150,10 +162,22 @@ const CardEnrollments = ({
|
|||||||
|
|
||||||
|
|
||||||
<div className='flex justify-between gap-x-4 py-3'>
|
<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'>
|
<dd className='flex items-start gap-x-2'>
|
||||||
<div className='font-medium line-clamp-4'>
|
<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>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -163,7 +187,7 @@ const CardEnrollments = ({
|
|||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
{!loading && enrollments.length === 0 && (
|
{!loading && leads.length === 0 && (
|
||||||
<div className='col-span-full flex items-center justify-center h-40'>
|
<div className='col-span-full flex items-center justify-center h-40'>
|
||||||
<p className=''>No data to display</p>
|
<p className=''>No data to display</p>
|
||||||
</div>
|
</div>
|
||||||
@ -180,4 +204,4 @@ const CardEnrollments = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CardEnrollments;
|
export default CardLeads;
|
||||||
@ -13,7 +13,7 @@ import {hasPermission} from "../../helpers/userPermissions";
|
|||||||
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
enrollments: any[];
|
leads: any[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
onDelete: (id: string) => void;
|
onDelete: (id: string) => void;
|
||||||
currentPage: number;
|
currentPage: number;
|
||||||
@ -21,10 +21,10 @@ type Props = {
|
|||||||
onPageChange: (page: number) => void;
|
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 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 corners = useAppSelector((state) => state.style.corners);
|
||||||
const bgColor = useAppSelector((state) => state.style.cardsColor);
|
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'>
|
<div className='relative overflow-x-auto p-4 space-y-4'>
|
||||||
{loading && <LoadingSpinner />}
|
{loading && <LoadingSpinner />}
|
||||||
{!loading && enrollments.map((item) => (
|
{!loading && leads.map((item) => (
|
||||||
<div key={item.id}>
|
<div key={item.id}>
|
||||||
<CardBox hasTable isList className={'rounded shadow-none'}>
|
<CardBox hasTable isList className={'rounded shadow-none'}>
|
||||||
<div className={`flex rounded dark:bg-dark-900 border border-stone-300 items-center overflow-hidden`}>
|
<div className={`flex rounded dark:bg-dark-900 border border-stone-300 items-center overflow-hidden`}>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
href={`/enrollments/enrollments-view/?id=${item.id}`}
|
href={`/leads/leads-view/?id=${item.id}`}
|
||||||
className={
|
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'
|
'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'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>EnrollmentLabel</p>
|
<p className={'text-xs text-gray-500 '}>Name</p>
|
||||||
<p className={'line-clamp-2'}>{ item.enrollment_label }</p>
|
<p className={'line-clamp-2'}>{ item.name }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>Student</p>
|
<p className={'text-xs text-gray-500 '}>Company</p>
|
||||||
<p className={'line-clamp-2'}>{ dataFormatter.usersOneListFormatter(item.student) }</p>
|
<p className={'line-clamp-2'}>{ item.company }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>Course</p>
|
<p className={'text-xs text-gray-500 '}>Email</p>
|
||||||
<p className={'line-clamp-2'}>{ dataFormatter.coursesOneListFormatter(item.course) }</p>
|
<p className={'line-clamp-2'}>{ item.email }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>EnrolledAt</p>
|
<p className={'text-xs text-gray-500 '}>Phone</p>
|
||||||
<p className={'line-clamp-2'}>{ dataFormatter.dateTimeFormatter(item.enrolled_at) }</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>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -88,16 +96,24 @@ const ListEnrollments = ({ enrollments, loading, onDelete, currentPage, numPages
|
|||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>ProgressPercent</p>
|
<p className={'text-xs text-gray-500 '}>Owner</p>
|
||||||
<p className={'line-clamp-2'}>{ item.progress_percent }</p>
|
<p className={'line-clamp-2'}>{ dataFormatter.usersOneListFormatter(item.owner) }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'flex-1 px-3'}>
|
<div className={'flex-1 px-3'}>
|
||||||
<p className={'text-xs text-gray-500 '}>PricePaid</p>
|
<p className={'text-xs text-gray-500 '}>EstimatedValue</p>
|
||||||
<p className={'line-clamp-2'}>{ item.price_paid }</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>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -106,8 +122,8 @@ const ListEnrollments = ({ enrollments, loading, onDelete, currentPage, numPages
|
|||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
itemId={item.id}
|
itemId={item.id}
|
||||||
pathEdit={`/enrollments/enrollments-edit/?id=${item.id}`}
|
pathEdit={`/leads/leads-edit/?id=${item.id}`}
|
||||||
pathView={`/enrollments/enrollments-view/?id=${item.id}`}
|
pathView={`/leads/leads-view/?id=${item.id}`}
|
||||||
|
|
||||||
hasUpdatePermission={hasUpdatePermission}
|
hasUpdatePermission={hasUpdatePermission}
|
||||||
|
|
||||||
@ -116,7 +132,7 @@ const ListEnrollments = ({ enrollments, loading, onDelete, currentPage, numPages
|
|||||||
</CardBox>
|
</CardBox>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{!loading && enrollments.length === 0 && (
|
{!loading && leads.length === 0 && (
|
||||||
<div className='col-span-full flex items-center justify-center h-40'>
|
<div className='col-span-full flex items-center justify-center h-40'>
|
||||||
<p className=''>No data to display</p>
|
<p className=''>No data to display</p>
|
||||||
</div>
|
</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 BaseButton from '../BaseButton'
|
||||||
import CardBoxModal from '../CardBoxModal'
|
import CardBoxModal from '../CardBoxModal'
|
||||||
import CardBox from "../CardBox";
|
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 { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { Field, Form, Formik } from "formik";
|
import { Field, Form, Formik } from "formik";
|
||||||
@ -12,7 +12,7 @@ import {
|
|||||||
DataGrid,
|
DataGrid,
|
||||||
GridColDef,
|
GridColDef,
|
||||||
} from '@mui/x-data-grid';
|
} from '@mui/x-data-grid';
|
||||||
import {loadColumns} from "./configureEnrollmentsCols";
|
import {loadColumns} from "./configureLeadsCols";
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import dataFormatter from '../../helpers/dataFormatter'
|
import dataFormatter from '../../helpers/dataFormatter'
|
||||||
import {dataGridStyles} from "../../styles";
|
import {dataGridStyles} from "../../styles";
|
||||||
@ -21,7 +21,7 @@ import {dataGridStyles} from "../../styles";
|
|||||||
|
|
||||||
const perPage = 10
|
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 notify = (type, msg) => toast( msg, {type, position: "bottom-center"});
|
||||||
|
|
||||||
const dispatch = useAppDispatch();
|
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 { currentUser } = useAppSelector((state) => state.auth);
|
||||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||||
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
||||||
@ -60,10 +60,10 @@ const TableSampleEnrollments = ({ filterItems, setFilterItems, filters, showGrid
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (enrollmentsNotify.showNotification) {
|
if (leadsNotify.showNotification) {
|
||||||
notify(enrollmentsNotify.typeNotification, enrollmentsNotify.textNotification);
|
notify(leadsNotify.typeNotification, leadsNotify.textNotification);
|
||||||
}
|
}
|
||||||
}, [enrollmentsNotify.showNotification]);
|
}, [leadsNotify.showNotification]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!currentUser) return;
|
if (!currentUser) return;
|
||||||
@ -177,7 +177,7 @@ const TableSampleEnrollments = ({ filterItems, setFilterItems, filters, showGrid
|
|||||||
|
|
||||||
loadColumns(
|
loadColumns(
|
||||||
handleDeleteModalAction,
|
handleDeleteModalAction,
|
||||||
`enrollments`,
|
`leads`,
|
||||||
currentUser,
|
currentUser,
|
||||||
).then((newCols) => setColumns(newCols));
|
).then((newCols) => setColumns(newCols));
|
||||||
}, [currentUser]);
|
}, [currentUser]);
|
||||||
@ -215,7 +215,7 @@ const TableSampleEnrollments = ({ filterItems, setFilterItems, filters, showGrid
|
|||||||
sx={dataGridStyles}
|
sx={dataGridStyles}
|
||||||
className={'datagrid--table'}
|
className={'datagrid--table'}
|
||||||
getRowClassName={() => `datagrid--row`}
|
getRowClassName={() => `datagrid--row`}
|
||||||
rows={enrollments ?? []}
|
rows={leads ?? []}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
initialState={{
|
initialState={{
|
||||||
pagination: {
|
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 [
|
return [
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'enrollment_label',
|
field: 'name',
|
||||||
headerName: 'EnrollmentLabel',
|
headerName: 'Name',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
@ -57,8 +57,83 @@ export const loadColumns = async (
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'student',
|
field: 'company',
|
||||||
headerName: 'Student',
|
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,
|
flex: 1,
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
@ -79,63 +154,8 @@ export const loadColumns = async (
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'course',
|
field: 'estimated_value',
|
||||||
headerName: 'Course',
|
headerName: 'EstimatedValue',
|
||||||
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',
|
|
||||||
flex: 1,
|
flex: 1,
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
@ -150,8 +170,8 @@ export const loadColumns = async (
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'price_paid',
|
field: 'notes',
|
||||||
headerName: 'PricePaid',
|
headerName: 'Notes',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
@ -161,7 +181,6 @@ export const loadColumns = async (
|
|||||||
|
|
||||||
editable: hasUpdatePermission,
|
editable: hasUpdatePermission,
|
||||||
|
|
||||||
type: 'number',
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -178,8 +197,8 @@ export const loadColumns = async (
|
|||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
itemId={params?.row?.id}
|
itemId={params?.row?.id}
|
||||||
pathEdit={`/enrollments/enrollments-edit/?id=${params?.row?.id}`}
|
pathEdit={`/leads/leads-edit/?id=${params?.row?.id}`}
|
||||||
pathView={`/enrollments/enrollments-view/?id=${params?.row?.id}`}
|
pathView={`/leads/leads-view/?id=${params?.row?.id}`}
|
||||||
|
|
||||||
hasUpdatePermission={hasUpdatePermission}
|
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 Link from 'next/link'
|
||||||
import { useState } from 'react'
|
|
||||||
import { mdiChevronUp, mdiChevronDown } from '@mdi/js'
|
import { mdiChevronUp, mdiChevronDown } from '@mdi/js'
|
||||||
import BaseDivider from './BaseDivider'
|
import BaseDivider from './BaseDivider'
|
||||||
import BaseIcon from './BaseIcon'
|
import BaseIcon from './BaseIcon'
|
||||||
|
|||||||
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 []
|
if (!val || !val.length) return []
|
||||||
return val.map((item) => item.title)
|
return val.map((item) => item.title)
|
||||||
},
|
},
|
||||||
coursesOneListFormatter(val) {
|
pipeline_stagesOneListFormatter(val) {
|
||||||
if (!val) return ''
|
if (!val) return ''
|
||||||
return val.title
|
return val.title
|
||||||
},
|
},
|
||||||
coursesManyListFormatterEdit(val) {
|
pipeline_stagesManyListFormatterEdit(val) {
|
||||||
if (!val || !val.length) return []
|
if (!val || !val.length) return []
|
||||||
return val.map((item) => {
|
return val.map((item) => {
|
||||||
return {id: item.id, label: item.title}
|
return {id: item.id, label: item.title}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
coursesOneListFormatterEdit(val) {
|
pipeline_stagesOneListFormatterEdit(val) {
|
||||||
if (!val) return ''
|
if (!val) return ''
|
||||||
return {label: val.title, id: val.id}
|
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 []
|
if (!val || !val.length) return []
|
||||||
return val.map((item) => item.title)
|
return val.map((item) => item.title)
|
||||||
},
|
},
|
||||||
lessonsOneListFormatter(val) {
|
dealsOneListFormatter(val) {
|
||||||
if (!val) return ''
|
if (!val) return ''
|
||||||
return val.title
|
return val.title
|
||||||
},
|
},
|
||||||
lessonsManyListFormatterEdit(val) {
|
dealsManyListFormatterEdit(val) {
|
||||||
if (!val || !val.length) return []
|
if (!val || !val.length) return []
|
||||||
return val.map((item) => {
|
return val.map((item) => {
|
||||||
return {id: item.id, label: item.title}
|
return {id: item.id, label: item.title}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
lessonsOneListFormatterEdit(val) {
|
dealsOneListFormatterEdit(val) {
|
||||||
if (!val) return ''
|
if (!val) return ''
|
||||||
return {label: val.title, id: val.id}
|
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 React, { ReactNode, useEffect, useState } from 'react'
|
||||||
import { useState } from 'react'
|
|
||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
import { mdiForwardburger, mdiBackburger, mdiMenu } from '@mdi/js'
|
import { mdiForwardburger, mdiBackburger, mdiMenu } from '@mdi/js'
|
||||||
import menuAside from '../menuAside'
|
import menuAside from '../menuAside'
|
||||||
|
|||||||
@ -33,36 +33,44 @@ const menuAside: MenuAsideItem[] = [
|
|||||||
permissions: 'READ_PERMISSIONS'
|
permissions: 'READ_PERMISSIONS'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
href: '/courses/courses-list',
|
href: '/pipeline_stages/pipeline_stages-list',
|
||||||
label: 'Courses',
|
label: 'Pipeline stages',
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
icon: 'mdiSchool' in icon ? icon['mdiSchool' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
icon: 'mdiFormatListBulleted' in icon ? icon['mdiFormatListBulleted' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
||||||
permissions: 'READ_COURSES'
|
permissions: 'READ_PIPELINE_STAGES'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
href: '/lessons/lessons-list',
|
href: '/leads/leads-list',
|
||||||
label: 'Lessons',
|
label: 'Leads',
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
icon: 'mdiBookOpen' in icon ? icon['mdiBookOpen' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
icon: 'mdiAccountPlus' in icon ? icon['mdiAccountPlus' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
||||||
permissions: 'READ_LESSONS'
|
permissions: 'READ_LEADS'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
href: '/enrollments/enrollments-list',
|
href: '/contacts/contacts-list',
|
||||||
label: 'Enrollments',
|
label: 'Contacts',
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
icon: 'mdiAccountMultiple' in icon ? icon['mdiAccountMultiple' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
icon: 'mdiAccount' in icon ? icon['mdiAccount' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
||||||
permissions: 'READ_ENROLLMENTS'
|
permissions: 'READ_CONTACTS'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
href: '/progress/progress-list',
|
href: '/deals/deals-list',
|
||||||
label: 'Progress',
|
label: 'Deals',
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
icon: 'mdiCheckCircle' in icon ? icon['mdiCheckCircle' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
icon: 'mdiBriefcase' in icon ? icon['mdiBriefcase' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
||||||
permissions: 'READ_PROGRESS'
|
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',
|
href: '/profile',
|
||||||
|
|||||||
@ -149,10 +149,10 @@ function MyApp({ Component, pageProps }: AppPropsWithLayout) {
|
|||||||
setStepsEnabled(false);
|
setStepsEnabled(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const title = 'Instructor-Student LMS'
|
const title = 'Sales Pipeline CRM'
|
||||||
const description = "Instructor-student LMS for courses, lessons, enrollments, and progress tracking."
|
const description = "Sales Pipeline CRM for managing leads, deals, contacts, activities and automated follow-ups."
|
||||||
const url = "https://flatlogic.com/"
|
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 imageWidth = '1920'
|
||||||
const imageHeight = '960'
|
const imageHeight = '960'
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import { SelectFieldMany } from "../../components/SelectFieldMany";
|
|||||||
import { SwitchField } from '../../components/SwitchField'
|
import { SwitchField } from '../../components/SwitchField'
|
||||||
import {RichTextField} from "../../components/RichTextField";
|
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 { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import {saveFile} from "../../helpers/fileSaver";
|
import {saveFile} from "../../helpers/fileSaver";
|
||||||
@ -34,13 +34,13 @@ import ImageField from "../../components/ImageField";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const EditCourses = () => {
|
const EditActivities = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
const initVals = {
|
const initVals = {
|
||||||
|
|
||||||
|
|
||||||
'title': '',
|
'subject': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -72,7 +72,6 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
description: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -85,6 +84,7 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
activity_type: '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -106,6 +106,7 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
start: new Date(),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -118,7 +119,6 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
instructor: null,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -134,13 +134,13 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end: new Date(),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
category: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -164,11 +164,11 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
completed: false,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
level: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -200,9 +200,9 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
thumbnail: [],
|
|
||||||
|
|
||||||
|
|
||||||
|
owner: null,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -220,7 +220,6 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
published: false,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -231,6 +230,7 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
related_deal: null,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -246,7 +246,6 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
start_date: new Date(),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -259,6 +258,7 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
related_lead: null,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -268,63 +268,7 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
notes: '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end_date: new Date(),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'price': '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'language': '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -351,44 +295,44 @@ const EditCourses = () => {
|
|||||||
}
|
}
|
||||||
const [initialValues, setInitialValues] = useState(initVals)
|
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(() => {
|
useEffect(() => {
|
||||||
dispatch(fetch({ id: coursesId }))
|
dispatch(fetch({ id: activitiesId }))
|
||||||
}, [coursesId])
|
}, [activitiesId])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof courses === 'object') {
|
if (typeof activities === 'object') {
|
||||||
setInitialValues(courses)
|
setInitialValues(activities)
|
||||||
}
|
}
|
||||||
}, [courses])
|
}, [activities])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof courses === 'object') {
|
if (typeof activities === 'object') {
|
||||||
|
|
||||||
const newInitialVal = {...initVals};
|
const newInitialVal = {...initVals};
|
||||||
|
|
||||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (courses)[el])
|
Object.keys(initVals).forEach(el => newInitialVal[el] = (activities)[el])
|
||||||
|
|
||||||
setInitialValues(newInitialVal);
|
setInitialValues(newInitialVal);
|
||||||
}
|
}
|
||||||
}, [courses])
|
}, [activities])
|
||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
await dispatch(update({ id: coursesId, data }))
|
await dispatch(update({ id: activitiesId, data }))
|
||||||
await router.push('/courses/courses-list')
|
await router.push('/activities/activities-list')
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('Edit courses')}</title>
|
<title>{getPageTitle('Edit activities')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit courses'} main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit activities'} main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox>
|
<CardBox>
|
||||||
@ -402,11 +346,11 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
label="Title"
|
label="Subject"
|
||||||
>
|
>
|
||||||
<Field
|
<Field
|
||||||
name="title"
|
name="subject"
|
||||||
placeholder="Title"
|
placeholder="Subject"
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@ -442,13 +386,6 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FormField label='Description' hasTextareaHeight>
|
|
||||||
<Field
|
|
||||||
name='description'
|
|
||||||
id='description'
|
|
||||||
component={RichTextField}
|
|
||||||
></Field>
|
|
||||||
</FormField>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -459,107 +396,18 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField label="ActivityType" labelFor="activity_type">
|
||||||
|
<Field name="activity_type" id="activity_type" component="select">
|
||||||
|
|
||||||
|
<option value="Call">Call</option>
|
||||||
|
|
||||||
|
<option value="Meeting">Meeting</option>
|
||||||
|
|
||||||
|
<option value="Email">Email</option>
|
||||||
|
|
||||||
|
<option value="Task">Task</option>
|
||||||
|
|
||||||
|
<option value="FollowUp">FollowUp</option>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<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">
|
|
||||||
|
|
||||||
<option value="Programming">Programming</option>
|
|
||||||
|
|
||||||
<option value="Design">Design</option>
|
|
||||||
|
|
||||||
<option value="Math">Math</option>
|
|
||||||
|
|
||||||
<option value="Language">Language</option>
|
|
||||||
|
|
||||||
<option value="Business">Business</option>
|
|
||||||
|
|
||||||
<option value="Other">Other</option>
|
|
||||||
|
|
||||||
</Field>
|
</Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
@ -588,21 +436,28 @@ 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>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -624,6 +479,20 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -640,21 +509,6 @@ 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>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -674,14 +528,10 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField label='Completed' labelFor='completed'>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FormField label='Published' labelFor='published'>
|
|
||||||
<Field
|
<Field
|
||||||
name='published'
|
name='completed'
|
||||||
id='published'
|
id='completed'
|
||||||
component={SwitchField}
|
component={SwitchField}
|
||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
@ -708,20 +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,73 +567,33 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField label='Owner' labelFor='owner'>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<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"
|
|
||||||
>
|
|
||||||
<Field
|
<Field
|
||||||
type="number"
|
name='owner'
|
||||||
name="price"
|
id='owner'
|
||||||
placeholder="Price"
|
component={SelectField}
|
||||||
/>
|
options={initialValues.owner}
|
||||||
|
itemRef={'users'}
|
||||||
|
|
||||||
|
|
||||||
|
showField={'firstName'}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -822,13 +618,42 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
label="Language"
|
|
||||||
>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField label='RelatedDeal' labelFor='related_deal'>
|
||||||
<Field
|
<Field
|
||||||
name="language"
|
name='related_deal'
|
||||||
placeholder="Language"
|
id='related_deal'
|
||||||
/>
|
component={SelectField}
|
||||||
|
options={initialValues.related_deal}
|
||||||
|
itemRef={'deals'}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
showField={'title'}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -850,6 +675,86 @@ const EditCourses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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>
|
<BaseButtons>
|
||||||
<BaseButton type="submit" color="info" label="Submit" />
|
<BaseButton type="submit" color="info" label="Submit" />
|
||||||
<BaseButton type="reset" color="info" outline label="Reset" />
|
<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>
|
</BaseButtons>
|
||||||
</Form>
|
</Form>
|
||||||
</Formik>
|
</Formik>
|
||||||
@ -873,11 +778,11 @@ const EditCourses = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
EditCourses.getLayout = function getLayout(page: ReactElement) {
|
EditActivities.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'UPDATE_COURSES'}
|
permission={'UPDATE_ACTIVITIES'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 { SwitchField } from '../../components/SwitchField'
|
||||||
import {RichTextField} from "../../components/RichTextField";
|
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 { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import {saveFile} from "../../helpers/fileSaver";
|
import {saveFile} from "../../helpers/fileSaver";
|
||||||
@ -34,13 +34,13 @@ import ImageField from "../../components/ImageField";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const EditCoursesPage = () => {
|
const EditActivitiesPage = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
const initVals = {
|
const initVals = {
|
||||||
|
|
||||||
|
|
||||||
'title': '',
|
'subject': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -72,7 +72,6 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
description: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -85,6 +84,7 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
activity_type: '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -106,6 +106,7 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
start: new Date(),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -118,7 +119,6 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
instructor: null,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -134,13 +134,13 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end: new Date(),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
category: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -164,11 +164,11 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
completed: false,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
level: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -200,9 +200,9 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
thumbnail: [],
|
|
||||||
|
|
||||||
|
|
||||||
|
owner: null,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -220,7 +220,6 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
published: false,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -231,6 +230,7 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
related_deal: null,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -246,7 +246,6 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
start_date: new Date(),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -259,6 +258,7 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
related_lead: null,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -268,63 +268,7 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
notes: '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end_date: new Date(),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'price': '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'language': '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -351,7 +295,7 @@ const EditCoursesPage = () => {
|
|||||||
}
|
}
|
||||||
const [initialValues, setInitialValues] = useState(initVals)
|
const [initialValues, setInitialValues] = useState(initVals)
|
||||||
|
|
||||||
const { courses } = useAppSelector((state) => state.courses)
|
const { activities } = useAppSelector((state) => state.activities)
|
||||||
|
|
||||||
|
|
||||||
const { id } = router.query
|
const { id } = router.query
|
||||||
@ -361,31 +305,31 @@ const EditCoursesPage = () => {
|
|||||||
}, [id])
|
}, [id])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof courses === 'object') {
|
if (typeof activities === 'object') {
|
||||||
setInitialValues(courses)
|
setInitialValues(activities)
|
||||||
}
|
}
|
||||||
}, [courses])
|
}, [activities])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof courses === 'object') {
|
if (typeof activities === 'object') {
|
||||||
const newInitialVal = {...initVals};
|
const newInitialVal = {...initVals};
|
||||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (courses)[el])
|
Object.keys(initVals).forEach(el => newInitialVal[el] = (activities)[el])
|
||||||
setInitialValues(newInitialVal);
|
setInitialValues(newInitialVal);
|
||||||
}
|
}
|
||||||
}, [courses])
|
}, [activities])
|
||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
await dispatch(update({ id: id, data }))
|
await dispatch(update({ id: id, data }))
|
||||||
await router.push('/courses/courses-list')
|
await router.push('/activities/activities-list')
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('Edit courses')}</title>
|
<title>{getPageTitle('Edit activities')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit courses'} main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit activities'} main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox>
|
<CardBox>
|
||||||
@ -399,11 +343,11 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
label="Title"
|
label="Subject"
|
||||||
>
|
>
|
||||||
<Field
|
<Field
|
||||||
name="title"
|
name="subject"
|
||||||
placeholder="Title"
|
placeholder="Subject"
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@ -439,13 +383,6 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FormField label='Description' hasTextareaHeight>
|
|
||||||
<Field
|
|
||||||
name='description'
|
|
||||||
id='description'
|
|
||||||
component={RichTextField}
|
|
||||||
></Field>
|
|
||||||
</FormField>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -456,107 +393,18 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField label="ActivityType" labelFor="activity_type">
|
||||||
|
<Field name="activity_type" id="activity_type" component="select">
|
||||||
|
|
||||||
|
<option value="Call">Call</option>
|
||||||
|
|
||||||
|
<option value="Meeting">Meeting</option>
|
||||||
|
|
||||||
|
<option value="Email">Email</option>
|
||||||
|
|
||||||
|
<option value="Task">Task</option>
|
||||||
|
|
||||||
|
<option value="FollowUp">FollowUp</option>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<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">
|
|
||||||
|
|
||||||
<option value="Programming">Programming</option>
|
|
||||||
|
|
||||||
<option value="Design">Design</option>
|
|
||||||
|
|
||||||
<option value="Math">Math</option>
|
|
||||||
|
|
||||||
<option value="Language">Language</option>
|
|
||||||
|
|
||||||
<option value="Business">Business</option>
|
|
||||||
|
|
||||||
<option value="Other">Other</option>
|
|
||||||
|
|
||||||
</Field>
|
</Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
@ -585,21 +433,28 @@ 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>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -621,6 +476,20 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -637,21 +506,6 @@ 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>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -671,14 +525,10 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField label='Completed' labelFor='completed'>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FormField label='Published' labelFor='published'>
|
|
||||||
<Field
|
<Field
|
||||||
name='published'
|
name='completed'
|
||||||
id='published'
|
id='completed'
|
||||||
component={SwitchField}
|
component={SwitchField}
|
||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
@ -705,20 +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,73 +564,33 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField label='Owner' labelFor='owner'>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<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"
|
|
||||||
>
|
|
||||||
<Field
|
<Field
|
||||||
type="number"
|
name='owner'
|
||||||
name="price"
|
id='owner'
|
||||||
placeholder="Price"
|
component={SelectField}
|
||||||
/>
|
options={initialValues.owner}
|
||||||
|
itemRef={'users'}
|
||||||
|
|
||||||
|
|
||||||
|
showField={'firstName'}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -819,13 +615,42 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
label="Language"
|
|
||||||
>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField label='RelatedDeal' labelFor='related_deal'>
|
||||||
<Field
|
<Field
|
||||||
name="language"
|
name='related_deal'
|
||||||
placeholder="Language"
|
id='related_deal'
|
||||||
/>
|
component={SelectField}
|
||||||
|
options={initialValues.related_deal}
|
||||||
|
itemRef={'deals'}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
showField={'title'}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -847,6 +672,86 @@ const EditCoursesPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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>
|
<BaseButtons>
|
||||||
<BaseButton type="submit" color="info" label="Submit" />
|
<BaseButton type="submit" color="info" label="Submit" />
|
||||||
<BaseButton type="reset" color="info" outline label="Reset" />
|
<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>
|
</BaseButtons>
|
||||||
</Form>
|
</Form>
|
||||||
</Formik>
|
</Formik>
|
||||||
@ -870,11 +775,11 @@ const EditCoursesPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
EditCoursesPage.getLayout = function getLayout(page: ReactElement) {
|
EditActivitiesPage.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'UPDATE_COURSES'}
|
permission={'UPDATE_ACTIVITIES'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 SectionMain from '../../components/SectionMain'
|
||||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||||
import { getPageTitle } from '../../config'
|
import { getPageTitle } from '../../config'
|
||||||
import TableCourses from '../../components/Courses/TableCourses'
|
import TableActivities from '../../components/Activities/TableActivities'
|
||||||
import BaseButton from '../../components/BaseButton'
|
import BaseButton from '../../components/BaseButton'
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
||||||
import CardBoxModal from "../../components/CardBoxModal";
|
import CardBoxModal from "../../components/CardBoxModal";
|
||||||
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
||||||
import {setRefetch, uploadCsv} from '../../stores/courses/coursesSlice';
|
import {setRefetch, uploadCsv} from '../../stores/activities/activitiesSlice';
|
||||||
|
|
||||||
|
|
||||||
import {hasPermission} from "../../helpers/userPermissions";
|
import {hasPermission} from "../../helpers/userPermissions";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const CoursesTablesPage = () => {
|
const ActivitiesTablesPage = () => {
|
||||||
const [filterItems, setFilterItems] = useState([]);
|
const [filterItems, setFilterItems] = useState([]);
|
||||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||||
const [isModalActive, setIsModalActive] = useState(false);
|
const [isModalActive, setIsModalActive] = useState(false);
|
||||||
@ -34,20 +34,28 @@ const CoursesTablesPage = () => {
|
|||||||
const dispatch = useAppDispatch();
|
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: 'Instructor', title: 'instructor'},
|
{label: 'Start', title: 'start', date: 'true'},{label: 'End', title: 'end', date: 'true'},
|
||||||
|
|
||||||
|
|
||||||
|
{label: 'Owner', title: 'owner'},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{label: 'Category', title: 'category', type: 'enum', options: ['Programming','Design','Math','Language','Business','Other']},{label: 'Level', title: 'level', type: 'enum', options: ['Beginner','Intermediate','Advanced']},
|
{label: 'RelatedDeal', title: 'related_deal'},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{label: 'RelatedLead', title: 'related_lead'},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{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 = () => {
|
const addFilter = () => {
|
||||||
@ -64,13 +72,13 @@ const CoursesTablesPage = () => {
|
|||||||
setFilterItems([...filterItems, newItem]);
|
setFilterItems([...filterItems, newItem]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getCoursesCSV = async () => {
|
const getActivitiesCSV = async () => {
|
||||||
const response = await axios({url: '/courses?filetype=csv', method: 'GET',responseType: 'blob'});
|
const response = await axios({url: '/activities?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||||
const type = response.headers['content-type']
|
const type = response.headers['content-type']
|
||||||
const blob = new Blob([response.data], { type: type })
|
const blob = new Blob([response.data], { type: type })
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a')
|
||||||
link.href = window.URL.createObjectURL(blob)
|
link.href = window.URL.createObjectURL(blob)
|
||||||
link.download = 'coursesCSV.csv'
|
link.download = 'activitiesCSV.csv'
|
||||||
link.click()
|
link.click()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -90,15 +98,15 @@ const CoursesTablesPage = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('Courses')}</title>
|
<title>{getPageTitle('Activities')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Courses" main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Activities" main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
<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
|
<BaseButton
|
||||||
className={'mr-3'}
|
className={'mr-3'}
|
||||||
@ -106,7 +114,7 @@ const CoursesTablesPage = () => {
|
|||||||
label='Filter'
|
label='Filter'
|
||||||
onClick={addFilter}
|
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 && (
|
{hasCreatePermission && (
|
||||||
<BaseButton
|
<BaseButton
|
||||||
@ -121,13 +129,13 @@ const CoursesTablesPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='md:inline-flex items-center ms-auto'>
|
<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>
|
</div>
|
||||||
|
|
||||||
</CardBox>
|
</CardBox>
|
||||||
|
|
||||||
<CardBox className="mb-6" hasTable>
|
<CardBox className="mb-6" hasTable>
|
||||||
<TableCourses
|
<TableActivities
|
||||||
filterItems={filterItems}
|
filterItems={filterItems}
|
||||||
setFilterItems={setFilterItems}
|
setFilterItems={setFilterItems}
|
||||||
filters={filters}
|
filters={filters}
|
||||||
@ -155,11 +163,11 @@ const CoursesTablesPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
CoursesTablesPage.getLayout = function getLayout(page: ReactElement) {
|
ActivitiesTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'READ_COURSES'}
|
permission={'READ_ACTIVITIES'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||||
import {RichTextField} from "../../components/RichTextField";
|
import {RichTextField} from "../../components/RichTextField";
|
||||||
|
|
||||||
import { create } from '../../stores/courses/coursesSlice'
|
import { create } from '../../stores/activities/activitiesSlice'
|
||||||
import { useAppDispatch } from '../../stores/hooks'
|
import { useAppDispatch } from '../../stores/hooks'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
@ -30,7 +30,7 @@ import moment from 'moment';
|
|||||||
const initialValues = {
|
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: '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
notes: '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end_date: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
price: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
language: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -210,7 +177,7 @@ const initialValues = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const CoursesNew = () => {
|
const ActivitiesNew = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
|
|
||||||
@ -222,7 +189,7 @@ const CoursesNew = () => {
|
|||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
await dispatch(create(data))
|
await dispatch(create(data))
|
||||||
await router.push('/courses/courses-list')
|
await router.push('/activities/activities-list')
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -242,8 +209,8 @@ const CoursesNew = () => {
|
|||||||
dateRangeStart && dateRangeEnd ?
|
dateRangeStart && dateRangeEnd ?
|
||||||
{
|
{
|
||||||
...initialValues,
|
...initialValues,
|
||||||
start_date: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
|
start: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
|
||||||
end_date: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
|
end: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
|
||||||
} : initialValues
|
} : initialValues
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -254,11 +221,11 @@ const CoursesNew = () => {
|
|||||||
|
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
label="Title"
|
label="Subject"
|
||||||
>
|
>
|
||||||
<Field
|
<Field
|
||||||
name="title"
|
name="subject"
|
||||||
placeholder="Title"
|
placeholder="Subject"
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</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="ActivityType" labelFor="activity_type">
|
||||||
|
<Field name="activity_type" id="activity_type" component="select">
|
||||||
|
|
||||||
|
<option value="Call">Call</option>
|
||||||
|
|
||||||
|
<option value="Meeting">Meeting</option>
|
||||||
|
|
||||||
|
<option value="Email">Email</option>
|
||||||
|
|
||||||
|
<option value="Task">Task</option>
|
||||||
|
|
||||||
|
<option value="FollowUp">FollowUp</option>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<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">
|
|
||||||
|
|
||||||
<option value="Programming">Programming</option>
|
|
||||||
|
|
||||||
<option value="Design">Design</option>
|
|
||||||
|
|
||||||
<option value="Math">Math</option>
|
|
||||||
|
|
||||||
<option value="Language">Language</option>
|
|
||||||
|
|
||||||
<option value="Business">Business</option>
|
|
||||||
|
|
||||||
<option value="Other">Other</option>
|
|
||||||
|
|
||||||
</Field>
|
</Field>
|
||||||
</FormField>
|
</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>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -454,48 +385,10 @@ const CoursesNew = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField label='Completed' labelFor='completed'>
|
||||||
|
|
||||||
<FormField>
|
|
||||||
<Field
|
<Field
|
||||||
label='Thumbnail'
|
name='completed'
|
||||||
color='info'
|
id='completed'
|
||||||
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'
|
|
||||||
component={SwitchField}
|
component={SwitchField}
|
||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</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>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -556,14 +451,8 @@ const CoursesNew = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FormField
|
<FormField label="RelatedDeal" labelFor="related_deal">
|
||||||
label="EndDate"
|
<Field name="related_deal" id="related_deal" component={SelectField} options={[]} itemRef={'deals'}></Field>
|
||||||
>
|
|
||||||
<Field
|
|
||||||
type="datetime-local"
|
|
||||||
name="end_date"
|
|
||||||
placeholder="EndDate"
|
|
||||||
/>
|
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -588,43 +477,12 @@ const CoursesNew = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
label="Price"
|
|
||||||
>
|
|
||||||
<Field
|
|
||||||
type="number"
|
|
||||||
name="price"
|
|
||||||
placeholder="Price"
|
|
||||||
/>
|
|
||||||
</FormField>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField label="RelatedLead" labelFor="related_lead">
|
||||||
|
<Field name="related_lead" id="related_lead" component={SelectField} options={[]} itemRef={'leads'}></Field>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
label="Language"
|
|
||||||
>
|
|
||||||
<Field
|
|
||||||
name="language"
|
|
||||||
placeholder="Language"
|
|
||||||
/>
|
|
||||||
</FormField>
|
</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>
|
<BaseButtons>
|
||||||
<BaseButton type="submit" color="info" label="Submit" />
|
<BaseButton type="submit" color="info" label="Submit" />
|
||||||
<BaseButton type="reset" color="info" outline label="Reset" />
|
<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>
|
</BaseButtons>
|
||||||
</Form>
|
</Form>
|
||||||
</Formik>
|
</Formik>
|
||||||
@ -665,11 +539,11 @@ const CoursesNew = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
CoursesNew.getLayout = function getLayout(page: ReactElement) {
|
ActivitiesNew.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'CREATE_COURSES'}
|
permission={'CREATE_ACTIVITIES'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 SectionMain from '../../components/SectionMain'
|
||||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||||
import { getPageTitle } from '../../config'
|
import { getPageTitle } from '../../config'
|
||||||
import TableCourses from '../../components/Courses/TableCourses'
|
import TableActivities from '../../components/Activities/TableActivities'
|
||||||
import BaseButton from '../../components/BaseButton'
|
import BaseButton from '../../components/BaseButton'
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
||||||
import CardBoxModal from "../../components/CardBoxModal";
|
import CardBoxModal from "../../components/CardBoxModal";
|
||||||
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
||||||
import {setRefetch, uploadCsv} from '../../stores/courses/coursesSlice';
|
import {setRefetch, uploadCsv} from '../../stores/activities/activitiesSlice';
|
||||||
|
|
||||||
|
|
||||||
import {hasPermission} from "../../helpers/userPermissions";
|
import {hasPermission} from "../../helpers/userPermissions";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const CoursesTablesPage = () => {
|
const ActivitiesTablesPage = () => {
|
||||||
const [filterItems, setFilterItems] = useState([]);
|
const [filterItems, setFilterItems] = useState([]);
|
||||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||||
const [isModalActive, setIsModalActive] = useState(false);
|
const [isModalActive, setIsModalActive] = useState(false);
|
||||||
@ -34,20 +34,28 @@ const CoursesTablesPage = () => {
|
|||||||
const dispatch = useAppDispatch();
|
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: 'Instructor', title: 'instructor'},
|
{label: 'Start', title: 'start', date: 'true'},{label: 'End', title: 'end', date: 'true'},
|
||||||
|
|
||||||
|
|
||||||
|
{label: 'Owner', title: 'owner'},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{label: 'Category', title: 'category', type: 'enum', options: ['Programming','Design','Math','Language','Business','Other']},{label: 'Level', title: 'level', type: 'enum', options: ['Beginner','Intermediate','Advanced']},
|
{label: 'RelatedDeal', title: 'related_deal'},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{label: 'RelatedLead', title: 'related_lead'},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{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 = () => {
|
const addFilter = () => {
|
||||||
@ -64,13 +72,13 @@ const CoursesTablesPage = () => {
|
|||||||
setFilterItems([...filterItems, newItem]);
|
setFilterItems([...filterItems, newItem]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getCoursesCSV = async () => {
|
const getActivitiesCSV = async () => {
|
||||||
const response = await axios({url: '/courses?filetype=csv', method: 'GET',responseType: 'blob'});
|
const response = await axios({url: '/activities?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||||
const type = response.headers['content-type']
|
const type = response.headers['content-type']
|
||||||
const blob = new Blob([response.data], { type: type })
|
const blob = new Blob([response.data], { type: type })
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a')
|
||||||
link.href = window.URL.createObjectURL(blob)
|
link.href = window.URL.createObjectURL(blob)
|
||||||
link.download = 'coursesCSV.csv'
|
link.download = 'activitiesCSV.csv'
|
||||||
link.click()
|
link.click()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -90,15 +98,15 @@ const CoursesTablesPage = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('Courses')}</title>
|
<title>{getPageTitle('Activities')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Courses" main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Activities" main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
<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
|
<BaseButton
|
||||||
className={'mr-3'}
|
className={'mr-3'}
|
||||||
@ -106,7 +114,7 @@ const CoursesTablesPage = () => {
|
|||||||
label='Filter'
|
label='Filter'
|
||||||
onClick={addFilter}
|
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 && (
|
{hasCreatePermission && (
|
||||||
<BaseButton
|
<BaseButton
|
||||||
@ -119,14 +127,14 @@ const CoursesTablesPage = () => {
|
|||||||
<div className='md:inline-flex items-center ms-auto'>
|
<div className='md:inline-flex items-center ms-auto'>
|
||||||
<div id='delete-rows-button'></div>
|
<div id='delete-rows-button'></div>
|
||||||
|
|
||||||
<Link href={'/courses/courses-list'}>
|
<Link href={'/activities/activities-list'}>
|
||||||
Back to <span className='capitalize'>calendar</span>
|
Back to <span className='capitalize'>calendar</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</CardBox>
|
</CardBox>
|
||||||
<CardBox className="mb-6" hasTable>
|
<CardBox className="mb-6" hasTable>
|
||||||
<TableCourses
|
<TableActivities
|
||||||
filterItems={filterItems}
|
filterItems={filterItems}
|
||||||
setFilterItems={setFilterItems}
|
setFilterItems={setFilterItems}
|
||||||
filters={filters}
|
filters={filters}
|
||||||
@ -153,11 +161,11 @@ const CoursesTablesPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
CoursesTablesPage.getLayout = function getLayout(page: ReactElement) {
|
ActivitiesTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'READ_COURSES'}
|
permission={'READ_ACTIVITIES'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 dayjs from "dayjs";
|
||||||
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
||||||
import {useRouter} from "next/router";
|
import {useRouter} from "next/router";
|
||||||
import { fetch } from '../../stores/progress/progressSlice'
|
import { fetch } from '../../stores/activities/activitiesSlice'
|
||||||
import {saveFile} from "../../helpers/fileSaver";
|
import {saveFile} from "../../helpers/fileSaver";
|
||||||
import dataFormatter from '../../helpers/dataFormatter';
|
import dataFormatter from '../../helpers/dataFormatter';
|
||||||
import ImageField from "../../components/ImageField";
|
import ImageField from "../../components/ImageField";
|
||||||
@ -21,10 +21,10 @@ import {SwitchField} from "../../components/SwitchField";
|
|||||||
import FormField from "../../components/FormField";
|
import FormField from "../../components/FormField";
|
||||||
|
|
||||||
|
|
||||||
const ProgressView = () => {
|
const ActivitiesView = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
const { progress } = useAppSelector((state) => state.progress)
|
const { activities } = useAppSelector((state) => state.activities)
|
||||||
|
|
||||||
|
|
||||||
const { id } = router.query;
|
const { id } = router.query;
|
||||||
@ -42,24 +42,105 @@ const ProgressView = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('View progress')}</title>
|
<title>{getPageTitle('View activities')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View progress')} main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View activities')} main>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
color='info'
|
color='info'
|
||||||
label='Edit'
|
label='Edit'
|
||||||
href={`/progress/progress-edit/?id=${id}`}
|
href={`/activities/activities-edit/?id=${id}`}
|
||||||
/>
|
/>
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox>
|
<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>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -89,6 +170,18 @@ const ProgressView = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -102,86 +195,6 @@ const ProgressView = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'mb-4'}>
|
|
||||||
<p className={'block font-bold mb-2'}>Enrollment</p>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<p>{progress?.enrollment?.enrollment_label ?? 'No data'}</p>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<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'>
|
<FormField label='Completed'>
|
||||||
<SwitchField
|
<SwitchField
|
||||||
field={{name: 'completed', value: progress?.completed}}
|
field={{name: 'completed', value: activities?.completed}}
|
||||||
form={{setFieldValue: () => null}}
|
form={{setFieldValue: () => null}}
|
||||||
disabled
|
disabled
|
||||||
/>
|
/>
|
||||||
@ -230,33 +243,6 @@ 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>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -269,8 +255,26 @@ const ProgressView = () => {
|
|||||||
|
|
||||||
|
|
||||||
<div className={'mb-4'}>
|
<div className={'mb-4'}>
|
||||||
<p className={'block font-bold mb-2'}>Score</p>
|
<p className={'block font-bold mb-2'}>Owner</p>
|
||||||
<p>{progress?.score || 'No data'}</p>
|
|
||||||
|
|
||||||
|
<p>{activities?.owner?.firstName ?? 'No data'}</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -297,12 +301,32 @@ const ProgressView = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'mb-4'}>
|
<div className={'mb-4'}>
|
||||||
<p className={'block font-bold mb-2'}>Attempts</p>
|
<p className={'block font-bold mb-2'}>RelatedDeal</p>
|
||||||
<p>{progress?.attempts || 'No data'}</p>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p>{activities?.related_deal?.title ?? 'No data'}</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -321,6 +345,83 @@ const ProgressView = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>RelatedLead</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p>{activities?.related_lead?.name ?? 'No data'}</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Notes</p>
|
||||||
|
{activities.notes
|
||||||
|
? <p dangerouslySetInnerHTML={{__html: activities.notes}}/>
|
||||||
|
: <p>No data</p>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -339,7 +440,7 @@ const ProgressView = () => {
|
|||||||
<BaseButton
|
<BaseButton
|
||||||
color='info'
|
color='info'
|
||||||
label='Back'
|
label='Back'
|
||||||
onClick={() => router.push('/progress/progress-list')}
|
onClick={() => router.push('/activities/activities-list')}
|
||||||
/>
|
/>
|
||||||
</CardBox>
|
</CardBox>
|
||||||
</SectionMain>
|
</SectionMain>
|
||||||
@ -347,11 +448,11 @@ const ProgressView = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
ProgressView.getLayout = function getLayout(page: ReactElement) {
|
ActivitiesView.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'READ_PROGRESS'}
|
permission={'READ_ACTIVITIES'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 { SwitchField } from '../../components/SwitchField'
|
||||||
import {RichTextField} from "../../components/RichTextField";
|
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 { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import {saveFile} from "../../helpers/fileSaver";
|
import {saveFile} from "../../helpers/fileSaver";
|
||||||
@ -34,15 +34,15 @@ import ImageField from "../../components/ImageField";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const EditProgress = () => {
|
const EditContacts = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
const initVals = {
|
const initVals = {
|
||||||
|
|
||||||
|
|
||||||
|
'name': '',
|
||||||
|
|
||||||
|
|
||||||
note: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -68,6 +68,7 @@ const EditProgress = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'email': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -90,12 +91,12 @@ const EditProgress = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
enrollment: null,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'phone': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -118,12 +119,12 @@ const EditProgress = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
lesson: null,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'title': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -136,7 +137,6 @@ const EditProgress = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
completed: false,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -152,6 +152,7 @@ const EditProgress = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'company': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -162,7 +163,6 @@ const EditProgress = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
completed_at: new Date(),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -180,7 +180,6 @@ const EditProgress = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
'score': '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -203,6 +202,7 @@ const EditProgress = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
owner: null,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -210,11 +210,11 @@ const EditProgress = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
notes: '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
attempts: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -239,44 +239,44 @@ const EditProgress = () => {
|
|||||||
}
|
}
|
||||||
const [initialValues, setInitialValues] = useState(initVals)
|
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(() => {
|
useEffect(() => {
|
||||||
dispatch(fetch({ id: progressId }))
|
dispatch(fetch({ id: contactsId }))
|
||||||
}, [progressId])
|
}, [contactsId])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof progress === 'object') {
|
if (typeof contacts === 'object') {
|
||||||
setInitialValues(progress)
|
setInitialValues(contacts)
|
||||||
}
|
}
|
||||||
}, [progress])
|
}, [contacts])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof progress === 'object') {
|
if (typeof contacts === 'object') {
|
||||||
|
|
||||||
const newInitialVal = {...initVals};
|
const newInitialVal = {...initVals};
|
||||||
|
|
||||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (progress)[el])
|
Object.keys(initVals).forEach(el => newInitialVal[el] = (contacts)[el])
|
||||||
|
|
||||||
setInitialValues(newInitialVal);
|
setInitialValues(newInitialVal);
|
||||||
}
|
}
|
||||||
}, [progress])
|
}, [contacts])
|
||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
await dispatch(update({ id: progressId, data }))
|
await dispatch(update({ id: contactsId, data }))
|
||||||
await router.push('/progress/progress-list')
|
await router.push('/contacts/contacts-list')
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('Edit progress')}</title>
|
<title>{getPageTitle('Edit contacts')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit progress'} main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit contacts'} main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox>
|
<CardBox>
|
||||||
@ -286,249 +286,15 @@ const EditProgress = () => {
|
|||||||
onSubmit={(values) => handleSubmit(values)}
|
onSubmit={(values) => handleSubmit(values)}
|
||||||
>
|
>
|
||||||
<Form>
|
<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
|
<FormField
|
||||||
label="Score"
|
label="Name"
|
||||||
>
|
>
|
||||||
<Field
|
<Field
|
||||||
type="number"
|
name="name"
|
||||||
name="score"
|
placeholder="Name"
|
||||||
placeholder="Score"
|
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@ -561,12 +327,11 @@ const EditProgress = () => {
|
|||||||
|
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
label="Attempts"
|
label="Email"
|
||||||
>
|
>
|
||||||
<Field
|
<Field
|
||||||
type="number"
|
name="email"
|
||||||
name="attempts"
|
placeholder="Email"
|
||||||
placeholder="Attempts"
|
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@ -585,6 +350,215 @@ const EditProgress = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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={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>
|
<BaseButtons>
|
||||||
<BaseButton type="submit" color="info" label="Submit" />
|
<BaseButton type="submit" color="info" label="Submit" />
|
||||||
<BaseButton type="reset" color="info" outline label="Reset" />
|
<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>
|
</BaseButtons>
|
||||||
</Form>
|
</Form>
|
||||||
</Formik>
|
</Formik>
|
||||||
@ -606,11 +580,11 @@ const EditProgress = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
EditProgress.getLayout = function getLayout(page: ReactElement) {
|
EditContacts.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'UPDATE_PROGRESS'}
|
permission={'UPDATE_CONTACTS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 { SwitchField } from '../../components/SwitchField'
|
||||||
import {RichTextField} from "../../components/RichTextField";
|
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 { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import {saveFile} from "../../helpers/fileSaver";
|
import {saveFile} from "../../helpers/fileSaver";
|
||||||
@ -34,15 +34,15 @@ import ImageField from "../../components/ImageField";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const EditProgressPage = () => {
|
const EditContactsPage = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
const initVals = {
|
const initVals = {
|
||||||
|
|
||||||
|
|
||||||
|
'name': '',
|
||||||
|
|
||||||
|
|
||||||
note: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -68,6 +68,7 @@ const EditProgressPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'email': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -90,12 +91,12 @@ const EditProgressPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
enrollment: null,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'phone': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -118,12 +119,12 @@ const EditProgressPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
lesson: null,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'title': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -136,7 +137,6 @@ const EditProgressPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
completed: false,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -152,6 +152,7 @@ const EditProgressPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'company': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -162,7 +163,6 @@ const EditProgressPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
completed_at: new Date(),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -180,7 +180,6 @@ const EditProgressPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
'score': '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -203,6 +202,7 @@ const EditProgressPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
owner: null,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -210,11 +210,11 @@ const EditProgressPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
notes: '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
attempts: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ const EditProgressPage = () => {
|
|||||||
}
|
}
|
||||||
const [initialValues, setInitialValues] = useState(initVals)
|
const [initialValues, setInitialValues] = useState(initVals)
|
||||||
|
|
||||||
const { progress } = useAppSelector((state) => state.progress)
|
const { contacts } = useAppSelector((state) => state.contacts)
|
||||||
|
|
||||||
|
|
||||||
const { id } = router.query
|
const { id } = router.query
|
||||||
@ -249,31 +249,31 @@ const EditProgressPage = () => {
|
|||||||
}, [id])
|
}, [id])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof progress === 'object') {
|
if (typeof contacts === 'object') {
|
||||||
setInitialValues(progress)
|
setInitialValues(contacts)
|
||||||
}
|
}
|
||||||
}, [progress])
|
}, [contacts])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof progress === 'object') {
|
if (typeof contacts === 'object') {
|
||||||
const newInitialVal = {...initVals};
|
const newInitialVal = {...initVals};
|
||||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (progress)[el])
|
Object.keys(initVals).forEach(el => newInitialVal[el] = (contacts)[el])
|
||||||
setInitialValues(newInitialVal);
|
setInitialValues(newInitialVal);
|
||||||
}
|
}
|
||||||
}, [progress])
|
}, [contacts])
|
||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
await dispatch(update({ id: id, data }))
|
await dispatch(update({ id: id, data }))
|
||||||
await router.push('/progress/progress-list')
|
await router.push('/contacts/contacts-list')
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('Edit progress')}</title>
|
<title>{getPageTitle('Edit contacts')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit progress'} main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit contacts'} main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox>
|
<CardBox>
|
||||||
@ -283,249 +283,15 @@ const EditProgressPage = () => {
|
|||||||
onSubmit={(values) => handleSubmit(values)}
|
onSubmit={(values) => handleSubmit(values)}
|
||||||
>
|
>
|
||||||
<Form>
|
<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
|
<FormField
|
||||||
label="Score"
|
label="Name"
|
||||||
>
|
>
|
||||||
<Field
|
<Field
|
||||||
type="number"
|
name="name"
|
||||||
name="score"
|
placeholder="Name"
|
||||||
placeholder="Score"
|
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@ -558,12 +324,11 @@ const EditProgressPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
label="Attempts"
|
label="Email"
|
||||||
>
|
>
|
||||||
<Field
|
<Field
|
||||||
type="number"
|
name="email"
|
||||||
name="attempts"
|
placeholder="Email"
|
||||||
placeholder="Attempts"
|
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@ -582,6 +347,215 @@ const EditProgressPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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={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>
|
<BaseButtons>
|
||||||
<BaseButton type="submit" color="info" label="Submit" />
|
<BaseButton type="submit" color="info" label="Submit" />
|
||||||
<BaseButton type="reset" color="info" outline label="Reset" />
|
<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>
|
</BaseButtons>
|
||||||
</Form>
|
</Form>
|
||||||
</Formik>
|
</Formik>
|
||||||
@ -603,11 +577,11 @@ const EditProgressPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
EditProgressPage.getLayout = function getLayout(page: ReactElement) {
|
EditContactsPage.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'UPDATE_PROGRESS'}
|
permission={'UPDATE_CONTACTS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 SectionMain from '../../components/SectionMain'
|
||||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||||
import { getPageTitle } from '../../config'
|
import { getPageTitle } from '../../config'
|
||||||
import TableProgress from '../../components/Progress/TableProgress'
|
import TableContacts from '../../components/Contacts/TableContacts'
|
||||||
import BaseButton from '../../components/BaseButton'
|
import BaseButton from '../../components/BaseButton'
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
||||||
import CardBoxModal from "../../components/CardBoxModal";
|
import CardBoxModal from "../../components/CardBoxModal";
|
||||||
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
||||||
import {setRefetch, uploadCsv} from '../../stores/progress/progressSlice';
|
import {setRefetch, uploadCsv} from '../../stores/contacts/contactsSlice';
|
||||||
|
|
||||||
|
|
||||||
import {hasPermission} from "../../helpers/userPermissions";
|
import {hasPermission} from "../../helpers/userPermissions";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const ProgressTablesPage = () => {
|
const ContactsTablesPage = () => {
|
||||||
const [filterItems, setFilterItems] = useState([]);
|
const [filterItems, setFilterItems] = useState([]);
|
||||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||||
const [isModalActive, setIsModalActive] = useState(false);
|
const [isModalActive, setIsModalActive] = useState(false);
|
||||||
@ -34,24 +34,20 @@ const ProgressTablesPage = () => {
|
|||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
|
||||||
const [filters] = useState([{label: 'Note', title: 'note'},
|
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: 'Attempts', title: 'attempts', number: 'true'},
|
|
||||||
{label: 'Score', title: 'score', number: 'true'},
|
|
||||||
{label: 'CompletedAt', title: 'completed_at', date: 'true'},
|
|
||||||
|
|
||||||
|
|
||||||
{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 = () => {
|
const addFilter = () => {
|
||||||
@ -68,13 +64,13 @@ const ProgressTablesPage = () => {
|
|||||||
setFilterItems([...filterItems, newItem]);
|
setFilterItems([...filterItems, newItem]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getProgressCSV = async () => {
|
const getContactsCSV = async () => {
|
||||||
const response = await axios({url: '/progress?filetype=csv', method: 'GET',responseType: 'blob'});
|
const response = await axios({url: '/contacts?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||||
const type = response.headers['content-type']
|
const type = response.headers['content-type']
|
||||||
const blob = new Blob([response.data], { type: type })
|
const blob = new Blob([response.data], { type: type })
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a')
|
||||||
link.href = window.URL.createObjectURL(blob)
|
link.href = window.URL.createObjectURL(blob)
|
||||||
link.download = 'progressCSV.csv'
|
link.download = 'contactsCSV.csv'
|
||||||
link.click()
|
link.click()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -94,15 +90,15 @@ const ProgressTablesPage = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('Progress')}</title>
|
<title>{getPageTitle('Contacts')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Progress" main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Contacts" main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
<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
|
<BaseButton
|
||||||
className={'mr-3'}
|
className={'mr-3'}
|
||||||
@ -110,7 +106,7 @@ const ProgressTablesPage = () => {
|
|||||||
label='Filter'
|
label='Filter'
|
||||||
onClick={addFilter}
|
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 && (
|
{hasCreatePermission && (
|
||||||
<BaseButton
|
<BaseButton
|
||||||
@ -125,13 +121,13 @@ const ProgressTablesPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='md:inline-flex items-center ms-auto'>
|
<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>
|
</div>
|
||||||
|
|
||||||
</CardBox>
|
</CardBox>
|
||||||
|
|
||||||
<CardBox className="mb-6" hasTable>
|
<CardBox className="mb-6" hasTable>
|
||||||
<TableProgress
|
<TableContacts
|
||||||
filterItems={filterItems}
|
filterItems={filterItems}
|
||||||
setFilterItems={setFilterItems}
|
setFilterItems={setFilterItems}
|
||||||
filters={filters}
|
filters={filters}
|
||||||
@ -159,11 +155,11 @@ const ProgressTablesPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressTablesPage.getLayout = function getLayout(page: ReactElement) {
|
ContactsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'READ_PROGRESS'}
|
permission={'READ_CONTACTS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||||
import {RichTextField} from "../../components/RichTextField";
|
import {RichTextField} from "../../components/RichTextField";
|
||||||
|
|
||||||
import { create } from '../../stores/progress/progressSlice'
|
import { create } from '../../stores/contacts/contactsSlice'
|
||||||
import { useAppDispatch } from '../../stores/hooks'
|
import { useAppDispatch } from '../../stores/hooks'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
@ -30,8 +30,8 @@ import moment from 'moment';
|
|||||||
const initialValues = {
|
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 router = useRouter()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ const ProgressNew = () => {
|
|||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
await dispatch(create(data))
|
await dispatch(create(data))
|
||||||
await router.push('/progress/progress-list')
|
await router.push('/contacts/contacts-list')
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -176,148 +176,13 @@ const ProgressNew = () => {
|
|||||||
<Form>
|
<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
|
<FormField
|
||||||
label="CompletedAt"
|
label="Name"
|
||||||
>
|
>
|
||||||
<Field
|
<Field
|
||||||
type="datetime-local"
|
name="name"
|
||||||
name="completed_at"
|
placeholder="Name"
|
||||||
placeholder="CompletedAt"
|
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@ -343,14 +208,184 @@ const ProgressNew = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
label="Score"
|
|
||||||
>
|
|
||||||
<Field
|
|
||||||
type="number"
|
<FormField
|
||||||
name="score"
|
label="Email"
|
||||||
placeholder="Score"
|
>
|
||||||
/>
|
<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>
|
</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>
|
<BaseButtons>
|
||||||
<BaseButton type="submit" color="info" label="Submit" />
|
<BaseButton type="submit" color="info" label="Submit" />
|
||||||
<BaseButton type="reset" color="info" outline label="Reset" />
|
<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>
|
</BaseButtons>
|
||||||
</Form>
|
</Form>
|
||||||
</Formik>
|
</Formik>
|
||||||
@ -421,11 +424,11 @@ const ProgressNew = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressNew.getLayout = function getLayout(page: ReactElement) {
|
ContactsNew.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'CREATE_PROGRESS'}
|
permission={'CREATE_CONTACTS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 SectionMain from '../../components/SectionMain'
|
||||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||||
import { getPageTitle } from '../../config'
|
import { getPageTitle } from '../../config'
|
||||||
import TableProgress from '../../components/Progress/TableProgress'
|
import TableContacts from '../../components/Contacts/TableContacts'
|
||||||
import BaseButton from '../../components/BaseButton'
|
import BaseButton from '../../components/BaseButton'
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
||||||
import CardBoxModal from "../../components/CardBoxModal";
|
import CardBoxModal from "../../components/CardBoxModal";
|
||||||
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
||||||
import {setRefetch, uploadCsv} from '../../stores/progress/progressSlice';
|
import {setRefetch, uploadCsv} from '../../stores/contacts/contactsSlice';
|
||||||
|
|
||||||
|
|
||||||
import {hasPermission} from "../../helpers/userPermissions";
|
import {hasPermission} from "../../helpers/userPermissions";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const ProgressTablesPage = () => {
|
const ContactsTablesPage = () => {
|
||||||
const [filterItems, setFilterItems] = useState([]);
|
const [filterItems, setFilterItems] = useState([]);
|
||||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||||
const [isModalActive, setIsModalActive] = useState(false);
|
const [isModalActive, setIsModalActive] = useState(false);
|
||||||
@ -34,24 +34,20 @@ const ProgressTablesPage = () => {
|
|||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
|
||||||
const [filters] = useState([{label: 'Note', title: 'note'},
|
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: 'Attempts', title: 'attempts', number: 'true'},
|
|
||||||
{label: 'Score', title: 'score', number: 'true'},
|
|
||||||
{label: 'CompletedAt', title: 'completed_at', date: 'true'},
|
|
||||||
|
|
||||||
|
|
||||||
{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 = () => {
|
const addFilter = () => {
|
||||||
@ -68,13 +64,13 @@ const ProgressTablesPage = () => {
|
|||||||
setFilterItems([...filterItems, newItem]);
|
setFilterItems([...filterItems, newItem]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getProgressCSV = async () => {
|
const getContactsCSV = async () => {
|
||||||
const response = await axios({url: '/progress?filetype=csv', method: 'GET',responseType: 'blob'});
|
const response = await axios({url: '/contacts?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||||
const type = response.headers['content-type']
|
const type = response.headers['content-type']
|
||||||
const blob = new Blob([response.data], { type: type })
|
const blob = new Blob([response.data], { type: type })
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a')
|
||||||
link.href = window.URL.createObjectURL(blob)
|
link.href = window.URL.createObjectURL(blob)
|
||||||
link.download = 'progressCSV.csv'
|
link.download = 'contactsCSV.csv'
|
||||||
link.click()
|
link.click()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -94,15 +90,15 @@ const ProgressTablesPage = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('Progress')}</title>
|
<title>{getPageTitle('Contacts')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Progress" main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Contacts" main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
<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
|
<BaseButton
|
||||||
className={'mr-3'}
|
className={'mr-3'}
|
||||||
@ -110,7 +106,7 @@ const ProgressTablesPage = () => {
|
|||||||
label='Filter'
|
label='Filter'
|
||||||
onClick={addFilter}
|
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 && (
|
{hasCreatePermission && (
|
||||||
<BaseButton
|
<BaseButton
|
||||||
@ -123,14 +119,14 @@ const ProgressTablesPage = () => {
|
|||||||
<div className='md:inline-flex items-center ms-auto'>
|
<div className='md:inline-flex items-center ms-auto'>
|
||||||
<div id='delete-rows-button'></div>
|
<div id='delete-rows-button'></div>
|
||||||
|
|
||||||
<Link href={'/progress/progress-list'}>
|
<Link href={'/contacts/contacts-list'}>
|
||||||
Back to <span className='capitalize'>list</span>
|
Back to <span className='capitalize'>list</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</CardBox>
|
</CardBox>
|
||||||
<CardBox className="mb-6" hasTable>
|
<CardBox className="mb-6" hasTable>
|
||||||
<TableProgress
|
<TableContacts
|
||||||
filterItems={filterItems}
|
filterItems={filterItems}
|
||||||
setFilterItems={setFilterItems}
|
setFilterItems={setFilterItems}
|
||||||
filters={filters}
|
filters={filters}
|
||||||
@ -157,11 +153,11 @@ const ProgressTablesPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressTablesPage.getLayout = function getLayout(page: ReactElement) {
|
ContactsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'READ_PROGRESS'}
|
permission={'READ_CONTACTS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 dayjs from "dayjs";
|
||||||
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
||||||
import {useRouter} from "next/router";
|
import {useRouter} from "next/router";
|
||||||
import { fetch } from '../../stores/enrollments/enrollmentsSlice'
|
import { fetch } from '../../stores/contacts/contactsSlice'
|
||||||
import {saveFile} from "../../helpers/fileSaver";
|
import {saveFile} from "../../helpers/fileSaver";
|
||||||
import dataFormatter from '../../helpers/dataFormatter';
|
import dataFormatter from '../../helpers/dataFormatter';
|
||||||
import ImageField from "../../components/ImageField";
|
import ImageField from "../../components/ImageField";
|
||||||
@ -21,10 +21,10 @@ import {SwitchField} from "../../components/SwitchField";
|
|||||||
import FormField from "../../components/FormField";
|
import FormField from "../../components/FormField";
|
||||||
|
|
||||||
|
|
||||||
const EnrollmentsView = () => {
|
const ContactsView = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
const { enrollments } = useAppSelector((state) => state.enrollments)
|
const { contacts } = useAppSelector((state) => state.contacts)
|
||||||
|
|
||||||
|
|
||||||
const { id } = router.query;
|
const { id } = router.query;
|
||||||
@ -42,14 +42,14 @@ const EnrollmentsView = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('View enrollments')}</title>
|
<title>{getPageTitle('View contacts')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View enrollments')} main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View contacts')} main>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
color='info'
|
color='info'
|
||||||
label='Edit'
|
label='Edit'
|
||||||
href={`/enrollments/enrollments-edit/?id=${id}`}
|
href={`/contacts/contacts-edit/?id=${id}`}
|
||||||
/>
|
/>
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox>
|
<CardBox>
|
||||||
@ -57,8 +57,136 @@ const EnrollmentsView = () => {
|
|||||||
|
|
||||||
|
|
||||||
<div className={'mb-4'}>
|
<div className={'mb-4'}>
|
||||||
<p className={'block font-bold mb-2'}>EnrollmentLabel</p>
|
<p className={'block font-bold mb-2'}>Name</p>
|
||||||
<p>{enrollments?.enrollment_label}</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>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -108,10 +236,12 @@ const EnrollmentsView = () => {
|
|||||||
|
|
||||||
|
|
||||||
<div className={'mb-4'}>
|
<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 = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField label='Multi Text' hasTextareaHeight>
|
||||||
|
<textarea className={'w-full'} disabled value={contacts?.notes} />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<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>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -230,94 +293,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
|
<CardBox
|
||||||
className='mb-6 border border-gray-300 rounded overflow-hidden'
|
className='mb-6 border border-gray-300 rounded overflow-hidden'
|
||||||
hasTable
|
hasTable
|
||||||
@ -342,7 +317,29 @@ const EnrollmentsView = () => {
|
|||||||
<tr>
|
<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>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{enrollments.progress_enrollment && Array.isArray(enrollments.progress_enrollment) &&
|
{contacts.deals_primary_contact && Array.isArray(contacts.deals_primary_contact) &&
|
||||||
enrollments.progress_enrollment.map((item: any) => (
|
contacts.deals_primary_contact.map((item: any) => (
|
||||||
<tr key={item.id} onClick={() => router.push(`/progress/progress-view/?id=${item.id}`)}>
|
<tr key={item.id} onClick={() => router.push(`/deals/deals-view/?id=${item.id}`)}>
|
||||||
|
|
||||||
|
|
||||||
<td data-label="note">
|
<td data-label="title">
|
||||||
{ item.note }
|
{ 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>
|
</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>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</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>
|
</CardBox>
|
||||||
</>
|
</>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
|
|
||||||
<BaseButton
|
<BaseButton
|
||||||
color='info'
|
color='info'
|
||||||
label='Back'
|
label='Back'
|
||||||
onClick={() => router.push('/enrollments/enrollments-list')}
|
onClick={() => router.push('/contacts/contacts-list')}
|
||||||
/>
|
/>
|
||||||
</CardBox>
|
</CardBox>
|
||||||
</SectionMain>
|
</SectionMain>
|
||||||
@ -430,11 +424,11 @@ const EnrollmentsView = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
EnrollmentsView.getLayout = function getLayout(page: ReactElement) {
|
ContactsView.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'READ_ENROLLMENTS'}
|
permission={'READ_CONTACTS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 BaseIcon from "../components/BaseIcon";
|
||||||
import { getPageTitle } from '../config'
|
import { getPageTitle } from '../config'
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import CardBox from '../components/CardBox';
|
||||||
|
|
||||||
import { hasPermission } from "../helpers/userPermissions";
|
import { hasPermission } from "../helpers/userPermissions";
|
||||||
import { fetchWidgets } from '../stores/roles/rolesSlice';
|
import { fetchWidgets } from '../stores/roles/rolesSlice';
|
||||||
@ -16,62 +17,55 @@ import { WidgetCreator } from '../components/WidgetCreator/WidgetCreator';
|
|||||||
import { SmartWidget } from '../components/SmartWidget/SmartWidget';
|
import { SmartWidget } from '../components/SmartWidget/SmartWidget';
|
||||||
|
|
||||||
import { useAppDispatch, useAppSelector } from '../stores/hooks';
|
import { useAppDispatch, useAppSelector } from '../stores/hooks';
|
||||||
|
|
||||||
const Dashboard = () => {
|
const Dashboard = () => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const iconsColor = useAppSelector((state) => state.style.iconsColor);
|
const iconsColor = useAppSelector((state) => state.style.iconsColor);
|
||||||
const corners = useAppSelector((state) => state.style.corners);
|
const corners = useAppSelector((state) => state.style.corners);
|
||||||
const cardsStyle = useAppSelector((state) => state.style.cardsStyle);
|
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 [recentDeals, setRecentDeals] = React.useState([]);
|
||||||
const [roles, setRoles] = React.useState(loadingMessage);
|
const [upcomingActivities, setUpcomingActivities] = React.useState([]);
|
||||||
const [permissions, setPermissions] = React.useState(loadingMessage);
|
const [pipelineStages, setPipelineStages] = React.useState([]);
|
||||||
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 [widgetsRole, setWidgetsRole] = React.useState({
|
const [widgetsRole, setWidgetsRole] = React.useState({
|
||||||
role: { value: '', label: '' },
|
role: { value: '', label: '' },
|
||||||
});
|
});
|
||||||
const { currentUser } = useAppSelector((state) => state.auth);
|
const { currentUser } = useAppSelector((state) => state.auth);
|
||||||
const { isFetchingQuery } = useAppSelector((state) => state.openAi);
|
const { isFetchingQuery } = useAppSelector((state) => state.openAi);
|
||||||
|
|
||||||
const { rolesWidgets, loading } = useAppSelector((state) => state.roles);
|
const { rolesWidgets, loading } = useAppSelector((state) => state.roles);
|
||||||
|
|
||||||
|
|
||||||
async function loadData() {
|
async function loadData() {
|
||||||
const entities = ['users','roles','permissions','courses','lessons','enrollments','progress',];
|
if (hasPermission(currentUser, 'READ_LEADS')) {
|
||||||
const fns = [setUsers,setRoles,setPermissions,setCourses,setLessons,setEnrollments,setProgress,];
|
axios.get('/leads/count').then(res => setLeads(res.data.count));
|
||||||
|
}
|
||||||
const requests = entities.map((entity, index) => {
|
if (hasPermission(currentUser, 'READ_DEALS')) {
|
||||||
|
axios.get('/deals/stats').then(res => {
|
||||||
if(hasPermission(currentUser, `READ_${entity.toUpperCase()}`)) {
|
setDealsCount(res.data.count);
|
||||||
return axios.get(`/${entity.toLowerCase()}/count`);
|
setTotalValue(res.data.totalValue || 0);
|
||||||
} 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);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
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) {
|
async function getWidgets(roleId) {
|
||||||
await dispatch(fetchWidgets(roleId));
|
await dispatch(fetchWidgets(roleId));
|
||||||
}
|
}
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!currentUser) return;
|
if (!currentUser) return;
|
||||||
loadData().then();
|
loadData().then();
|
||||||
@ -83,17 +77,23 @@ const Dashboard = () => {
|
|||||||
getWidgets(widgetsRole?.role?.value || '').then();
|
getWidgets(widgetsRole?.role?.value || '').then();
|
||||||
}, [widgetsRole?.role?.value]);
|
}, [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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>
|
<title>{getPageTitle('Overview')}</title>
|
||||||
{getPageTitle('Overview')}
|
|
||||||
</title>
|
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton
|
<SectionTitleLineWithButton
|
||||||
icon={icon.mdiChartTimelineVariant}
|
icon={icon.mdiChartTimelineVariant}
|
||||||
title='Overview'
|
title='Sales Overview'
|
||||||
main>
|
main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
@ -104,16 +104,172 @@ const Dashboard = () => {
|
|||||||
setWidgetsRole={setWidgetsRole}
|
setWidgetsRole={setWidgetsRole}
|
||||||
widgetsRole={widgetsRole}
|
widgetsRole={widgetsRole}
|
||||||
/>}
|
/>}
|
||||||
{!!rolesWidgets.length &&
|
|
||||||
hasPermission(currentUser, 'CREATE_ROLES') && (
|
<div className='grid grid-cols-1 gap-6 lg:grid-cols-4 mb-6'>
|
||||||
<p className=' text-gray-500 dark:text-gray-400 mb-4'>
|
<CardBox className={`${cardsStyle} border-l-4 border-indigo-500 shadow-md`}>
|
||||||
{`${widgetsRole?.role?.label || 'Users'}'s widgets`}
|
<div className="flex justify-between items-center">
|
||||||
</p>
|
<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'>
|
<div className='grid grid-cols-1 gap-6 lg:grid-cols-4 mb-6 grid-flow-dense'>
|
||||||
{(isFetchingQuery || loading) && (
|
{(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
|
<BaseIcon
|
||||||
className={`${iconsColor} animate-spin mr-5`}
|
className={`${iconsColor} animate-spin mr-5`}
|
||||||
w='w-16'
|
w='w-16'
|
||||||
@ -121,7 +277,7 @@ const Dashboard = () => {
|
|||||||
size={48}
|
size={48}
|
||||||
path={icon.mdiLoading}
|
path={icon.mdiLoading}
|
||||||
/>{' '}
|
/>{' '}
|
||||||
Loading widgets...
|
Loading insights...
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@ -137,209 +293,6 @@ const Dashboard = () => {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</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>
|
</SectionMain>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import { SelectFieldMany } from "../../components/SelectFieldMany";
|
|||||||
import { SwitchField } from '../../components/SwitchField'
|
import { SwitchField } from '../../components/SwitchField'
|
||||||
import {RichTextField} from "../../components/RichTextField";
|
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 { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import {saveFile} from "../../helpers/fileSaver";
|
import {saveFile} from "../../helpers/fileSaver";
|
||||||
@ -34,7 +34,7 @@ import ImageField from "../../components/ImageField";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const EditLessons = () => {
|
const EditDeals = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
const initVals = {
|
const initVals = {
|
||||||
@ -68,11 +68,11 @@ const EditLessons = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'deal_number': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
content: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -96,6 +96,7 @@ const EditLessons = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'value': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -118,19 +119,18 @@ const EditLessons = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
course: null,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'currency': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
order: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -158,7 +158,6 @@ const EditLessons = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
duration_minutes: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -175,90 +174,7 @@ const EditLessons = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
stage: null,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
video_files: [],
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resources: [],
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
release_date: new Date(),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -289,50 +205,162 @@ const EditLessons = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
close_date: new Date(),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
owner: null,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
primary_contact: null,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
description: '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
const [initialValues, setInitialValues] = useState(initVals)
|
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(() => {
|
useEffect(() => {
|
||||||
dispatch(fetch({ id: lessonsId }))
|
dispatch(fetch({ id: dealsId }))
|
||||||
}, [lessonsId])
|
}, [dealsId])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof lessons === 'object') {
|
if (typeof deals === 'object') {
|
||||||
setInitialValues(lessons)
|
setInitialValues(deals)
|
||||||
}
|
}
|
||||||
}, [lessons])
|
}, [deals])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof lessons === 'object') {
|
if (typeof deals === 'object') {
|
||||||
|
|
||||||
const newInitialVal = {...initVals};
|
const newInitialVal = {...initVals};
|
||||||
|
|
||||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (lessons)[el])
|
Object.keys(initVals).forEach(el => newInitialVal[el] = (deals)[el])
|
||||||
|
|
||||||
setInitialValues(newInitialVal);
|
setInitialValues(newInitialVal);
|
||||||
}
|
}
|
||||||
}, [lessons])
|
}, [deals])
|
||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
await dispatch(update({ id: lessonsId, data }))
|
await dispatch(update({ id: dealsId, data }))
|
||||||
await router.push('/lessons/lessons-list')
|
await router.push('/deals/deals-list')
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('Edit lessons')}</title>
|
<title>{getPageTitle('Edit deals')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit lessons'} main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit deals'} main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox>
|
<CardBox>
|
||||||
@ -382,16 +410,88 @@ const EditLessons = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
label="DealNumber"
|
||||||
|
>
|
||||||
|
|
||||||
<FormField label='Content' hasTextareaHeight>
|
|
||||||
<Field
|
<Field
|
||||||
name='content'
|
name="deal_number"
|
||||||
id='content'
|
placeholder="DealNumber"
|
||||||
component={RichTextField}
|
/>
|
||||||
></Field>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
label="Value"
|
||||||
|
>
|
||||||
|
<Field
|
||||||
|
type="number"
|
||||||
|
name="value"
|
||||||
|
placeholder="Value"
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
label="Currency"
|
||||||
|
>
|
||||||
|
<Field
|
||||||
|
name="currency"
|
||||||
|
placeholder="Currency"
|
||||||
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -437,13 +537,17 @@ const EditLessons = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FormField label='Course' labelFor='course'>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField label='Stage' labelFor='stage'>
|
||||||
<Field
|
<Field
|
||||||
name='course'
|
name='stage'
|
||||||
id='course'
|
id='stage'
|
||||||
component={SelectField}
|
component={SelectField}
|
||||||
options={initialValues.course}
|
options={initialValues.stage}
|
||||||
itemRef={'courses'}
|
itemRef={'pipeline_stages'}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -461,6 +565,8 @@ const EditLessons = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</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>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -511,157 +627,23 @@ 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>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
label="ReleaseDate"
|
label="CloseDate"
|
||||||
>
|
>
|
||||||
<DatePicker
|
<DatePicker
|
||||||
dateFormat="yyyy-MM-dd hh:mm"
|
dateFormat="yyyy-MM-dd hh:mm"
|
||||||
showTimeSelect
|
showTimeSelect
|
||||||
selected={initialValues.release_date ?
|
selected={initialValues.close_date ?
|
||||||
new Date(
|
new Date(
|
||||||
dayjs(initialValues.release_date).format('YYYY-MM-DD hh:mm'),
|
dayjs(initialValues.close_date).format('YYYY-MM-DD hh:mm'),
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
onChange={(date) => setInitialValues({...initialValues, 'release_date': date})}
|
onChange={(date) => setInitialValues({...initialValues, 'close_date': date})}
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@ -697,16 +679,38 @@ 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>
|
||||||
|
|
||||||
|
|
||||||
@ -719,6 +723,100 @@ const EditLessons = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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>
|
<BaseButtons>
|
||||||
<BaseButton type="submit" color="info" label="Submit" />
|
<BaseButton type="submit" color="info" label="Submit" />
|
||||||
<BaseButton type="reset" color="info" outline label="Reset" />
|
<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>
|
</BaseButtons>
|
||||||
</Form>
|
</Form>
|
||||||
</Formik>
|
</Formik>
|
||||||
@ -737,11 +835,11 @@ const EditLessons = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
EditLessons.getLayout = function getLayout(page: ReactElement) {
|
EditDeals.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'UPDATE_LESSONS'}
|
permission={'UPDATE_DEALS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 { SwitchField } from '../../components/SwitchField'
|
||||||
import {RichTextField} from "../../components/RichTextField";
|
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 { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import {saveFile} from "../../helpers/fileSaver";
|
import {saveFile} from "../../helpers/fileSaver";
|
||||||
@ -34,7 +34,7 @@ import ImageField from "../../components/ImageField";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const EditLessonsPage = () => {
|
const EditDealsPage = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
const initVals = {
|
const initVals = {
|
||||||
@ -68,11 +68,11 @@ const EditLessonsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'deal_number': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
content: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -96,6 +96,7 @@ const EditLessonsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'value': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -118,19 +119,18 @@ const EditLessonsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
course: null,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'currency': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
order: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -158,7 +158,6 @@ const EditLessonsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
duration_minutes: '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -175,90 +174,7 @@ const EditLessonsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
stage: null,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
video_files: [],
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resources: [],
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
release_date: new Date(),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -289,13 +205,125 @@ const EditLessonsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
close_date: new Date(),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
owner: null,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
primary_contact: null,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
description: '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
const [initialValues, setInitialValues] = useState(initVals)
|
const [initialValues, setInitialValues] = useState(initVals)
|
||||||
|
|
||||||
const { lessons } = useAppSelector((state) => state.lessons)
|
const { deals } = useAppSelector((state) => state.deals)
|
||||||
|
|
||||||
|
|
||||||
const { id } = router.query
|
const { id } = router.query
|
||||||
@ -305,31 +333,31 @@ const EditLessonsPage = () => {
|
|||||||
}, [id])
|
}, [id])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof lessons === 'object') {
|
if (typeof deals === 'object') {
|
||||||
setInitialValues(lessons)
|
setInitialValues(deals)
|
||||||
}
|
}
|
||||||
}, [lessons])
|
}, [deals])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof lessons === 'object') {
|
if (typeof deals === 'object') {
|
||||||
const newInitialVal = {...initVals};
|
const newInitialVal = {...initVals};
|
||||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (lessons)[el])
|
Object.keys(initVals).forEach(el => newInitialVal[el] = (deals)[el])
|
||||||
setInitialValues(newInitialVal);
|
setInitialValues(newInitialVal);
|
||||||
}
|
}
|
||||||
}, [lessons])
|
}, [deals])
|
||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
await dispatch(update({ id: id, data }))
|
await dispatch(update({ id: id, data }))
|
||||||
await router.push('/lessons/lessons-list')
|
await router.push('/deals/deals-list')
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('Edit lessons')}</title>
|
<title>{getPageTitle('Edit deals')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit lessons'} main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit deals'} main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox>
|
<CardBox>
|
||||||
@ -379,16 +407,88 @@ const EditLessonsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
label="DealNumber"
|
||||||
|
>
|
||||||
|
|
||||||
<FormField label='Content' hasTextareaHeight>
|
|
||||||
<Field
|
<Field
|
||||||
name='content'
|
name="deal_number"
|
||||||
id='content'
|
placeholder="DealNumber"
|
||||||
component={RichTextField}
|
/>
|
||||||
></Field>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
label="Value"
|
||||||
|
>
|
||||||
|
<Field
|
||||||
|
type="number"
|
||||||
|
name="value"
|
||||||
|
placeholder="Value"
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
label="Currency"
|
||||||
|
>
|
||||||
|
<Field
|
||||||
|
name="currency"
|
||||||
|
placeholder="Currency"
|
||||||
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -434,13 +534,17 @@ const EditLessonsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FormField label='Course' labelFor='course'>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField label='Stage' labelFor='stage'>
|
||||||
<Field
|
<Field
|
||||||
name='course'
|
name='stage'
|
||||||
id='course'
|
id='stage'
|
||||||
component={SelectField}
|
component={SelectField}
|
||||||
options={initialValues.course}
|
options={initialValues.stage}
|
||||||
itemRef={'courses'}
|
itemRef={'pipeline_stages'}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -458,6 +562,8 @@ const EditLessonsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</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>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -508,157 +624,23 @@ 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>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
label="ReleaseDate"
|
label="CloseDate"
|
||||||
>
|
>
|
||||||
<DatePicker
|
<DatePicker
|
||||||
dateFormat="yyyy-MM-dd hh:mm"
|
dateFormat="yyyy-MM-dd hh:mm"
|
||||||
showTimeSelect
|
showTimeSelect
|
||||||
selected={initialValues.release_date ?
|
selected={initialValues.close_date ?
|
||||||
new Date(
|
new Date(
|
||||||
dayjs(initialValues.release_date).format('YYYY-MM-DD hh:mm'),
|
dayjs(initialValues.close_date).format('YYYY-MM-DD hh:mm'),
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
onChange={(date) => setInitialValues({...initialValues, 'release_date': date})}
|
onChange={(date) => setInitialValues({...initialValues, 'close_date': date})}
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@ -694,16 +676,38 @@ 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>
|
||||||
|
|
||||||
|
|
||||||
@ -716,6 +720,100 @@ const EditLessonsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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>
|
<BaseButtons>
|
||||||
<BaseButton type="submit" color="info" label="Submit" />
|
<BaseButton type="submit" color="info" label="Submit" />
|
||||||
<BaseButton type="reset" color="info" outline label="Reset" />
|
<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>
|
</BaseButtons>
|
||||||
</Form>
|
</Form>
|
||||||
</Formik>
|
</Formik>
|
||||||
@ -734,11 +832,11 @@ const EditLessonsPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
EditLessonsPage.getLayout = function getLayout(page: ReactElement) {
|
EditDealsPage.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'UPDATE_LESSONS'}
|
permission={'UPDATE_DEALS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||||
import {RichTextField} from "../../components/RichTextField";
|
import {RichTextField} from "../../components/RichTextField";
|
||||||
|
|
||||||
import { create } from '../../stores/lessons/lessonsSlice'
|
import { create } from '../../stores/deals/dealsSlice'
|
||||||
import { useAppDispatch } from '../../stores/hooks'
|
import { useAppDispatch } from '../../stores/hooks'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import moment from 'moment';
|
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 router = useRouter()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
|
|
||||||
@ -186,7 +202,7 @@ const LessonsNew = () => {
|
|||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
await dispatch(create(data))
|
await dispatch(create(data))
|
||||||
await router.push('/lessons/lessons-list')
|
await router.push('/deals/deals-list')
|
||||||
}
|
}
|
||||||
return (
|
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
|
<FormField
|
||||||
label="ReleaseDate"
|
label="DealNumber"
|
||||||
>
|
>
|
||||||
<Field
|
<Field
|
||||||
type="datetime-local"
|
name="deal_number"
|
||||||
name="release_date"
|
placeholder="DealNumber"
|
||||||
placeholder="ReleaseDate"
|
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</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">
|
<FormField label="Status" labelFor="status">
|
||||||
<Field name="status" id="status" component="select">
|
<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>
|
</Field>
|
||||||
</FormField>
|
</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 />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type="submit" color="info" label="Submit" />
|
<BaseButton type="submit" color="info" label="Submit" />
|
||||||
<BaseButton type="reset" color="info" outline label="Reset" />
|
<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>
|
</BaseButtons>
|
||||||
</Form>
|
</Form>
|
||||||
</Formik>
|
</Formik>
|
||||||
@ -551,11 +577,11 @@ const LessonsNew = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
LessonsNew.getLayout = function getLayout(page: ReactElement) {
|
DealsNew.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'CREATE_LESSONS'}
|
permission={'CREATE_DEALS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 SectionMain from '../../components/SectionMain'
|
||||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||||
import { getPageTitle } from '../../config'
|
import { getPageTitle } from '../../config'
|
||||||
import TableLessons from '../../components/Lessons/TableLessons'
|
import TableDeals from '../../components/Deals/TableDeals'
|
||||||
import BaseButton from '../../components/BaseButton'
|
import BaseButton from '../../components/BaseButton'
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
||||||
import CardBoxModal from "../../components/CardBoxModal";
|
import CardBoxModal from "../../components/CardBoxModal";
|
||||||
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
||||||
import {setRefetch, uploadCsv} from '../../stores/lessons/lessonsSlice';
|
import {setRefetch, uploadCsv} from '../../stores/deals/dealsSlice';
|
||||||
|
|
||||||
|
|
||||||
import {hasPermission} from "../../helpers/userPermissions";
|
import {hasPermission} from "../../helpers/userPermissions";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const LessonsTablesPage = () => {
|
const DealsTablesPage = () => {
|
||||||
const [filterItems, setFilterItems] = useState([]);
|
const [filterItems, setFilterItems] = useState([]);
|
||||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||||
const [isModalActive, setIsModalActive] = useState(false);
|
const [isModalActive, setIsModalActive] = useState(false);
|
||||||
@ -34,20 +34,28 @@ const LessonsTablesPage = () => {
|
|||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
|
||||||
const [filters] = useState([{label: 'Title', title: 'title'},{label: 'Content', title: 'content'},
|
const [filters] = useState([{label: 'Title', title: 'title'},{label: 'DealNumber', title: 'deal_number'},{label: 'Currency', title: 'currency'},{label: 'Description', title: 'description'},
|
||||||
{label: 'Order', title: 'order', number: 'true'},{label: 'Duration(minutes)', title: 'duration_minutes', number: 'true'},
|
|
||||||
|
|
||||||
{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: 'Status', title: 'status', type: 'enum', options: ['draft','published','archived']},
|
{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_LESSONS');
|
const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_DEALS');
|
||||||
|
|
||||||
|
|
||||||
const addFilter = () => {
|
const addFilter = () => {
|
||||||
@ -64,13 +72,13 @@ const LessonsTablesPage = () => {
|
|||||||
setFilterItems([...filterItems, newItem]);
|
setFilterItems([...filterItems, newItem]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getLessonsCSV = async () => {
|
const getDealsCSV = async () => {
|
||||||
const response = await axios({url: '/lessons?filetype=csv', method: 'GET',responseType: 'blob'});
|
const response = await axios({url: '/deals?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||||
const type = response.headers['content-type']
|
const type = response.headers['content-type']
|
||||||
const blob = new Blob([response.data], { type: type })
|
const blob = new Blob([response.data], { type: type })
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a')
|
||||||
link.href = window.URL.createObjectURL(blob)
|
link.href = window.URL.createObjectURL(blob)
|
||||||
link.download = 'lessonsCSV.csv'
|
link.download = 'dealsCSV.csv'
|
||||||
link.click()
|
link.click()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -90,15 +98,15 @@ const LessonsTablesPage = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('Lessons')}</title>
|
<title>{getPageTitle('Deals')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Lessons" main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Deals" main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
<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
|
<BaseButton
|
||||||
className={'mr-3'}
|
className={'mr-3'}
|
||||||
@ -106,7 +114,7 @@ const LessonsTablesPage = () => {
|
|||||||
label='Filter'
|
label='Filter'
|
||||||
onClick={addFilter}
|
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 && (
|
{hasCreatePermission && (
|
||||||
<BaseButton
|
<BaseButton
|
||||||
@ -119,14 +127,14 @@ const LessonsTablesPage = () => {
|
|||||||
<div className='md:inline-flex items-center ms-auto'>
|
<div className='md:inline-flex items-center ms-auto'>
|
||||||
<div id='delete-rows-button'></div>
|
<div id='delete-rows-button'></div>
|
||||||
|
|
||||||
<Link href={'/lessons/lessons-list'}>
|
<Link href={'/deals/deals-list'}>
|
||||||
Back to <span className='capitalize'>kanban</span>
|
Back to <span className='capitalize'>kanban</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</CardBox>
|
</CardBox>
|
||||||
<CardBox className="mb-6" hasTable>
|
<CardBox className="mb-6" hasTable>
|
||||||
<TableLessons
|
<TableDeals
|
||||||
filterItems={filterItems}
|
filterItems={filterItems}
|
||||||
setFilterItems={setFilterItems}
|
setFilterItems={setFilterItems}
|
||||||
filters={filters}
|
filters={filters}
|
||||||
@ -153,11 +161,11 @@ const LessonsTablesPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
LessonsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
DealsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'READ_LESSONS'}
|
permission={'READ_DEALS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 dayjs from "dayjs";
|
||||||
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
||||||
import {useRouter} from "next/router";
|
import {useRouter} from "next/router";
|
||||||
import { fetch } from '../../stores/courses/coursesSlice'
|
import { fetch } from '../../stores/deals/dealsSlice'
|
||||||
import {saveFile} from "../../helpers/fileSaver";
|
import {saveFile} from "../../helpers/fileSaver";
|
||||||
import dataFormatter from '../../helpers/dataFormatter';
|
import dataFormatter from '../../helpers/dataFormatter';
|
||||||
import ImageField from "../../components/ImageField";
|
import ImageField from "../../components/ImageField";
|
||||||
@ -21,10 +21,10 @@ import {SwitchField} from "../../components/SwitchField";
|
|||||||
import FormField from "../../components/FormField";
|
import FormField from "../../components/FormField";
|
||||||
|
|
||||||
|
|
||||||
const CoursesView = () => {
|
const DealsView = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
const { courses } = useAppSelector((state) => state.courses)
|
const { deals } = useAppSelector((state) => state.deals)
|
||||||
|
|
||||||
|
|
||||||
const { id } = router.query;
|
const { id } = router.query;
|
||||||
@ -42,14 +42,14 @@ const CoursesView = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('View courses')}</title>
|
<title>{getPageTitle('View deals')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View courses')} main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View deals')} main>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
color='info'
|
color='info'
|
||||||
label='Edit'
|
label='Edit'
|
||||||
href={`/courses/courses-edit/?id=${id}`}
|
href={`/deals/deals-edit/?id=${id}`}
|
||||||
/>
|
/>
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox>
|
<CardBox>
|
||||||
@ -58,7 +58,39 @@ const CoursesView = () => {
|
|||||||
|
|
||||||
<div className={'mb-4'}>
|
<div className={'mb-4'}>
|
||||||
<p className={'block font-bold mb-2'}>Title</p>
|
<p className={'block font-bold mb-2'}>Title</p>
|
||||||
<p>{courses?.title}</p>
|
<p>{deals?.title}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>DealNumber</p>
|
||||||
|
<p>{deals?.deal_number}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -80,6 +112,298 @@ const CoursesView = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Value</p>
|
||||||
|
<p>{deals?.value || 'No data'}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Currency</p>
|
||||||
|
<p>{deals?.currency}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>PrimaryContact</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p>{deals?.primary_contact?.name ?? 'No data'}</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -94,8 +418,8 @@ const CoursesView = () => {
|
|||||||
|
|
||||||
<div className={'mb-4'}>
|
<div className={'mb-4'}>
|
||||||
<p className={'block font-bold mb-2'}>Description</p>
|
<p className={'block font-bold mb-2'}>Description</p>
|
||||||
{courses.description
|
{deals.description
|
||||||
? <p dangerouslySetInnerHTML={{__html: courses.description}}/>
|
? <p dangerouslySetInnerHTML={{__html: deals.description}}/>
|
||||||
: <p>No data</p>
|
: <p>No data</p>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@ -119,336 +443,6 @@ const CoursesView = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'mb-4'}>
|
|
||||||
<p className={'block font-bold mb-2'}>Instructor</p>
|
|
||||||
|
|
||||||
|
|
||||||
<p>{courses?.instructor?.firstName ?? 'No data'}</p>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'mb-4'}>
|
|
||||||
<p className={'block font-bold mb-2'}>Category</p>
|
|
||||||
<p>{courses?.category ?? 'No data'}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<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>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -461,7 +455,7 @@ const CoursesView = () => {
|
|||||||
|
|
||||||
|
|
||||||
<>
|
<>
|
||||||
<p className={'block font-bold mb-2'}>Lessons Course</p>
|
<p className={'block font-bold mb-2'}>Activities RelatedDeal</p>
|
||||||
<CardBox
|
<CardBox
|
||||||
className='mb-6 border border-gray-300 rounded overflow-hidden'
|
className='mb-6 border border-gray-300 rounded overflow-hidden'
|
||||||
hasTable
|
hasTable
|
||||||
@ -472,7 +466,23 @@ const CoursesView = () => {
|
|||||||
<tr>
|
<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>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{courses.lessons_course && Array.isArray(courses.lessons_course) &&
|
{deals.activities_related_deal && Array.isArray(deals.activities_related_deal) &&
|
||||||
courses.lessons_course.map((item: any) => (
|
deals.activities_related_deal.map((item: any) => (
|
||||||
<tr key={item.id} onClick={() => router.push(`/lessons/lessons-view/?id=${item.id}`)}>
|
<tr key={item.id} onClick={() => router.push(`/activities/activities-view/?id=${item.id}`)}>
|
||||||
|
|
||||||
|
|
||||||
<td data-label="title">
|
<td data-label="subject">
|
||||||
{ item.title }
|
{ 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>
|
</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>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</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>
|
</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 />
|
<BaseDivider />
|
||||||
|
|
||||||
<BaseButton
|
<BaseButton
|
||||||
color='info'
|
color='info'
|
||||||
label='Back'
|
label='Back'
|
||||||
onClick={() => router.push('/courses/courses-list')}
|
onClick={() => router.push('/deals/deals-list')}
|
||||||
/>
|
/>
|
||||||
</CardBox>
|
</CardBox>
|
||||||
</SectionMain>
|
</SectionMain>
|
||||||
@ -655,11 +562,11 @@ const CoursesView = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
CoursesView.getLayout = function getLayout(page: ReactElement) {
|
DealsView.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'READ_COURSES'}
|
permission={'READ_DEALS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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,
|
photographer_url: undefined,
|
||||||
})
|
})
|
||||||
const [illustrationVideo, setIllustrationVideo] = useState({video_files: []})
|
const [illustrationVideo, setIllustrationVideo] = useState({video_files: []})
|
||||||
const [contentType, setContentType] = useState('image');
|
const [contentType, setContentType] = useState('video');
|
||||||
const [contentPosition, setContentPosition] = useState('left');
|
const [contentPosition, setContentPosition] = useState('left');
|
||||||
const textColor = useAppSelector((state) => state.style.linkColor);
|
const textColor = useAppSelector((state) => state.style.linkColor);
|
||||||
|
|
||||||
const title = 'Instructor-Student LMS'
|
const title = 'Sales Pipeline CRM'
|
||||||
|
|
||||||
// Fetch Pexels image/video
|
// Fetch Pexels image/video
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -128,7 +128,7 @@ export default function Starter() {
|
|||||||
: null}
|
: null}
|
||||||
<div className='flex items-center justify-center flex-col space-y-4 w-full lg:w-full'>
|
<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'>
|
<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">
|
<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>
|
<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 { SwitchField } from '../../components/SwitchField'
|
||||||
import {RichTextField} from "../../components/RichTextField";
|
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 { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import {saveFile} from "../../helpers/fileSaver";
|
import {saveFile} from "../../helpers/fileSaver";
|
||||||
@ -34,13 +34,13 @@ import ImageField from "../../components/ImageField";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const EditEnrollments = () => {
|
const EditLeads = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
const initVals = {
|
const initVals = {
|
||||||
|
|
||||||
|
|
||||||
'enrollment_label': '',
|
'name': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -68,6 +68,7 @@ const EditEnrollments = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'company': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -90,12 +91,12 @@ const EditEnrollments = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
student: null,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'email': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -118,12 +119,12 @@ const EditEnrollments = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
course: null,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'phone': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -134,7 +135,6 @@ const EditEnrollments = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
enrolled_at: new Date(),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -147,6 +147,34 @@ const EditEnrollments = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
source: '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -180,7 +208,35 @@ const EditEnrollments = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
'progress_percent': '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
owner: null,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'estimated_value': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -208,11 +264,11 @@ const EditEnrollments = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
'price_paid': '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
notes: '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -239,44 +295,44 @@ const EditEnrollments = () => {
|
|||||||
}
|
}
|
||||||
const [initialValues, setInitialValues] = useState(initVals)
|
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(() => {
|
useEffect(() => {
|
||||||
dispatch(fetch({ id: enrollmentsId }))
|
dispatch(fetch({ id: leadsId }))
|
||||||
}, [enrollmentsId])
|
}, [leadsId])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof enrollments === 'object') {
|
if (typeof leads === 'object') {
|
||||||
setInitialValues(enrollments)
|
setInitialValues(leads)
|
||||||
}
|
}
|
||||||
}, [enrollments])
|
}, [leads])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof enrollments === 'object') {
|
if (typeof leads === 'object') {
|
||||||
|
|
||||||
const newInitialVal = {...initVals};
|
const newInitialVal = {...initVals};
|
||||||
|
|
||||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (enrollments)[el])
|
Object.keys(initVals).forEach(el => newInitialVal[el] = (leads)[el])
|
||||||
|
|
||||||
setInitialValues(newInitialVal);
|
setInitialValues(newInitialVal);
|
||||||
}
|
}
|
||||||
}, [enrollments])
|
}, [leads])
|
||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
await dispatch(update({ id: enrollmentsId, data }))
|
await dispatch(update({ id: leadsId, data }))
|
||||||
await router.push('/enrollments/enrollments-list')
|
await router.push('/leads/leads-list')
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('Edit enrollments')}</title>
|
<title>{getPageTitle('Edit leads')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit enrollments'} main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit leads'} main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox>
|
<CardBox>
|
||||||
@ -290,11 +346,122 @@ const EditEnrollments = () => {
|
|||||||
|
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
label="EnrollmentLabel"
|
label="Name"
|
||||||
>
|
>
|
||||||
<Field
|
<Field
|
||||||
name="enrollment_label"
|
name="name"
|
||||||
placeholder="EnrollmentLabel"
|
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>
|
</FormField>
|
||||||
|
|
||||||
@ -340,36 +507,20 @@ const EditEnrollments = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
<FormField label='Student' labelFor='student'>
|
<option value="SocialMedia">SocialMedia</option>
|
||||||
<Field
|
|
||||||
name='student'
|
|
||||||
id='student'
|
|
||||||
component={SelectField}
|
|
||||||
options={initialValues.student}
|
|
||||||
itemRef={'users'}
|
|
||||||
|
|
||||||
|
</Field>
|
||||||
showField={'firstName'}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
></Field>
|
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -387,105 +538,6 @@ const EditEnrollments = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<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">
|
<FormField label="Status" labelFor="status">
|
||||||
<Field name="status" id="status" component="select">
|
<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>
|
</Field>
|
||||||
</FormField>
|
</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
|
<FormField
|
||||||
label="ProgressPercent"
|
label="EstimatedValue"
|
||||||
>
|
>
|
||||||
<Field
|
<Field
|
||||||
type="number"
|
type="number"
|
||||||
name="progress_percent"
|
name="estimated_value"
|
||||||
placeholder="ProgressPercent"
|
placeholder="EstimatedValue"
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@ -567,16 +681,12 @@ const EditEnrollments = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField label='Notes' hasTextareaHeight>
|
||||||
|
|
||||||
<FormField
|
|
||||||
label="PricePaid"
|
|
||||||
>
|
|
||||||
<Field
|
<Field
|
||||||
type="number"
|
name='notes'
|
||||||
name="price_paid"
|
id='notes'
|
||||||
placeholder="PricePaid"
|
component={RichTextField}
|
||||||
/>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -598,6 +708,8 @@ const EditEnrollments = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -605,7 +717,7 @@ const EditEnrollments = () => {
|
|||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type="submit" color="info" label="Submit" />
|
<BaseButton type="submit" color="info" label="Submit" />
|
||||||
<BaseButton type="reset" color="info" outline label="Reset" />
|
<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>
|
</BaseButtons>
|
||||||
</Form>
|
</Form>
|
||||||
</Formik>
|
</Formik>
|
||||||
@ -615,11 +727,11 @@ const EditEnrollments = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
EditEnrollments.getLayout = function getLayout(page: ReactElement) {
|
EditLeads.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'UPDATE_ENROLLMENTS'}
|
permission={'UPDATE_LEADS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 { SwitchField } from '../../components/SwitchField'
|
||||||
import {RichTextField} from "../../components/RichTextField";
|
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 { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import {saveFile} from "../../helpers/fileSaver";
|
import {saveFile} from "../../helpers/fileSaver";
|
||||||
@ -34,13 +34,13 @@ import ImageField from "../../components/ImageField";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const EditEnrollmentsPage = () => {
|
const EditLeadsPage = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
const initVals = {
|
const initVals = {
|
||||||
|
|
||||||
|
|
||||||
'enrollment_label': '',
|
'name': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -68,6 +68,7 @@ const EditEnrollmentsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'company': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -90,12 +91,12 @@ const EditEnrollmentsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
student: null,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'email': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -118,12 +119,12 @@ const EditEnrollmentsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
course: null,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'phone': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -134,7 +135,6 @@ const EditEnrollmentsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
enrolled_at: new Date(),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -147,6 +147,34 @@ const EditEnrollmentsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
source: '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -180,7 +208,35 @@ const EditEnrollmentsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
'progress_percent': '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
owner: null,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'estimated_value': '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -208,11 +264,11 @@ const EditEnrollmentsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
'price_paid': '',
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
notes: '',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -239,7 +295,7 @@ const EditEnrollmentsPage = () => {
|
|||||||
}
|
}
|
||||||
const [initialValues, setInitialValues] = useState(initVals)
|
const [initialValues, setInitialValues] = useState(initVals)
|
||||||
|
|
||||||
const { enrollments } = useAppSelector((state) => state.enrollments)
|
const { leads } = useAppSelector((state) => state.leads)
|
||||||
|
|
||||||
|
|
||||||
const { id } = router.query
|
const { id } = router.query
|
||||||
@ -249,31 +305,31 @@ const EditEnrollmentsPage = () => {
|
|||||||
}, [id])
|
}, [id])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof enrollments === 'object') {
|
if (typeof leads === 'object') {
|
||||||
setInitialValues(enrollments)
|
setInitialValues(leads)
|
||||||
}
|
}
|
||||||
}, [enrollments])
|
}, [leads])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof enrollments === 'object') {
|
if (typeof leads === 'object') {
|
||||||
const newInitialVal = {...initVals};
|
const newInitialVal = {...initVals};
|
||||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (enrollments)[el])
|
Object.keys(initVals).forEach(el => newInitialVal[el] = (leads)[el])
|
||||||
setInitialValues(newInitialVal);
|
setInitialValues(newInitialVal);
|
||||||
}
|
}
|
||||||
}, [enrollments])
|
}, [leads])
|
||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
await dispatch(update({ id: id, data }))
|
await dispatch(update({ id: id, data }))
|
||||||
await router.push('/enrollments/enrollments-list')
|
await router.push('/leads/leads-list')
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('Edit enrollments')}</title>
|
<title>{getPageTitle('Edit leads')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit enrollments'} main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit leads'} main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox>
|
<CardBox>
|
||||||
@ -287,11 +343,122 @@ const EditEnrollmentsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
label="EnrollmentLabel"
|
label="Name"
|
||||||
>
|
>
|
||||||
<Field
|
<Field
|
||||||
name="enrollment_label"
|
name="name"
|
||||||
placeholder="EnrollmentLabel"
|
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>
|
</FormField>
|
||||||
|
|
||||||
@ -337,36 +504,20 @@ const EditEnrollmentsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
<FormField label='Student' labelFor='student'>
|
<option value="SocialMedia">SocialMedia</option>
|
||||||
<Field
|
|
||||||
name='student'
|
|
||||||
id='student'
|
|
||||||
component={SelectField}
|
|
||||||
options={initialValues.student}
|
|
||||||
itemRef={'users'}
|
|
||||||
|
|
||||||
|
</Field>
|
||||||
showField={'firstName'}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
></Field>
|
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -384,105 +535,6 @@ const EditEnrollmentsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<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">
|
<FormField label="Status" labelFor="status">
|
||||||
<Field name="status" id="status" component="select">
|
<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>
|
</Field>
|
||||||
</FormField>
|
</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
|
<FormField
|
||||||
label="ProgressPercent"
|
label="EstimatedValue"
|
||||||
>
|
>
|
||||||
<Field
|
<Field
|
||||||
type="number"
|
type="number"
|
||||||
name="progress_percent"
|
name="estimated_value"
|
||||||
placeholder="ProgressPercent"
|
placeholder="EstimatedValue"
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@ -564,16 +678,12 @@ const EditEnrollmentsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<FormField label='Notes' hasTextareaHeight>
|
||||||
|
|
||||||
<FormField
|
|
||||||
label="PricePaid"
|
|
||||||
>
|
|
||||||
<Field
|
<Field
|
||||||
type="number"
|
name='notes'
|
||||||
name="price_paid"
|
id='notes'
|
||||||
placeholder="PricePaid"
|
component={RichTextField}
|
||||||
/>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
|
||||||
@ -595,6 +705,8 @@ const EditEnrollmentsPage = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -602,7 +714,7 @@ const EditEnrollmentsPage = () => {
|
|||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type="submit" color="info" label="Submit" />
|
<BaseButton type="submit" color="info" label="Submit" />
|
||||||
<BaseButton type="reset" color="info" outline label="Reset" />
|
<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>
|
</BaseButtons>
|
||||||
</Form>
|
</Form>
|
||||||
</Formik>
|
</Formik>
|
||||||
@ -612,11 +724,11 @@ const EditEnrollmentsPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
EditEnrollmentsPage.getLayout = function getLayout(page: ReactElement) {
|
EditLeadsPage.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'UPDATE_ENROLLMENTS'}
|
permission={'UPDATE_LEADS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 SectionMain from '../../components/SectionMain'
|
||||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||||
import { getPageTitle } from '../../config'
|
import { getPageTitle } from '../../config'
|
||||||
import TableEnrollments from '../../components/Enrollments/TableEnrollments'
|
import TableLeads from '../../components/Leads/TableLeads'
|
||||||
import BaseButton from '../../components/BaseButton'
|
import BaseButton from '../../components/BaseButton'
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
||||||
import CardBoxModal from "../../components/CardBoxModal";
|
import CardBoxModal from "../../components/CardBoxModal";
|
||||||
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
||||||
import {setRefetch, uploadCsv} from '../../stores/enrollments/enrollmentsSlice';
|
import {setRefetch, uploadCsv} from '../../stores/leads/leadsSlice';
|
||||||
|
|
||||||
|
|
||||||
import {hasPermission} from "../../helpers/userPermissions";
|
import {hasPermission} from "../../helpers/userPermissions";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const EnrollmentsTablesPage = () => {
|
const LeadsTablesPage = () => {
|
||||||
const [filterItems, setFilterItems] = useState([]);
|
const [filterItems, setFilterItems] = useState([]);
|
||||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||||
const [isModalActive, setIsModalActive] = useState(false);
|
const [isModalActive, setIsModalActive] = useState(false);
|
||||||
@ -34,24 +34,20 @@ const EnrollmentsTablesPage = () => {
|
|||||||
const dispatch = useAppDispatch();
|
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: 'ProgressPercent', title: 'progress_percent', number: 'true'},{label: 'PricePaid', title: 'price_paid', number: 'true'},
|
{label: 'EstimatedValue', title: 'estimated_value', 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 = () => {
|
const addFilter = () => {
|
||||||
@ -68,13 +64,13 @@ const EnrollmentsTablesPage = () => {
|
|||||||
setFilterItems([...filterItems, newItem]);
|
setFilterItems([...filterItems, newItem]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getEnrollmentsCSV = async () => {
|
const getLeadsCSV = async () => {
|
||||||
const response = await axios({url: '/enrollments?filetype=csv', method: 'GET',responseType: 'blob'});
|
const response = await axios({url: '/leads?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||||
const type = response.headers['content-type']
|
const type = response.headers['content-type']
|
||||||
const blob = new Blob([response.data], { type: type })
|
const blob = new Blob([response.data], { type: type })
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a')
|
||||||
link.href = window.URL.createObjectURL(blob)
|
link.href = window.URL.createObjectURL(blob)
|
||||||
link.download = 'enrollmentsCSV.csv'
|
link.download = 'leadsCSV.csv'
|
||||||
link.click()
|
link.click()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -94,15 +90,15 @@ const EnrollmentsTablesPage = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('Enrollments')}</title>
|
<title>{getPageTitle('Leads')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Enrollments" main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Leads" main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
<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
|
<BaseButton
|
||||||
className={'mr-3'}
|
className={'mr-3'}
|
||||||
@ -110,7 +106,7 @@ const EnrollmentsTablesPage = () => {
|
|||||||
label='Filter'
|
label='Filter'
|
||||||
onClick={addFilter}
|
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 && (
|
{hasCreatePermission && (
|
||||||
<BaseButton
|
<BaseButton
|
||||||
@ -127,7 +123,7 @@ const EnrollmentsTablesPage = () => {
|
|||||||
</CardBox>
|
</CardBox>
|
||||||
|
|
||||||
<CardBox className="mb-6" hasTable>
|
<CardBox className="mb-6" hasTable>
|
||||||
<TableEnrollments
|
<TableLeads
|
||||||
filterItems={filterItems}
|
filterItems={filterItems}
|
||||||
setFilterItems={setFilterItems}
|
setFilterItems={setFilterItems}
|
||||||
filters={filters}
|
filters={filters}
|
||||||
@ -155,11 +151,11 @@ const EnrollmentsTablesPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
EnrollmentsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
LeadsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'READ_ENROLLMENTS'}
|
permission={'READ_LEADS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||||
import {RichTextField} from "../../components/RichTextField";
|
import {RichTextField} from "../../components/RichTextField";
|
||||||
|
|
||||||
import { create } from '../../stores/enrollments/enrollmentsSlice'
|
import { create } from '../../stores/leads/leadsSlice'
|
||||||
import { useAppDispatch } from '../../stores/hooks'
|
import { useAppDispatch } from '../../stores/hooks'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
@ -30,7 +30,7 @@ import moment from 'moment';
|
|||||||
const initialValues = {
|
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 router = useRouter()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
|
|
||||||
@ -154,7 +187,7 @@ const EnrollmentsNew = () => {
|
|||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
await dispatch(create(data))
|
await dispatch(create(data))
|
||||||
await router.push('/enrollments/enrollments-list')
|
await router.push('/leads/leads-list')
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -179,11 +212,11 @@ const EnrollmentsNew = () => {
|
|||||||
|
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
label="EnrollmentLabel"
|
label="Name"
|
||||||
>
|
>
|
||||||
<Field
|
<Field
|
||||||
name="enrollment_label"
|
name="name"
|
||||||
placeholder="EnrollmentLabel"
|
placeholder="Name"
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</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
|
<FormField
|
||||||
label="EnrolledAt"
|
label="Company"
|
||||||
>
|
>
|
||||||
<Field
|
<Field
|
||||||
type="datetime-local"
|
name="company"
|
||||||
name="enrolled_at"
|
placeholder="Company"
|
||||||
placeholder="EnrolledAt"
|
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</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">
|
<FormField label="Status" labelFor="status">
|
||||||
<Field name="status" id="status" component="select">
|
<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>
|
</Field>
|
||||||
</FormField>
|
</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
|
<FormField
|
||||||
label="ProgressPercent"
|
label="EstimatedValue"
|
||||||
>
|
>
|
||||||
<Field
|
<Field
|
||||||
type="number"
|
type="number"
|
||||||
name="progress_percent"
|
name="estimated_value"
|
||||||
placeholder="ProgressPercent"
|
placeholder="EstimatedValue"
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</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>
|
<BaseButtons>
|
||||||
<BaseButton type="submit" color="info" label="Submit" />
|
<BaseButton type="submit" color="info" label="Submit" />
|
||||||
<BaseButton type="reset" color="info" outline label="Reset" />
|
<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>
|
</BaseButtons>
|
||||||
</Form>
|
</Form>
|
||||||
</Formik>
|
</Formik>
|
||||||
@ -431,11 +545,11 @@ const EnrollmentsNew = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
EnrollmentsNew.getLayout = function getLayout(page: ReactElement) {
|
LeadsNew.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'CREATE_ENROLLMENTS'}
|
permission={'CREATE_LEADS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 SectionMain from '../../components/SectionMain'
|
||||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||||
import { getPageTitle } from '../../config'
|
import { getPageTitle } from '../../config'
|
||||||
import TableEnrollments from '../../components/Enrollments/TableEnrollments'
|
import TableLeads from '../../components/Leads/TableLeads'
|
||||||
import BaseButton from '../../components/BaseButton'
|
import BaseButton from '../../components/BaseButton'
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
||||||
import CardBoxModal from "../../components/CardBoxModal";
|
import CardBoxModal from "../../components/CardBoxModal";
|
||||||
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
||||||
import {setRefetch, uploadCsv} from '../../stores/enrollments/enrollmentsSlice';
|
import {setRefetch, uploadCsv} from '../../stores/leads/leadsSlice';
|
||||||
|
|
||||||
|
|
||||||
import {hasPermission} from "../../helpers/userPermissions";
|
import {hasPermission} from "../../helpers/userPermissions";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const EnrollmentsTablesPage = () => {
|
const LeadsTablesPage = () => {
|
||||||
const [filterItems, setFilterItems] = useState([]);
|
const [filterItems, setFilterItems] = useState([]);
|
||||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||||
const [isModalActive, setIsModalActive] = useState(false);
|
const [isModalActive, setIsModalActive] = useState(false);
|
||||||
@ -34,24 +34,20 @@ const EnrollmentsTablesPage = () => {
|
|||||||
const dispatch = useAppDispatch();
|
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: 'ProgressPercent', title: 'progress_percent', number: 'true'},{label: 'PricePaid', title: 'price_paid', number: 'true'},
|
{label: 'EstimatedValue', title: 'estimated_value', 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 = () => {
|
const addFilter = () => {
|
||||||
@ -68,13 +64,13 @@ const EnrollmentsTablesPage = () => {
|
|||||||
setFilterItems([...filterItems, newItem]);
|
setFilterItems([...filterItems, newItem]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getEnrollmentsCSV = async () => {
|
const getLeadsCSV = async () => {
|
||||||
const response = await axios({url: '/enrollments?filetype=csv', method: 'GET',responseType: 'blob'});
|
const response = await axios({url: '/leads?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||||
const type = response.headers['content-type']
|
const type = response.headers['content-type']
|
||||||
const blob = new Blob([response.data], { type: type })
|
const blob = new Blob([response.data], { type: type })
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a')
|
||||||
link.href = window.URL.createObjectURL(blob)
|
link.href = window.URL.createObjectURL(blob)
|
||||||
link.download = 'enrollmentsCSV.csv'
|
link.download = 'leadsCSV.csv'
|
||||||
link.click()
|
link.click()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -94,15 +90,15 @@ const EnrollmentsTablesPage = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('Enrollments')}</title>
|
<title>{getPageTitle('Leads')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Enrollments" main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Leads" main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
<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
|
<BaseButton
|
||||||
className={'mr-3'}
|
className={'mr-3'}
|
||||||
@ -110,7 +106,7 @@ const EnrollmentsTablesPage = () => {
|
|||||||
label='Filter'
|
label='Filter'
|
||||||
onClick={addFilter}
|
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 && (
|
{hasCreatePermission && (
|
||||||
<BaseButton
|
<BaseButton
|
||||||
@ -123,14 +119,14 @@ const EnrollmentsTablesPage = () => {
|
|||||||
<div className='md:inline-flex items-center ms-auto'>
|
<div className='md:inline-flex items-center ms-auto'>
|
||||||
<div id='delete-rows-button'></div>
|
<div id='delete-rows-button'></div>
|
||||||
|
|
||||||
<Link href={'/enrollments/enrollments-list'}>
|
<Link href={'/leads/leads-list'}>
|
||||||
Back to <span className='capitalize'>table</span>
|
Back to <span className='capitalize'>table</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</CardBox>
|
</CardBox>
|
||||||
<CardBox className="mb-6" hasTable>
|
<CardBox className="mb-6" hasTable>
|
||||||
<TableEnrollments
|
<TableLeads
|
||||||
filterItems={filterItems}
|
filterItems={filterItems}
|
||||||
setFilterItems={setFilterItems}
|
setFilterItems={setFilterItems}
|
||||||
filters={filters}
|
filters={filters}
|
||||||
@ -157,11 +153,11 @@ const EnrollmentsTablesPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
EnrollmentsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
LeadsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'READ_ENROLLMENTS'}
|
permission={'READ_LEADS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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 dayjs from "dayjs";
|
||||||
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
||||||
import {useRouter} from "next/router";
|
import {useRouter} from "next/router";
|
||||||
import { fetch } from '../../stores/lessons/lessonsSlice'
|
import { fetch } from '../../stores/leads/leadsSlice'
|
||||||
import {saveFile} from "../../helpers/fileSaver";
|
import {saveFile} from "../../helpers/fileSaver";
|
||||||
import dataFormatter from '../../helpers/dataFormatter';
|
import dataFormatter from '../../helpers/dataFormatter';
|
||||||
import ImageField from "../../components/ImageField";
|
import ImageField from "../../components/ImageField";
|
||||||
@ -21,10 +21,10 @@ import {SwitchField} from "../../components/SwitchField";
|
|||||||
import FormField from "../../components/FormField";
|
import FormField from "../../components/FormField";
|
||||||
|
|
||||||
|
|
||||||
const LessonsView = () => {
|
const LeadsView = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
const { lessons } = useAppSelector((state) => state.lessons)
|
const { leads } = useAppSelector((state) => state.leads)
|
||||||
|
|
||||||
|
|
||||||
const { id } = router.query;
|
const { id } = router.query;
|
||||||
@ -42,14 +42,14 @@ const LessonsView = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('View lessons')}</title>
|
<title>{getPageTitle('View leads')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View lessons')} main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View leads')} main>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
color='info'
|
color='info'
|
||||||
label='Edit'
|
label='Edit'
|
||||||
href={`/lessons/lessons-edit/?id=${id}`}
|
href={`/leads/leads-edit/?id=${id}`}
|
||||||
/>
|
/>
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox>
|
<CardBox>
|
||||||
@ -57,8 +57,104 @@ const LessonsView = () => {
|
|||||||
|
|
||||||
|
|
||||||
<div className={'mb-4'}>
|
<div className={'mb-4'}>
|
||||||
<p className={'block font-bold mb-2'}>Title</p>
|
<p className={'block font-bold mb-2'}>Name</p>
|
||||||
<p>{lessons?.title}</p>
|
<p>{leads?.name}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Company</p>
|
||||||
|
<p>{leads?.company}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Email</p>
|
||||||
|
<p>{leads?.email}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Phone</p>
|
||||||
|
<p>{leads?.phone}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -81,6 +177,16 @@ const LessonsView = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -93,9 +199,147 @@ const LessonsView = () => {
|
|||||||
|
|
||||||
|
|
||||||
<div className={'mb-4'}>
|
<div className={'mb-4'}>
|
||||||
<p className={'block font-bold mb-2'}>Content</p>
|
<p className={'block font-bold mb-2'}>Source</p>
|
||||||
{lessons.content
|
<p>{leads?.source ?? 'No data'}</p>
|
||||||
? <p dangerouslySetInnerHTML={{__html: lessons.content}}/>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Status</p>
|
||||||
|
<p>{leads?.status ?? 'No data'}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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>
|
: <p>No data</p>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@ -121,273 +365,6 @@ 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>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'mb-4'}>
|
|
||||||
<p className={'block font-bold mb-2'}>Duration(minutes)</p>
|
|
||||||
<p>{lessons?.duration_minutes || 'No data'}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<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>
|
|
||||||
}
|
|
||||||
</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>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className={'mb-4'}>
|
|
||||||
<p className={'block font-bold mb-2'}>Status</p>
|
|
||||||
<p>{lessons?.status ?? '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
|
<CardBox
|
||||||
className='mb-6 border border-gray-300 rounded overflow-hidden'
|
className='mb-6 border border-gray-300 rounded overflow-hidden'
|
||||||
hasTable
|
hasTable
|
||||||
@ -409,46 +386,64 @@ const LessonsView = () => {
|
|||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
|
|
||||||
<th>Note</th>
|
<th>Subject</th>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<th>ActivityType</th>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<th>Start</th>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<th>End</th>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<th>Completed</th>
|
<th>Completed</th>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<th>CompletedAt</th>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<th>Score</th>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<th>Attempts</th>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{lessons.progress_lesson && Array.isArray(lessons.progress_lesson) &&
|
{leads.activities_related_lead && Array.isArray(leads.activities_related_lead) &&
|
||||||
lessons.progress_lesson.map((item: any) => (
|
leads.activities_related_lead.map((item: any) => (
|
||||||
<tr key={item.id} onClick={() => router.push(`/progress/progress-view/?id=${item.id}`)}>
|
<tr key={item.id} onClick={() => router.push(`/activities/activities-view/?id=${item.id}`)}>
|
||||||
|
|
||||||
|
|
||||||
<td data-label="note">
|
<td data-label="subject">
|
||||||
{ item.note }
|
{ item.subject }
|
||||||
</td>
|
</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">
|
<td data-label="completed">
|
||||||
{ dataFormatter.booleanFormatter(item.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>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</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>
|
</CardBox>
|
||||||
</>
|
</>
|
||||||
|
|
||||||
@ -489,7 +474,7 @@ const LessonsView = () => {
|
|||||||
<BaseButton
|
<BaseButton
|
||||||
color='info'
|
color='info'
|
||||||
label='Back'
|
label='Back'
|
||||||
onClick={() => router.push('/lessons/lessons-list')}
|
onClick={() => router.push('/leads/leads-list')}
|
||||||
/>
|
/>
|
||||||
</CardBox>
|
</CardBox>
|
||||||
</SectionMain>
|
</SectionMain>
|
||||||
@ -497,11 +482,11 @@ const LessonsView = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
LessonsView.getLayout = function getLayout(page: ReactElement) {
|
LeadsView.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'READ_LESSONS'}
|
permission={'READ_LEADS'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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,
|
photographer_url: undefined,
|
||||||
})
|
})
|
||||||
const [ illustrationVideo, setIllustrationVideo ] = useState({video_files: []})
|
const [ illustrationVideo, setIllustrationVideo ] = useState({video_files: []})
|
||||||
const [contentType, setContentType] = useState('image');
|
const [contentType, setContentType] = useState('video');
|
||||||
const [contentPosition, setContentPosition] = useState('left');
|
const [contentPosition, setContentPosition] = useState('left');
|
||||||
const [showPassword, setShowPassword] = useState(false);
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
const { currentUser, isFetching, errorMessage, token, notify:notifyState } = useAppSelector(
|
const { currentUser, isFetching, errorMessage, token, notify:notifyState } = useAppSelector(
|
||||||
(state) => state.auth,
|
(state) => state.auth,
|
||||||
);
|
);
|
||||||
const [initialValues, setInitialValues] = React.useState({ email:'admin@flatlogic.com',
|
const [initialValues, setInitialValues] = React.useState({ email:'admin@flatlogic.com',
|
||||||
password: 'e52941c5',
|
password: '72a5084e',
|
||||||
remember: true })
|
remember: true })
|
||||||
|
|
||||||
const title = 'Instructor-Student LMS'
|
const title = 'Sales Pipeline CRM'
|
||||||
|
|
||||||
// Fetch Pexels image/video
|
// Fetch Pexels image/video
|
||||||
useEffect( () => {
|
useEffect( () => {
|
||||||
@ -172,15 +172,15 @@ export default function Login() {
|
|||||||
|
|
||||||
<p className='mb-2'>Use{' '}
|
<p className='mb-2'>Use{' '}
|
||||||
<code className={`cursor-pointer ${textColor} `}
|
<code className={`cursor-pointer ${textColor} `}
|
||||||
data-password="e52941c5"
|
data-password="72a5084e"
|
||||||
onClick={(e) => setLogin(e.target)}>admin@flatlogic.com</code>{' / '}
|
onClick={(e) => setLogin(e.target)}>admin@flatlogic.com</code>{' / '}
|
||||||
<code className={`${textColor}`}>e52941c5</code>{' / '}
|
<code className={`${textColor}`}>72a5084e</code>{' / '}
|
||||||
to login as Admin</p>
|
to login as Admin</p>
|
||||||
<p>Use <code
|
<p>Use <code
|
||||||
className={`cursor-pointer ${textColor} `}
|
className={`cursor-pointer ${textColor} `}
|
||||||
data-password="20ceb5eda155"
|
data-password="c6ada26bc4fa"
|
||||||
onClick={(e) => setLogin(e.target)}>client@hello.com</code>{' / '}
|
onClick={(e) => setLogin(e.target)}>client@hello.com</code>{' / '}
|
||||||
<code className={`${textColor}`}>20ceb5eda155</code>{' / '}
|
<code className={`${textColor}`}>c6ada26bc4fa</code>{' / '}
|
||||||
to login as User</p>
|
to login as User</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@ -94,6 +94,7 @@ const PermissionsView = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
|
|||||||
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 SectionMain from '../../components/SectionMain'
|
||||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||||
import { getPageTitle } from '../../config'
|
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 BaseButton from '../../components/BaseButton'
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
||||||
import CardBoxModal from "../../components/CardBoxModal";
|
import CardBoxModal from "../../components/CardBoxModal";
|
||||||
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
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";
|
import {hasPermission} from "../../helpers/userPermissions";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const LessonsTablesPage = () => {
|
const Pipeline_stagesTablesPage = () => {
|
||||||
const [filterItems, setFilterItems] = useState([]);
|
const [filterItems, setFilterItems] = useState([]);
|
||||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||||
const [isModalActive, setIsModalActive] = useState(false);
|
const [isModalActive, setIsModalActive] = useState(false);
|
||||||
@ -34,20 +34,16 @@ const LessonsTablesPage = () => {
|
|||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
|
||||||
const [filters] = useState([{label: 'Title', title: 'title'},{label: 'Content', title: 'content'},
|
const [filters] = useState([{label: 'Title', title: 'title'},
|
||||||
{label: 'Order', title: 'order', number: 'true'},{label: 'Duration(minutes)', title: 'duration_minutes', number: 'true'},
|
{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 = () => {
|
const addFilter = () => {
|
||||||
@ -64,13 +60,13 @@ const LessonsTablesPage = () => {
|
|||||||
setFilterItems([...filterItems, newItem]);
|
setFilterItems([...filterItems, newItem]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getLessonsCSV = async () => {
|
const getPipeline_stagesCSV = async () => {
|
||||||
const response = await axios({url: '/lessons?filetype=csv', method: 'GET',responseType: 'blob'});
|
const response = await axios({url: '/pipeline_stages?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||||
const type = response.headers['content-type']
|
const type = response.headers['content-type']
|
||||||
const blob = new Blob([response.data], { type: type })
|
const blob = new Blob([response.data], { type: type })
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a')
|
||||||
link.href = window.URL.createObjectURL(blob)
|
link.href = window.URL.createObjectURL(blob)
|
||||||
link.download = 'lessonsCSV.csv'
|
link.download = 'pipeline_stagesCSV.csv'
|
||||||
link.click()
|
link.click()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -90,15 +86,15 @@ const LessonsTablesPage = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{getPageTitle('Lessons')}</title>
|
<title>{getPageTitle('Pipeline_stages')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Lessons" main>
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Pipeline_stages" main>
|
||||||
{''}
|
{''}
|
||||||
</SectionTitleLineWithButton>
|
</SectionTitleLineWithButton>
|
||||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
<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
|
<BaseButton
|
||||||
className={'mr-3'}
|
className={'mr-3'}
|
||||||
@ -106,7 +102,7 @@ const LessonsTablesPage = () => {
|
|||||||
label='Filter'
|
label='Filter'
|
||||||
onClick={addFilter}
|
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 && (
|
{hasCreatePermission && (
|
||||||
<BaseButton
|
<BaseButton
|
||||||
@ -120,18 +116,16 @@ const LessonsTablesPage = () => {
|
|||||||
<div id='delete-rows-button'></div>
|
<div id='delete-rows-button'></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='md:inline-flex items-center ms-auto'>
|
|
||||||
<Link href={'/lessons/lessons-table'}>Switch to Table</Link>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</CardBox>
|
</CardBox>
|
||||||
|
|
||||||
<TableLessons
|
<CardBox className="mb-6" hasTable>
|
||||||
|
<TablePipeline_stages
|
||||||
filterItems={filterItems}
|
filterItems={filterItems}
|
||||||
setFilterItems={setFilterItems}
|
setFilterItems={setFilterItems}
|
||||||
filters={filters}
|
filters={filters}
|
||||||
showGrid={false}
|
showGrid={false}
|
||||||
/>
|
/>
|
||||||
|
</CardBox>
|
||||||
|
|
||||||
</SectionMain>
|
</SectionMain>
|
||||||
<CardBoxModal
|
<CardBoxModal
|
||||||
@ -153,11 +147,11 @@ const LessonsTablesPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
LessonsTablesPage.getLayout = function getLayout(page: ReactElement) {
|
Pipeline_stagesTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||||
return (
|
return (
|
||||||
<LayoutAuthenticated
|
<LayoutAuthenticated
|
||||||
|
|
||||||
permission={'READ_LESSONS'}
|
permission={'READ_PIPELINE_STAGES'}
|
||||||
|
|
||||||
>
|
>
|
||||||
{page}
|
{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