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

Refactoring of class components to functional components #7629

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from

Conversation

noah-brunate
Copy link
Collaborator

I have converted the class component in the file RequiresUpdate.tsx into a functional component.

@ocrvs-bot
Copy link
Collaborator

Your environment is deployed to https://ocrvs-993.opencrvs.dev.

@noah-brunate noah-brunate changed the title Refactoring of class component a functional component Refactoring of class components to functional components Sep 23, 2024
Copy link
Collaborator

@Zangetsu101 Zangetsu101 left a comment

Choose a reason for hiding this comment

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

I noticed some styling issues in your changes, so I suggest you install prettier & eslint plugin in your VSCode (I assumed that's what you're using as an editor) which should take care of those

@@ -17,7 +17,8 @@ import { injectIntl, WrappedComponentProps } from 'react-intl'
import styled, { withTheme } from 'styled-components'
import { CompletenessRateTime } from '@client/views/SysAdmin/Performance/utils'
import { messages } from '@client/i18n/messages/views/performance'
import type { LegendProps } from 'recharts'
// import type { LegendProps } from 'recharts'
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can directly remove this if it's not needed anymore

Comment on lines 75 to 76
// Not needed for functional component
/*interface IRejectTabState {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's remove it if it's not needed

Comment on lines 90 to 96
useEffect(() => {
function recordWindowWidth() {
setWidth(window.innerWidth);
}
window.addEventListener('resize', recordWindowWidth);
return () => window.removeEventListener('resize', recordWindowWidth);
}, []);
Copy link
Collaborator

Choose a reason for hiding this comment

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

useWindowSize

Comment on lines -30 to -48
interface IActiveState {
value: number
stroke: string
}
interface IState {
legendMarginTop: number
legendMarginLeft: number
chartTop: number
chartRight: number
chartBottom: number
chartLeft: number
maximizeXAxisInterval?: boolean
legendLayout: LegendProps['layout']
activeLabel: string
activeRegisteredInTargetDays: IActiveState
activeTotalRegistered: IActiveState
activeTotalEstimate: IActiveState
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably better to keep it and use in useState<IState>(...) at line no 146

Copy link
Collaborator

@Zangetsu101 Zangetsu101 left a comment

Choose a reason for hiding this comment

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

Awesome work @noah-brunate!

@Zangetsu101
Copy link
Collaborator

@noah-brunate Could you please update the CHANGELOG describing what we achieved on this PR? It should go under 1.7 -> Improvements

@opencrvs opencrvs deleted a comment from github-actions bot Sep 27, 2024

This comment has been minimized.

@Zangetsu101
Copy link
Collaborator

@noah-brunate looks like there are failing tests here, you can look at my comment here on how to run the tests locally on your machine: #7665 (comment)

CHANGELOG.md Outdated
@@ -11,6 +11,7 @@
- Fetch child identifier in view record
- Auth token, ip address, remote address redacted from server log
- **Align Patient data model with FHIR**: Previously we were using `string[]` for `Patient.name.family` field instead of `string` as mentioned in the FHIR standard. We've now aligned the field with the standard.
- Changed multiple class components into functional components [#993](https://github.com/opencrvs/opencrvs-core/issues/993)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Changed multiple class components into functional components [#993](https://github.com/opencrvs/opencrvs-core/issues/993)
- Refactored multiple class components into functional ones to facilitate the usage of `useWindowSize` hook [#993](https://github.com/opencrvs/opencrvs-core/issues/993)

Copy link
Member

Choose a reason for hiding this comment

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

For such a internal change, we can also omit the changelog mention completely. These types of changes do not really affect country implementors or users of OpenCRVS

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

noted, but will it not affect the merging if needed as a requirement

@Zangetsu101
Copy link
Collaborator

Zangetsu101 commented Oct 9, 2024

@noah-brunate The tests need to be fixed before thie can be merged in

Copy link
Collaborator

@Zangetsu101 Zangetsu101 left a comment

Choose a reason for hiding this comment

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

Tests need to be passing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants