Skip to content

Commit

Permalink
Merge pull request #9801 from MohammedFaragallah/next
Browse files Browse the repository at this point in the history
Upgrade date-fns to v3
  • Loading branch information
fzaninotto authored Apr 29, 2024
2 parents 4969243 + c301a90 commit a402c38
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 42 deletions.
2 changes: 1 addition & 1 deletion examples/crm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@nivo/bar": "^0.80.0",
"@nivo/core": "^0.80.0",
"clsx": "^1.1.1",
"date-fns": "^2.19.0",
"date-fns": "^3.6.0",
"faker": "~5.4.0",
"lodash": "~4.17.5",
"prop-types": "^15.8.1",
Expand Down
10 changes: 3 additions & 7 deletions examples/crm/src/companies/CompanyShow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,8 @@ const ContactsIterator = () => {
component="span"
>
last activity{' '}
{formatDistance(
new Date(contact.last_seen),
now
)}{' '}
ago <Status status={contact.status} />
{formatDistance(contact.last_seen, now)} ago{' '}
<Status status={contact.status} />
</Typography>
</ListItemSecondaryAction>
</ListItem>
Expand Down Expand Up @@ -252,8 +249,7 @@ const DealsIterator = () => {
component="span"
>
last activity{' '}
{formatDistance(new Date(deal.updated_at), now)}{' '}
ago{' '}
{formatDistance(deal.updated_at, now)} ago{' '}
</Typography>
</ListItemSecondaryAction>
</ListItem>
Expand Down
7 changes: 2 additions & 5 deletions examples/crm/src/contacts/ContactList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,8 @@ const ContactListContent = () => {
color="textSecondary"
>
last activity{' '}
{formatDistance(
new Date(contact.last_seen),
now
)}{' '}
ago <Status status={contact.status} />
{formatDistance(contact.last_seen, now)} ago{' '}
<Status status={contact.status} />
</Typography>
</ListItemSecondaryAction>
</ListItem>
Expand Down
4 changes: 2 additions & 2 deletions examples/crm/src/dashboard/DealsChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const DealsChart = () => {
if (!data) return [];
const dealsByMonth = data.reduce((acc, deal) => {
const month = startOfMonth(
deal.start_at ? new Date(deal.start_at) : new Date()
deal.start_at ?? new Date()
).toISOString();
if (!acc[month]) {
acc[month] = [];
Expand All @@ -39,7 +39,7 @@ export const DealsChart = () => {

const amountByMonth = Object.keys(dealsByMonth).map(month => {
return {
date: format(new Date(month), 'MMM'),
date: format(month, 'MMM'),
won: dealsByMonth[month]
.filter((deal: Deal) => deal.stage === 'won')
.reduce((acc: number, deal: Deal) => {
Expand Down
10 changes: 3 additions & 7 deletions examples/crm/src/dashboard/HotContacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,9 @@ export const HotContacts = () => {
}
resource="contacts"
secondaryText={(contact: Contact) =>
formatDistance(
new Date(contact.last_seen),
new Date(),
{
addSuffix: true,
}
)
formatDistance(contact.last_seen, new Date(), {
addSuffix: true,
})
}
leftAvatar={contact => <Avatar record={contact} />}
/>
Expand Down
10 changes: 3 additions & 7 deletions examples/crm/src/dashboard/LatestNotes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,9 @@ export const LatestNotes = () => {
<Contact note={note} />
)}
, added{' '}
{formatDistance(
new Date(note.date),
new Date(),
{
addSuffix: true,
}
)}
{formatDistance(note.date, new Date(), {
addSuffix: true,
})}
</Typography>
<div>
<Typography
Expand Down
2 changes: 1 addition & 1 deletion examples/crm/src/deals/DealShow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const DealShowContent = () => {
Start
</Typography>
<Typography variant="subtitle1">
{format(new Date(record.start_at), 'PP')}
{format(record.start_at, 'PP')}
</Typography>
</Box>

Expand Down
2 changes: 1 addition & 1 deletion examples/data-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"watch": "tsc --outDir dist/esm --module es2015 --watch"
},
"dependencies": {
"date-fns": "^2.19.0",
"date-fns": "^3.6.0",
"faker": "^4.1.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@vitejs/plugin-react": "^2.2.0",
"clsx": "^1.1.1",
"data-generator-retail": "^5.0.0-alpha.0",
"date-fns": "^2.19.0",
"date-fns": "^3.6.0",
"fakerest": "^3.0.0",
"fetch-mock": "~9.11.0",
"graphql": "^15.6.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/src/dashboard/OrderChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const aggregateOrdersByDay = (orders: Order[]): { [key: string]: number } =>
orders
.filter((order: Order) => order.status !== 'cancelled')
.reduce((acc, curr) => {
const day = format(new Date(curr.date), 'yyyy-MM-dd');
const day = format(curr.date, 'yyyy-MM-dd');
if (!acc[day]) {
acc[day] = 0;
}
Expand All @@ -37,7 +37,7 @@ const getRevenuePerDay = (orders: Order[]): TotalByDay[] => {
const daysWithRevenue = aggregateOrdersByDay(orders);
return lastMonthDays.map(date => ({
date: date.getTime(),
total: daysWithRevenue[format(new Date(date), 'yyyy-MM-dd')] || 0,
total: daysWithRevenue[format(date, 'yyyy-MM-dd')] || 0,
}));
};

Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"dependencies": {
"@tanstack/react-query": "^5.8.4",
"clsx": "^1.1.1",
"date-fns": "^2.19.0",
"date-fns": "^3.6.0",
"eventemitter3": "^4.0.7",
"hotscript": "^1.0.12",
"inflection": "~1.12.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-no-code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"dependencies": {
"@tanstack/react-query": "^5.8.4",
"clsx": "^1.1.1",
"date-fns": "^2.19.0",
"date-fns": "^3.6.0",
"inflection": "~1.12.0",
"lodash": "~4.17.5",
"papaparse": "^5.3.0",
Expand Down
19 changes: 13 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10174,7 +10174,7 @@ __metadata:
resolution: "data-generator-retail@workspace:examples/data-generator"
dependencies:
cross-env: "npm:^5.2.0"
date-fns: "npm:^2.19.0"
date-fns: "npm:^3.6.0"
faker: "npm:^4.1.0"
ra-core: "npm:^5.0.0-alpha.1"
rimraf: "npm:^3.0.2"
Expand All @@ -10195,13 +10195,20 @@ __metadata:
languageName: node
linkType: hard

"date-fns@npm:^2.0.1, date-fns@npm:^2.19.0":
"date-fns@npm:^2.0.1":
version: 2.28.0
resolution: "date-fns@npm:2.28.0"
checksum: ecdacd36326e7f5f8c4f1e78ae931a8997109f1c841f5163053b866585ca899521b0e7a114eeb48a9fe5135a550787bd4bbd8baa321cded0b4d823f847889a80
languageName: node
linkType: hard

"date-fns@npm:^3.6.0":
version: 3.6.0
resolution: "date-fns@npm:3.6.0"
checksum: 0b5fb981590ef2f8e5a3ba6cd6d77faece0ea7f7158948f2eaae7bbb7c80a8f63ae30b01236c2923cf89bb3719c33aeb150c715ea4fe4e86e37dcf06bed42fb6
languageName: node
linkType: hard

"dateformat@npm:^3.0.3":
version: 3.0.3
resolution: "dateformat@npm:3.0.3"
Expand Down Expand Up @@ -10443,7 +10450,7 @@ __metadata:
"@vitejs/plugin-react": "npm:^4.2.1"
clsx: "npm:^1.1.1"
data-generator-retail: "npm:^5.0.0-alpha.0"
date-fns: "npm:^2.19.0"
date-fns: "npm:^3.6.0"
fakerest: "npm:^3.0.0"
fetch-mock: "npm:~9.11.0"
graphql: "npm:^15.6.0"
Expand Down Expand Up @@ -18684,7 +18691,7 @@ __metadata:
"@types/react": "npm:^18.2.37"
clsx: "npm:^1.1.1"
cross-env: "npm:^5.2.0"
date-fns: "npm:^2.19.0"
date-fns: "npm:^3.6.0"
eventemitter3: "npm:^4.0.7"
expect: "npm:^27.4.6"
hotscript: "npm:^1.0.12"
Expand Down Expand Up @@ -18920,7 +18927,7 @@ __metadata:
"@testing-library/user-event": "npm:^14.5.1"
clsx: "npm:^1.1.1"
cross-env: "npm:^5.2.0"
date-fns: "npm:^2.19.0"
date-fns: "npm:^3.6.0"
inflection: "npm:~1.12.0"
lodash: "npm:~4.17.5"
papaparse: "npm:^5.3.0"
Expand Down Expand Up @@ -19091,7 +19098,7 @@ __metadata:
"@types/react-dom": "npm:^18.2.16"
"@vitejs/plugin-react": "npm:^4.2.1"
clsx: "npm:^1.1.1"
date-fns: "npm:^2.19.0"
date-fns: "npm:^3.6.0"
faker: "npm:~5.4.0"
lodash: "npm:~4.17.5"
prop-types: "npm:^15.8.1"
Expand Down

0 comments on commit a402c38

Please sign in to comment.