Skip to content

Commit

Permalink
Fix(crm): Remove start_at from deals as it is the same as created_at
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanarnault committed Jul 26, 2024
1 parent a1dda3c commit 8df44f2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
6 changes: 4 additions & 2 deletions examples/crm/src/dashboard/DealsChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const DealsChart = () => {
const { data, isPending } = useGetList<Deal>('deals', {
pagination: { perPage: 100, page: 1 },
sort: {
field: 'start_at',
field: 'created_at',
order: 'ASC',
},
});
Expand All @@ -27,7 +27,7 @@ export const DealsChart = () => {
if (!data) return [];
const dealsByMonth = data.reduce((acc, deal) => {
const month = startOfMonth(
deal.start_at ?? new Date()
deal.created_at ?? new Date()
).toISOString();
if (!acc[month]) {
acc[month] = [];
Expand All @@ -36,6 +36,8 @@ export const DealsChart = () => {
return acc;
}, {} as any);

console.log(dealsByMonth);

const amountByMonth = Object.keys(dealsByMonth).map(month => {
return {
date: format(month, 'MMM'),
Expand Down
8 changes: 3 additions & 5 deletions examples/crm/src/dataGenerator/deals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ export const generateDeals = (db: Db): Deal[] => {
new Date(company.created_at)
).toISOString();

const start_at = created_at;
const expected_closing_date = randomDate(
new Date(start_at),
add(new Date(start_at), { months: 6 })
new Date(created_at),
add(new Date(created_at), { months: 6 })
).toISOString();

return {
Expand All @@ -37,9 +36,8 @@ export const generateDeals = (db: Db): Deal[] => {
stage: random.arrayElement(defaultDealStages).value,
description: lorem.paragraphs(random.number({ min: 1, max: 4 })),
amount: random.number(1000) * 100,
created_at: created_at,
created_at,
updated_at: randomDate(new Date(created_at)).toISOString(),
start_at,
expected_closing_date,
sales_id: company.sales_id,
index: 0,
Expand Down
1 change: 0 additions & 1 deletion examples/crm/src/dataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ export const dataProvider = withLifecycleCallbacks(
...params,
data: {
...params.data,
start_at: new Date().toISOString(),
created_at: new Date().toISOString(),
updated_at: new Date().toISOString(),
},
Expand Down
1 change: 0 additions & 1 deletion examples/crm/src/deals/DealCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export const DealCreate = ({ open }: { open: boolean }) => {
sales_id: identity?.id,
contact_ids: [],
index: 0,
start_at: new Date().toISOString(),
}}
>
<DialogContent>
Expand Down
1 change: 0 additions & 1 deletion examples/crm/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export interface Deal extends RaRecord {
created_at: string;
updated_at: string;
archived_at?: string;
start_at: string;
expected_closing_date: string;
sales_id: Identifier;
index: number;
Expand Down

0 comments on commit 8df44f2

Please sign in to comment.