Forced merge: merge ai-dev into master

This commit is contained in:
Flatlogic Bot 2025-06-02 18:44:00 +00:00
commit 3e6dcc3a42
24 changed files with 192 additions and 63 deletions

5
.gitignore vendored
View File

@ -1,3 +1,8 @@
node_modules/
*/node_modules/
*/build/
**/node_modules/
**/build/
.DS_Store
.env

File diff suppressed because one or more lines are too long

View File

@ -20,6 +20,7 @@ module.exports = class LeadsDBApi {
country: data.country || null,
company_size: data.company_size || null,
conversion_likelihood: data.conversion_likelihood || null,
notes: data.notes || null,
importHash: data.importHash || null,
createdById: currentUser.id,
updatedById: currentUser.id,
@ -51,6 +52,7 @@ module.exports = class LeadsDBApi {
country: item.country || null,
company_size: item.company_size || null,
conversion_likelihood: item.conversion_likelihood || null,
notes: item.notes || null,
importHash: item.importHash || null,
createdById: currentUser.id,
updatedById: currentUser.id,
@ -85,6 +87,8 @@ module.exports = class LeadsDBApi {
if (data.conversion_likelihood !== undefined)
updatePayload.conversion_likelihood = data.conversion_likelihood;
if (data.notes !== undefined) updatePayload.notes = data.notes;
updatePayload.updatedById = currentUser.id;
await leads.update(updatePayload, { transaction });
@ -272,6 +276,13 @@ module.exports = class LeadsDBApi {
};
}
if (filter.notes) {
where = {
...where,
[Op.and]: Utils.ilike('leads', 'notes', filter.notes),
};
}
if (filter.conversion_likelihoodRange) {
const [start, end] = filter.conversion_likelihoodRange;

View File

@ -0,0 +1,47 @@
module.exports = {
/**
* @param {QueryInterface} queryInterface
* @param {Sequelize} Sequelize
* @returns {Promise<void>}
*/
async up(queryInterface, Sequelize) {
/**
* @type {Transaction}
*/
const transaction = await queryInterface.sequelize.transaction();
try {
await queryInterface.addColumn(
'leads',
'notes',
{
type: Sequelize.DataTypes.TEXT,
},
{ transaction },
);
await transaction.commit();
} catch (err) {
await transaction.rollback();
throw err;
}
},
/**
* @param {QueryInterface} queryInterface
* @param {Sequelize} Sequelize
* @returns {Promise<void>}
*/
async down(queryInterface, Sequelize) {
/**
* @type {Transaction}
*/
const transaction = await queryInterface.sequelize.transaction();
try {
await queryInterface.removeColumn('leads', 'notes', { transaction });
await transaction.commit();
} catch (err) {
await transaction.rollback();
throw err;
}
},
};

View File

@ -36,6 +36,10 @@ module.exports = function (sequelize, DataTypes) {
type: DataTypes.DECIMAL,
},
notes: {
type: DataTypes.TEXT,
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,

View File

@ -47,16 +47,6 @@ const CampaignsData = [
// type code here for "relation_many" field
},
{
title: 'Year-End Bonanza',
start_date: new Date('2023-11-01T00:00:00Z'),
end_date: new Date('2023-11-30T23:59:59Z'),
// type code here for "relation_many" field
},
];
const LeadsData = [
@ -67,13 +57,15 @@ const LeadsData = [
country: 'USA',
company_size: 'Small',
company_size: 'Medium',
conversion_likelihood: 0.75,
// type code here for "relation_one" field
// type code here for "relation_one" field
notes: 'Arthur Eddington',
},
{
@ -83,13 +75,15 @@ const LeadsData = [
country: 'Canada',
company_size: 'Small',
company_size: 'Medium',
conversion_likelihood: 0.6,
// type code here for "relation_one" field
// type code here for "relation_one" field
notes: 'Max von Laue',
},
{
@ -99,13 +93,15 @@ const LeadsData = [
country: 'UK',
company_size: 'Medium',
company_size: 'Large',
conversion_likelihood: 0.85,
// type code here for "relation_one" field
// type code here for "relation_one" field
notes: 'Max von Laue',
},
{
@ -122,22 +118,8 @@ const LeadsData = [
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
name: 'Soylent Corp',
contact: 'frank.thorn@soylent.com',
country: 'Australia',
company_size: 'Small',
conversion_likelihood: 0.55,
// type code here for "relation_one" field
// type code here for "relation_one" field
notes: 'Edward Teller',
},
];
@ -165,12 +147,6 @@ const StagesData = [
order: 4,
},
{
name: 'Negotiation',
order: 5,
},
];
// Similar logic for "relation_many"
@ -221,17 +197,6 @@ async function associateLeadWithStage() {
if (Lead3?.setStage) {
await Lead3.setStage(relatedStage3);
}
const relatedStage4 = await Stages.findOne({
offset: Math.floor(Math.random() * (await Stages.count())),
});
const Lead4 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Lead4?.setStage) {
await Lead4.setStage(relatedStage4);
}
}
async function associateLeadWithOwner() {
@ -278,17 +243,6 @@ async function associateLeadWithOwner() {
if (Lead3?.setOwner) {
await Lead3.setOwner(relatedOwner3);
}
const relatedOwner4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Lead4 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Lead4?.setOwner) {
await Lead4.setOwner(relatedOwner4);
}
}
module.exports = {

View File

@ -29,6 +29,9 @@ router.use(checkCrudPermissions('leads'));
* country:
* type: string
* default: country
* notes:
* type: string
* default: notes
* conversion_likelihood:
* type: integer
@ -315,6 +318,7 @@ router.get(
'name',
'contact',
'country',
'notes',
'conversion_likelihood',
];

View File

@ -45,7 +45,7 @@ module.exports = class SearchService {
campaigns: ['title'],
leads: ['name', 'contact', 'country'],
leads: ['name', 'contact', 'country', 'notes'],
stages: ['name'],
};

View File

@ -0,0 +1 @@
{}

View File

@ -3,6 +3,9 @@ import Link from 'next/link';
import moment from 'moment';
import ListActionsPopover from '../ListActionsPopover';
import { DragSourceMonitor, useDrag } from 'react-dnd';
import countryFlags from './countryFlags';
import dataFormatter from '../../helpers/dataFormatter';
type Props = {
item: any;
@ -37,13 +40,19 @@ const KanbanCard = ({
isDragging ? 'cursor-grabbing' : 'cursor-grab'
}`}
>
<div className={'flex items-center justify-between'}>
<div className={'flex items-center space-x-2'}>
<Link
href={`/${entityName}/${entityName}-view/?id=${item.id}`}
className={'text-base font-semibold'}
>
{countryFlags[item.country] ? `${countryFlags[item.country]} ` : ''}
{item[showFieldName] ?? 'No data'}
</Link>
{item.owner && (
<span className='text-xs bg-blue-100 text-blue-800 px-1.5 py-0.5 rounded'>
{dataFormatter.usersOneListFormatter(item.owner)}
</span>
)}
</div>
<div className={'flex items-center justify-between'}>
<p>{moment(item.createdAt).format('MMM DD hh:mm a')}</p>

View File

@ -161,7 +161,7 @@ const KanbanColumn = ({
<CardBox
hasComponentLayout
className={
'w-72 rounded-md h-fit max-h-full overflow-hidden flex flex-col'
'w-56 rounded-md h-fit max-h-full overflow-hidden flex flex-col'
}
>
<div className={'flex items-center justify-between p-3'}>

View File

@ -0,0 +1,31 @@
const countryFlags: { [key: string]: string } = {
Germany: '🇩🇪',
France: '🇫🇷',
Spain: '🇪🇸',
Italy: '🇮🇹',
Netherlands: '🇳🇱',
Belgium: '🇧🇪',
Sweden: '🇸🇪',
Poland: '🇵🇱',
Romania: '🇷🇴',
Portugal: '🇵🇹',
Ireland: '🇮🇪',
Greece: '🇬🇷',
'Czech Republic': '🇨🇿',
USA: '🇺🇸',
UK: '🇬🇧',
'United Kingdom': '🇬🇧',
'United States': '🇺🇸',
Canada: '🇨🇦',
Australia: '🇦🇺',
Brazil: '🇧🇷',
Argentina: '🇦🇷',
Mexico: '🇲🇽',
Chile: '🇨🇱',
India: '🇮🇳',
Pakistan: '🇵🇰',
};
export default countryFlags;

View File

@ -144,6 +144,13 @@ const CardLeads = ({
</div>
</dd>
</div>
<div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'>Notes</dt>
<dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'>{item.notes}</div>
</dd>
</div>
</dl>
</li>
))}

View File

@ -93,6 +93,11 @@ const ListLeads = ({
{dataFormatter.usersOneListFormatter(item.owner)}
</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>
</Link>
<ListActionsPopover
onDelete={onDelete}

View File

@ -140,6 +140,18 @@ export const loadColumns = async (
params?.value?.id ?? params?.value,
},
{
field: 'notes',
headerName: 'Notes',
flex: 1,
minWidth: 120,
filterable: false,
headerClassName: 'datagrid--header',
cellClassName: 'datagrid--cell',
editable: hasUpdatePermission,
},
{
field: 'actions',
type: 'actions',

View File

@ -116,6 +116,8 @@ const CampaignsView = () => {
<th>CompanySize</th>
<th>ConversionLikelihood</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
@ -139,6 +141,8 @@ const CampaignsView = () => {
<td data-label='conversion_likelihood'>
{item.conversion_likelihood}
</td>
<td data-label='notes'>{item.notes}</td>
</tr>
))}
</tbody>

View File

@ -49,6 +49,8 @@ const EditLeads = () => {
stage: null,
owner: null,
notes: '',
};
const [initialValues, setInitialValues] = useState(initVals);
@ -153,6 +155,10 @@ const EditLeads = () => {
></Field>
</FormField>
<FormField label='Notes'>
<Field name='notes' placeholder='Notes' />
</FormField>
<BaseDivider />
<BaseButtons>
<BaseButton type='submit' color='info' label='Submit' />

View File

@ -49,6 +49,8 @@ const EditLeadsPage = () => {
stage: null,
owner: null,
notes: '',
};
const [initialValues, setInitialValues] = useState(initVals);
@ -151,6 +153,10 @@ const EditLeadsPage = () => {
></Field>
</FormField>
<FormField label='Notes'>
<Field name='notes' placeholder='Notes' />
</FormField>
<BaseDivider />
<BaseButtons>
<BaseButton type='submit' color='info' label='Submit' />

View File

@ -32,6 +32,7 @@ const LeadsTablesPage = () => {
{ label: 'Name', title: 'name' },
{ label: 'Contact', title: 'contact' },
{ label: 'Country', title: 'country' },
{ label: 'Notes', title: 'notes' },
{
label: 'ConversionLikelihood',

View File

@ -46,6 +46,8 @@ const initialValues = {
stage: '',
owner: '',
notes: '',
};
const LeadsNew = () => {
@ -125,6 +127,10 @@ const LeadsNew = () => {
></Field>
</FormField>
<FormField label='Notes'>
<Field name='notes' placeholder='Notes' />
</FormField>
<BaseDivider />
<BaseButtons>
<BaseButton type='submit' color='info' label='Submit' />

View File

@ -32,6 +32,7 @@ const LeadsTablesPage = () => {
{ label: 'Name', title: 'name' },
{ label: 'Contact', title: 'contact' },
{ label: 'Country', title: 'country' },
{ label: 'Notes', title: 'notes' },
{
label: 'ConversionLikelihood',

View File

@ -91,6 +91,11 @@ const LeadsView = () => {
<p>{leads?.owner?.firstName ?? 'No data'}</p>
</div>
<div className={'mb-4'}>
<p className={'block font-bold mb-2'}>Notes</p>
<p>{leads?.notes}</p>
</div>
<BaseDivider />
<BaseButton

View File

@ -83,6 +83,8 @@ const StagesView = () => {
<th>CompanySize</th>
<th>ConversionLikelihood</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
@ -106,6 +108,8 @@ const StagesView = () => {
<td data-label='conversion_likelihood'>
{item.conversion_likelihood}
</td>
<td data-label='notes'>{item.notes}</td>
</tr>
))}
</tbody>

View File

@ -157,6 +157,8 @@ const UsersView = () => {
<th>CompanySize</th>
<th>ConversionLikelihood</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
@ -180,6 +182,8 @@ const UsersView = () => {
<td data-label='conversion_likelihood'>
{item.conversion_likelihood}
</td>
<td data-label='notes'>{item.notes}</td>
</tr>
))}
</tbody>