Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintenance: DateSelect component to tsx & server-handlers get-categories type #1776

Merged

Conversation

MikesGlitch
Copy link
Contributor

@MikesGlitch MikesGlitch commented Oct 9, 2023

Convert DateSelect component to TypeScript and update category query type.

#1483

@netlify
Copy link

netlify bot commented Oct 9, 2023

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit e22c381
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/652474304ed7f40008f91af6
😎 Deploy Preview https://deploy-preview-1776.demo.actualbudget.org/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2023

Bundle Stats — desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
16 2.48 MB → 2.48 MB (+127 B) +0.00%
Changeset
File Δ Size
src/components/select/DateSelect.tsx 🆕 +11.42 kB 0 B → 11.42 kB
src/components/select/DateSelect.js 🔥 -11.42 kB (-100%) 11.42 kB → 0 B
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/main.js 1.12 MB → 1.12 MB (+127 B) +0.01%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/678.chunk.js 420.74 kB 0%
static/media/Inter-italic.var.woff2 239.29 kB 0%
static/media/Inter-roman.var.woff2 221.86 kB 0%
static/js/713.chunk.js 156.56 kB 0%
static/js/wide-components.chunk.js 126.84 kB 0%
static/js/231.chunk.js 117.37 kB 0%
static/js/narrow-components.chunk.js 34.74 kB 0%
static/js/reports.chunk.js 29.23 kB 0%
static/js/473.chunk.js 13 kB 0%
static/js/389.chunk.js 12.77 kB 0%
static/js/resize-observer-polyfill.chunk.js 8.88 kB 0%
static/css/main.css 7.41 kB 0%
asset-manifest.json 2.07 kB 0%
index.html 1.66 kB 0%
static/media/browser-server.js 903 B 0%

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2023

Bundle Stats — loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
2 2.22 MB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.js 1.23 MB 0%
xfo.xfo.kcab.worker.js 1014.46 kB 0%

} from 'react';
import { useSelector } from 'react-redux';

import * as d from 'date-fns';
import { parse, parseISO, format, subDays, addDays, isValid } from 'date-fns';
Copy link
Contributor Author

@MikesGlitch MikesGlitch Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reducing import cost from
image
To
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing

if (date instanceof Date && !isNaN(date)) {
onSelect(d.format(date, 'yyyy-MM-dd'));
let date = parse(selectedValue, dateFormat, new Date());
if (date instanceof Date && !isNaN(date.valueOf())) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typescript was complaining about isNaN(date) because date is typed as a Date (previous check ensures that) - isNaN only accepts a number.

under the hood isNaN would convert the date object to a timestamp number - to satisfy typescript we now have to call that manually.

@MikesGlitch MikesGlitch changed the title DateSelect component to tsx Maintenance: DateSelect component to tsx and server-handlers category type Oct 9, 2023
@MikesGlitch MikesGlitch changed the title Maintenance: DateSelect component to tsx and server-handlers category type Maintenance: DateSelect component to tsx & server-handlers category type Oct 9, 2023
@MikesGlitch MikesGlitch changed the title Maintenance: DateSelect component to tsx & server-handlers category type Maintenance: DateSelect component to tsx & server-handlers get-categories type Oct 9, 2023
@MikesGlitch MikesGlitch marked this pull request as ready for review October 9, 2023 21:59
@@ -0,0 +1,2 @@
// Allow images to be imported
declare module '*.png';
Copy link
Contributor Author

@MikesGlitch MikesGlitch Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to allow us to import png's - typescript needs to know it's allowed. Used in DateSelect where we're importing the back and forward arrow images.

image

Copy link
Member

@MatissJanis MatissJanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment on lines +171 to +172
containerProps?: ViewProps;
inputProps?: InputProps;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥜 nitpick: ‏(for future reference) you can also do this:

Suggested change
containerProps?: ViewProps;
inputProps?: InputProps;
containerProps?: React.ComponentProps<typeof View>;
inputProps?: React.ComponentProps<typeof Input>;

@MatissJanis MatissJanis merged commit 057caf1 into actualbudget:master Oct 10, 2023
17 checks passed
@trafico-bot trafico-bot bot added ✨ Merged Pull Request has been merged successfully ✅ Approved and removed 🔍 Ready for Review ✨ Merged Pull Request has been merged successfully labels Oct 10, 2023
@MikesGlitch MikesGlitch deleted the maintenance/date-select-to-tsx branch October 10, 2023 20:30
FlorianLang06 pushed a commit to FlorianLang06/actual that referenced this pull request Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants