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

Removing texts part b#161 #269

Merged
merged 13 commits into from
Dec 4, 2023
Merged

Removing texts part b#161 #269

merged 13 commits into from
Dec 4, 2023

Conversation

amabelleS
Copy link
Collaborator

@amabelleS amabelleS commented Dec 2, 2023

Description

Removed from: GitHubLink & BugReportFormData.

** Next, src>routes.tsx, but we need to implement the PAGES array differently because we can't use a hook outside of a component **

screenshots

GitHubLink
image

BugReportFormData
image

EDIT

Meanwhile, I started working on routes.tsx. Pls check the proposal changes I made, and if approved I'll continue.
The idea is to replace the PAGES array with the getPages function:

export const getPages = () => {
  const { t } = useTranslation()
  return [
    {
      label: t('dashboard_page_title'),
      path: '/dashboard',
      icon: <LaptopOutlined />,
      element: <DashboardPage />,
    },
    {
      label: t('timeline_page_title'),
      path: '/timeline',
      searchParamsRequired: true,
      icon: <FieldTimeOutlined />,
      element: <TimelinePage />,
    },
    {
      label: t('gaps_page_title'),
      path: '/gaps',
      searchParamsRequired: true,
      icon: <BarChartOutlined />,
      element: <GapsPage />,
    },
    {
      label: t('gaps_patterns_page_title'),
      path: '/gaps_patterns',
      icon: <LineChartOutlined />,
      element: <GapsPatternsPage />,
    },
    {
      label: t('realtime_map_page_title'),
      path: '/map',
      icon: <HeatMapOutlined />,
      element: <RealtimeMapPage />,
    },
    {
      label: t('singleline_map_page_title'),
      path: '/single-line-map',
      searchParamsRequired: true,
      icon: <RadarChartOutlined />,
      element: <SingleLineMapPage />,
    },
    {
      label: t('about_title'),
      path: '/about',
      icon: <BellOutlined />,
      element: <About />,
    },
    {
      label: t('report_a_bug_title'),
      path: 'report-a-bug',
      icon: <BugOutlined />,
      element: <BugReportForm />,
    },
    {
      label: t('donate_title'),
      path: 'https://www.jgive.com/new/he/ils/donation-targets/3268#donation-modal',
      icon: <DollarOutlined />,
      element: null,
    },
  ]
}

Also important:

I noticed that the "old" translation of "dashboard_page_title" in text.tsx is: 'מפעילי תח"צ לפי קיום נסיעות מתוכננות'
But the new one in he.json is: 'קיום נסיעות'

Is is on purpose?

@amabelleS amabelleS requested a review from NoamGaash as a code owner December 2, 2023 16:07
Copy link
Member

@NoamGaash NoamGaash left a comment

Choose a reason for hiding this comment

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

Good job 💪
I've made some suggestions

src/App.tsx Outdated
@@ -62,6 +62,7 @@ const App = () => {
})

useEffect(() => {
// const page = pages.find((page) => page.path === location.pathname)
Copy link
Member

Choose a reason for hiding this comment

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

Please delete the commented line

@@ -4,6 +4,7 @@ import { PageContainer } from '../components/PageContainer'
import OperatorHbarChart from './OperatorHbarChart/OperatorHbarChart'
import './DashboardPage.scss'
import { TEXTS } from 'src/resources/texts'
// import { useTranslation } from 'react-i18next'
Copy link
Member

Choose a reason for hiding this comment

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

Please remove

@@ -24,6 +25,69 @@ import {
LineChartOutlined,
} from '@ant-design/icons'

export const getPages = () => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
export const getPages = () => {
export const usePages = () => {

Every function that calls react hook is a hook

},
]
}

export const PAGES = [
Copy link
Member

@NoamGaash NoamGaash Dec 2, 2023

Choose a reason for hiding this comment

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

Can you delete it?

First I need to remove all references to it, there are still some changes to make to replace the implementations of PAGES with the new usePages hook.
So I'll make the changes and ask again for a review for this PR, one that will complete the removal of TEXT_KEYS from routes.tsx.

Thx a lot for your suggestions, on it:)

@@ -85,8 +149,9 @@ export const PAGES = [
]

const RoutesList = () => {
const RedirectToDashboard = () => <Navigate to={PAGES[0].path} replace />
const routes = PAGES.filter((r) => r.element)
const pages = getPages()
Copy link
Member

Choose a reason for hiding this comment

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

Must be called outside this function, because it's a hook

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Must be called outside this function, because it's a hook

If you move usePages outside of a react component, you get this warning:
index.tsx:29 Warning: Invalid hook call. Hooks can only be called inside of the body of a function component.

I think I misunderstood you or something on this one:)

Copy link
Member

Choose a reason for hiding this comment

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

My bad, it should be inside the component, you're right ✅

@amabelleS amabelleS requested a review from NoamGaash December 2, 2023 20:00
Copy link
Contributor

@shootermv shootermv left a comment

Choose a reason for hiding this comment

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

looks very good to me
מפעילי תח"צ לפי קיום נסיעות מתוכננות - was something seemed hard to understand
i replaced it by קיום נסיעות
in order to make it more easy understand
but now, i think m- may be it can be better to replace it with
ביצועי תחבורה- מבט כללי

@amabelleS
Copy link
Collaborator Author

amabelleS commented Dec 2, 2023

looks very good to me מפעילי תח"צ לפי קיום נסיעות מתוכננות - was something seemed hard to understand i replaced it by קיום נסיעות in order to make it more easy understand but now, i think m- may be it can be better to replace it with ביצועי תחבורה- מבט כללי

for the he.json.
And for en.json: "Public transport operators - overview" ?

I tried to put it in this PR, but the validate/test failed, so I changed it back...
image

@NoamGaash
Copy link
Member

NoamGaash commented Dec 3, 2023

@amabelleS feel free to edit the tests if you want to :)

I'll put it in my next PR, changing to "Overview" / "מבט כללי" :)

Copy link
Contributor

@shootermv shootermv left a comment

Choose a reason for hiding this comment

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

nice work!
thanks @amabelleS !

@shootermv shootermv merged commit 402fc1b into main Dec 4, 2023
9 checks passed
@shootermv shootermv deleted the removing_texts-partB#161 branch December 4, 2023 07:08
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.

3 participants