Compare commits

..

2 Commits

Author SHA1 Message Date
Flatlogic Bot
fcf280ba6e 270425 2025-04-27 20:52:37 +00:00
Flatlogic Bot
713862172e v1 2025-04-27 20:32:47 +00:00
9 changed files with 283 additions and 74 deletions

5
.gitignore vendored
View File

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

File diff suppressed because one or more lines are too long

View File

@ -268,24 +268,6 @@ module.exports = class EventsDBApi {
}; };
} }
if (filter.calendarStart && filter.calendarEnd) {
where = {
...where,
[Op.or]: [
{
start_date: {
[Op.between]: [filter.calendarStart, filter.calendarEnd],
},
},
{
end_date: {
[Op.between]: [filter.calendarStart, filter.calendarEnd],
},
},
],
};
}
if (filter.start_dateRange) { if (filter.start_dateRange) {
const [start, end] = filter.start_dateRange; const [start, end] = filter.start_dateRange;

View File

@ -65,6 +65,42 @@ const CustomersData = [
// type code here for "relation_one" field // type code here for "relation_one" field
}, },
{
first_name: 'Bob',
last_name: 'Brown',
email: 'bob.brown@example.com',
vat_number: '321654987',
// type code here for "relation_one" field
// type code here for "relation_many" field
// type code here for "relation_many" field
// type code here for "relation_one" field
},
{
first_name: 'Charlie',
last_name: 'Davis',
email: 'charlie.davis@example.com',
vat_number: '654321789',
// type code here for "relation_one" field
// type code here for "relation_many" field
// type code here for "relation_many" field
// type code here for "relation_one" field
},
]; ];
const EmailCampaignsData = [ const EmailCampaignsData = [
@ -103,6 +139,30 @@ const EmailCampaignsData = [
// type code here for "relation_one" field // type code here for "relation_one" field
}, },
{
template: 'Tax Season Preparation Guide',
scheduled_date: new Date('2023-11-20T08:00:00Z'),
// type code here for "relation_many" field
// type code here for "relation_many" field
// type code here for "relation_one" field
},
{
template: 'Retirement Planning Essentials',
scheduled_date: new Date('2023-11-25T08:00:00Z'),
// type code here for "relation_many" field
// type code here for "relation_many" field
// type code here for "relation_one" field
},
]; ];
const EventsData = [ const EventsData = [
@ -153,6 +213,38 @@ const EventsData = [
// type code here for "relation_one" field // type code here for "relation_one" field
}, },
{
title: 'Retirement Planning Session',
note: 'Plan for retirement savings and investments.',
start_date: new Date('2023-11-15T13:00:00Z'),
end_date: new Date('2023-11-15T14:30:00Z'),
// type code here for "relation_one" field
// type code here for "relation_many" field
// type code here for "relation_one" field
},
{
title: 'Insurance Policy Review',
note: 'Evaluate current insurance coverage.',
start_date: new Date('2023-11-20T11:00:00Z'),
end_date: new Date('2023-11-20T12:00:00Z'),
// type code here for "relation_one" field
// type code here for "relation_many" field
// type code here for "relation_one" field
},
]; ];
const TagsData = [ const TagsData = [
@ -173,19 +265,39 @@ const TagsData = [
// type code here for "relation_one" field // type code here for "relation_one" field
}, },
{
name: 'Newsletter Subscriber',
// type code here for "relation_one" field
},
{
name: 'Long-term Client',
// type code here for "relation_one" field
},
]; ];
const DonderoorganizationData = [ const DonderoorganizationData = [
{ {
name: 'Edward O. Wilson', name: 'Karl Landsteiner',
}, },
{ {
name: 'Frederick Gowland Hopkins', name: 'Leonard Euler',
}, },
{ {
name: 'Stephen Hawking', name: 'John von Neumann',
},
{
name: 'Gregor Mendel',
},
{
name: 'Charles Sherrington',
}, },
]; ];
@ -224,6 +336,28 @@ async function associateUserWithDonderoorganization() {
if (User2?.setDonderoorganization) { if (User2?.setDonderoorganization) {
await User2.setDonderoorganization(relatedDonderoorganization2); await User2.setDonderoorganization(relatedDonderoorganization2);
} }
const relatedDonderoorganization3 = await Donderoorganization.findOne({
offset: Math.floor(Math.random() * (await Donderoorganization.count())),
});
const User3 = await Users.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (User3?.setDonderoorganization) {
await User3.setDonderoorganization(relatedDonderoorganization3);
}
const relatedDonderoorganization4 = await Donderoorganization.findOne({
offset: Math.floor(Math.random() * (await Donderoorganization.count())),
});
const User4 = await Users.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (User4?.setDonderoorganization) {
await User4.setDonderoorganization(relatedDonderoorganization4);
}
} }
async function associateCustomerWithSupervisor() { async function associateCustomerWithSupervisor() {
@ -259,6 +393,28 @@ async function associateCustomerWithSupervisor() {
if (Customer2?.setSupervisor) { if (Customer2?.setSupervisor) {
await Customer2.setSupervisor(relatedSupervisor2); await Customer2.setSupervisor(relatedSupervisor2);
} }
const relatedSupervisor3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Customer3 = await Customers.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Customer3?.setSupervisor) {
await Customer3.setSupervisor(relatedSupervisor3);
}
const relatedSupervisor4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Customer4 = await Customers.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Customer4?.setSupervisor) {
await Customer4.setSupervisor(relatedSupervisor4);
}
} }
// Similar logic for "relation_many" // Similar logic for "relation_many"
@ -298,6 +454,28 @@ async function associateCustomerWithDonderoorganization() {
if (Customer2?.setDonderoorganization) { if (Customer2?.setDonderoorganization) {
await Customer2.setDonderoorganization(relatedDonderoorganization2); await Customer2.setDonderoorganization(relatedDonderoorganization2);
} }
const relatedDonderoorganization3 = await Donderoorganization.findOne({
offset: Math.floor(Math.random() * (await Donderoorganization.count())),
});
const Customer3 = await Customers.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Customer3?.setDonderoorganization) {
await Customer3.setDonderoorganization(relatedDonderoorganization3);
}
const relatedDonderoorganization4 = await Donderoorganization.findOne({
offset: Math.floor(Math.random() * (await Donderoorganization.count())),
});
const Customer4 = await Customers.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Customer4?.setDonderoorganization) {
await Customer4.setDonderoorganization(relatedDonderoorganization4);
}
} }
// Similar logic for "relation_many" // Similar logic for "relation_many"
@ -337,6 +515,28 @@ async function associateEmailCampaignWithDonderoorganization() {
if (EmailCampaign2?.setDonderoorganization) { if (EmailCampaign2?.setDonderoorganization) {
await EmailCampaign2.setDonderoorganization(relatedDonderoorganization2); await EmailCampaign2.setDonderoorganization(relatedDonderoorganization2);
} }
const relatedDonderoorganization3 = await Donderoorganization.findOne({
offset: Math.floor(Math.random() * (await Donderoorganization.count())),
});
const EmailCampaign3 = await EmailCampaigns.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (EmailCampaign3?.setDonderoorganization) {
await EmailCampaign3.setDonderoorganization(relatedDonderoorganization3);
}
const relatedDonderoorganization4 = await Donderoorganization.findOne({
offset: Math.floor(Math.random() * (await Donderoorganization.count())),
});
const EmailCampaign4 = await EmailCampaigns.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (EmailCampaign4?.setDonderoorganization) {
await EmailCampaign4.setDonderoorganization(relatedDonderoorganization4);
}
} }
async function associateEventWithCustomer() { async function associateEventWithCustomer() {
@ -372,6 +572,28 @@ async function associateEventWithCustomer() {
if (Event2?.setCustomer) { if (Event2?.setCustomer) {
await Event2.setCustomer(relatedCustomer2); await Event2.setCustomer(relatedCustomer2);
} }
const relatedCustomer3 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const Event3 = await Events.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Event3?.setCustomer) {
await Event3.setCustomer(relatedCustomer3);
}
const relatedCustomer4 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const Event4 = await Events.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Event4?.setCustomer) {
await Event4.setCustomer(relatedCustomer4);
}
} }
// Similar logic for "relation_many" // Similar logic for "relation_many"
@ -409,6 +631,28 @@ async function associateEventWithDonderoorganization() {
if (Event2?.setDonderoorganization) { if (Event2?.setDonderoorganization) {
await Event2.setDonderoorganization(relatedDonderoorganization2); await Event2.setDonderoorganization(relatedDonderoorganization2);
} }
const relatedDonderoorganization3 = await Donderoorganization.findOne({
offset: Math.floor(Math.random() * (await Donderoorganization.count())),
});
const Event3 = await Events.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Event3?.setDonderoorganization) {
await Event3.setDonderoorganization(relatedDonderoorganization3);
}
const relatedDonderoorganization4 = await Donderoorganization.findOne({
offset: Math.floor(Math.random() * (await Donderoorganization.count())),
});
const Event4 = await Events.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Event4?.setDonderoorganization) {
await Event4.setDonderoorganization(relatedDonderoorganization4);
}
} }
async function associateTagWithDonderoorganization() { async function associateTagWithDonderoorganization() {
@ -444,6 +688,28 @@ async function associateTagWithDonderoorganization() {
if (Tag2?.setDonderoorganization) { if (Tag2?.setDonderoorganization) {
await Tag2.setDonderoorganization(relatedDonderoorganization2); await Tag2.setDonderoorganization(relatedDonderoorganization2);
} }
const relatedDonderoorganization3 = await Donderoorganization.findOne({
offset: Math.floor(Math.random() * (await Donderoorganization.count())),
});
const Tag3 = await Tags.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Tag3?.setDonderoorganization) {
await Tag3.setDonderoorganization(relatedDonderoorganization3);
}
const relatedDonderoorganization4 = await Donderoorganization.findOne({
offset: Math.floor(Math.random() * (await Donderoorganization.count())),
});
const Tag4 = await Tags.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Tag4?.setDonderoorganization) {
await Tag4.setDonderoorganization(relatedDonderoorganization4);
}
} }
module.exports = { module.exports = {

View File

@ -0,0 +1 @@
{}

View File

@ -20,10 +20,7 @@ import _ from 'lodash';
import dataFormatter from '../../helpers/dataFormatter'; import dataFormatter from '../../helpers/dataFormatter';
import { dataGridStyles } from '../../styles'; import { dataGridStyles } from '../../styles';
import BigCalendar from '../BigCalendar'; const perPage = 10;
import { SlotInfo } from 'react-big-calendar';
const perPage = 100;
const TableSampleEvents = ({ const TableSampleEvents = ({
filterItems, filterItems,
@ -101,12 +98,6 @@ const TableSampleEvents = ({
setIsModalTrashActive(false); setIsModalTrashActive(false);
}; };
const handleCreateEventAction = ({ start, end }: SlotInfo) => {
router.push(
`/events/events-new?dateRangeStart=${start.toISOString()}&dateRangeEnd=${end.toISOString()}`,
);
};
const handleDeleteModalAction = (id: string) => { const handleDeleteModalAction = (id: string) => {
setId(id); setId(id);
setIsModalTrashActive(true); setIsModalTrashActive(true);
@ -470,27 +461,7 @@ const TableSampleEvents = ({
<p>Are you sure you want to delete this item?</p> <p>Are you sure you want to delete this item?</p>
</CardBoxModal> </CardBoxModal>
{!showGrid && ( {dataGrid}
<BigCalendar
events={events}
showField={'title'}
start-data-key={'start_date'}
end-data-key={'end_date'}
handleDeleteAction={handleDeleteModalAction}
pathEdit={`/events/events-edit/?id=`}
pathView={`/events/events-view/?id=`}
handleCreateEventAction={handleCreateEventAction}
onDateRangeChange={(range) => {
loadData(
0,
`&calendarStart=${range.start}&calendarEnd=${range.end}`,
);
}}
entityName={'events'}
/>
)}
{showGrid && dataGrid}
{selectedRows.length > 0 && {selectedRows.length > 0 &&
createPortal( createPortal(

View File

@ -131,10 +131,6 @@ const EventsTablesPage = () => {
<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>
</div> </div>
<div className='md:inline-flex items-center ms-auto'>
<Link href={'/events/events-table'}>Switch to Table</Link>
</div>
</CardBox> </CardBox>
<CardBox className='mb-6' hasTable> <CardBox className='mb-6' hasTable>

View File

@ -52,9 +52,6 @@ const EventsNew = () => {
const router = useRouter(); const router = useRouter();
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
// get from url params
const { dateRangeStart, dateRangeEnd } = router.query;
const handleSubmit = async (data) => { const handleSubmit = async (data) => {
await dispatch(create(data)); await dispatch(create(data));
await router.push('/events/events-list'); await router.push('/events/events-list');
@ -74,16 +71,7 @@ const EventsNew = () => {
</SectionTitleLineWithButton> </SectionTitleLineWithButton>
<CardBox> <CardBox>
<Formik <Formik
initialValues={ initialValues={initialValues}
dateRangeStart && dateRangeEnd
? {
...initialValues,
start_date:
moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
end_date: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
}
: initialValues
}
onSubmit={(values) => handleSubmit(values)} onSubmit={(values) => handleSubmit(values)}
> >
<Form> <Form>

View File

@ -132,7 +132,7 @@ const EventsTablesPage = () => {
<div id='delete-rows-button'></div> <div id='delete-rows-button'></div>
<Link href={'/events/events-list'}> <Link href={'/events/events-list'}>
Back to <span className='capitalize'>calendar</span> Back to <span className='capitalize'>table</span>
</Link> </Link>
</div> </div>
</CardBox> </CardBox>