Skip to content

Commit c6e1975

Browse files
committed
added rtk for lomake
1 parent dc6bede commit c6e1975

File tree

6 files changed

+95
-29
lines changed

6 files changed

+95
-29
lines changed

client/components/MetaEvaluationView/ProgrammeLevelOverview/FacultyDropdown.jsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import React, { useEffect, useState } from 'react'
1+
import React, { useState, useEffect } from 'react'
22
import { Dropdown, MenuItem } from 'semantic-ui-react'
3+
import { useTranslation } from 'react-i18next'
34

4-
const FacultyDropdown = ({ t, handleFilterChange, faculties, lang, debouncedFilter }) => {
5+
const FacultyDropdown = ({ faculties, debouncedFilter, lang, handleFilterChange }) => {
6+
const { t } = useTranslation()
57
const [dropdownText, setDropdownText] = useState(t('chooseFaculty'))
68

79
useEffect(() => {
8-
if (debouncedFilter === '') setDropdownText(t('chooseFaculty'))
9-
else
10-
setDropdownText(
11-
faculties?.data.find(f => f.code === debouncedFilter)?.name[lang]
12-
? faculties?.data.find(f => f.code === debouncedFilter)?.name[lang]
13-
: t('chooseFaculty'),
14-
)
15-
}, [debouncedFilter, lang])
10+
setDropdownText(
11+
faculties?.data.find(f => f.code === debouncedFilter)?.name[lang]
12+
? faculties?.data.find(f => f.code === debouncedFilter)?.name[lang]
13+
: t('chooseFaculty'),
14+
)
15+
}, [debouncedFilter, lang, faculties, t])
1616

1717
const handleDropdownFilter = faculty => {
1818
if (!faculty) {
@@ -39,7 +39,7 @@ const FacultyDropdown = ({ t, handleFilterChange, faculties, lang, debouncedFilt
3939
{t('report:all')}
4040
</Dropdown.Item>
4141
{!faculties.pending
42-
? faculties.data
42+
? [...faculties.data]
4343
.sort((a, b) => a.name[lang].localeCompare(b.name[lang]))
4444
.map(faculty => (
4545
<Dropdown.Item
@@ -57,4 +57,4 @@ const FacultyDropdown = ({ t, handleFilterChange, faculties, lang, debouncedFilt
5757
)
5858
}
5959

60-
export default FacultyDropdown
60+
export default FacultyDropdown

client/components/Router.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import ReformAnswers from './ReformAnswers/index'
3030
import ErrorBoundary from './ErrorBoundary'
3131
import Homepage from './Homepage'
3232
import FacultyTrackingView from './FacultyMonitoringView/FacultyTrackingView/index'
33+
import Page from './V1'
3334

3435
export default () => (
3536
<div className="content">
@@ -102,6 +103,7 @@ export default () => (
102103
render={props => <ViewEvaluationAnswersForFaculty programmeKey={props.match.params.faculty} />}
103104
/>
104105
<Route exact path="/reform-answers" component={ReformAnswers} />
106+
<Route exact path="/v1" component={Page} />
105107
</Switch>
106108
</ErrorBoundary>
107109
</div>

client/components/V1/index.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react'
2+
3+
const Page = () => {
4+
return (
5+
<div>
6+
<h1>Page</h1>
7+
</div>
8+
)
9+
}
10+
11+
export default Page

client/util/store.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
/* eslint-disable import/no-cycle */
2-
import { createStore, applyMiddleware, compose } from 'redux'
3-
import thunk from 'redux-thunk'
4-
5-
import { handleRequest } from './apiConnection'
6-
import webSocketMiddleware from './webSocket'
7-
import combinedReducers from './redux'
8-
9-
// eslint-disable-next-line
10-
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
11-
12-
const store = createStore(
13-
combinedReducers,
14-
composeEnhancers(applyMiddleware(thunk, webSocketMiddleware, handleRequest)),
15-
)
16-
17-
export default store
1+
import { configureStore } from '@reduxjs/toolkit';
2+
import { handleRequest } from './apiConnection';
3+
import webSocketMiddleware from './webSocket';
4+
import combinedReducers from './redux';
5+
6+
const store = configureStore({
7+
reducer: combinedReducers,
8+
middleware: getDefaultMiddleware =>
9+
getDefaultMiddleware().concat(webSocketMiddleware, handleRequest),
10+
devTools: process.env.NODE_ENV !== 'production',
11+
})
12+
13+
export default store

package-lock.json

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"author": "Jami Kousa, Tuomas Huhtala, Venla Rantanen",
2222
"license": "ISC",
2323
"dependencies": {
24+
"@reduxjs/toolkit": "^2.5.0",
2425
"@sentry/browser": "^7.102.1",
2526
"@sentry/node": "^7.102.1",
2627
"@sentry/tracing": "^7.102.1",

0 commit comments

Comments
 (0)