Skip to content

Commit

Permalink
Fix create/update note after date change (#118)
Browse files Browse the repository at this point in the history
* Updated react router

* Force update note form values after rrd updates loader data

* Removed unused args from note tags
  • Loading branch information
pkirilin committed Sep 5, 2024
1 parent 295950e commit a27628b
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 39 deletions.
40 changes: 20 additions & 20 deletions src/frontend/.pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"react-dom": "^18.1.0",
"react-ga4": "^2.1.0",
"react-redux": "^8.0.2",
"react-router-dom": "^6.22.0",
"react-router-dom": "^6.26.1",
"redux": "^4.2.0",
"use-debounce": "^10.0.0",
"workbox-window": "^7.1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/entities/note/api/noteApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const noteApi = api.injectEndpoints({
endpoints: builder => ({
notes: builder.query<GetNotesResponse, GetNotesRequest>({
query: ({ date }) => `/api/v1/notes?date=${date}`,
providesTags: (_response, _error, { date }) => [{ type: 'note', id: date }],
providesTags: ['note'],
}),

notesHistory: builder.query<GetNotesHistoryResponse, GetNotesHistoryRequest>({
Expand Down
10 changes: 9 additions & 1 deletion src/frontend/src/entities/note/lib/useFormValues.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useMemo, useState } from 'react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { type FormValues } from '../model';

interface Result {
Expand All @@ -10,6 +10,14 @@ interface Result {
export const useFormValues = (initialValues: FormValues): Result => {
const [values, setValues] = useState<FormValues>(initialValues);

// Used to catch latest date updates from react-router-dom loader data
useEffect(() => {
setValues(prev => ({
...prev,
date: initialValues.date,
}));
}, [initialValues.date]);

const clearValues = useCallback(() => {
setValues(initialValues);
}, [initialValues]);
Expand Down
32 changes: 16 additions & 16 deletions src/frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2894,10 +2894,10 @@ __metadata:
languageName: node
linkType: hard

"@remix-run/router@npm:1.15.0":
version: 1.15.0
resolution: "@remix-run/router@npm:1.15.0"
checksum: 10/5cadae0c90874966ebd6b1b202284a337da32a68fc95af502859cd6158d3c254fbb4f76fa1844c837205dbc8a8120223360b9287a3d6aa0c747d02767c4c072c
"@remix-run/router@npm:1.19.1":
version: 1.19.1
resolution: "@remix-run/router@npm:1.19.1"
checksum: 10/2800c2f6567a982fe942aacc4cb5b170e7cc89bd455960e3bea2424161ff7dac32d01886322d88dd19b88d1bea711f39566d17f02b73eeb74999affb471f8f52
languageName: node
linkType: hard

Expand Down Expand Up @@ -6287,7 +6287,7 @@ __metadata:
react-dom: "npm:^18.1.0"
react-ga4: "npm:^2.1.0"
react-redux: "npm:^8.0.2"
react-router-dom: "npm:^6.22.0"
react-router-dom: "npm:^6.26.1"
redux: "npm:^4.2.0"
typescript: "npm:5.2.2"
use-debounce: "npm:^10.0.0"
Expand Down Expand Up @@ -8693,27 +8693,27 @@ __metadata:
languageName: node
linkType: hard

"react-router-dom@npm:^6.22.0":
version: 6.22.0
resolution: "react-router-dom@npm:6.22.0"
"react-router-dom@npm:^6.26.1":
version: 6.26.1
resolution: "react-router-dom@npm:6.26.1"
dependencies:
"@remix-run/router": "npm:1.15.0"
react-router: "npm:6.22.0"
"@remix-run/router": "npm:1.19.1"
react-router: "npm:6.26.1"
peerDependencies:
react: ">=16.8"
react-dom: ">=16.8"
checksum: 10/32ba0386d400354094116fa7dd98f1d23bc7cf683b0f4509694be5f730d4957fcb8cc73e35946576fc3f48b4d36743422f1b9bcdc37ad77f04bde0bde5d9102e
checksum: 10/1bd255d1ff88f477699c72656e7c07702a907e644388a1bea1c648f2df0c3c86db2e90bea945b1d43eaf84ebab194f3868f3788502965ad5f20c508c6874f1fe
languageName: node
linkType: hard

"react-router@npm:6.22.0":
version: 6.22.0
resolution: "react-router@npm:6.22.0"
"react-router@npm:6.26.1":
version: 6.26.1
resolution: "react-router@npm:6.26.1"
dependencies:
"@remix-run/router": "npm:1.15.0"
"@remix-run/router": "npm:1.19.1"
peerDependencies:
react: ">=16.8"
checksum: 10/627c25533667da0c8008587208e0d5633409173969fd579de706cde355465f6d1245e2b1a7ca2adeb96201f2858932b59ce3402482786cd20c4bf278562976dd
checksum: 10/b3761515c75da65a1678f005d08a6285ceccd9df7237ae6fdd9ab2ab816ef328435b75610f705ecd9ecd41c6878fd22eb9b44c5391cdef2e1ed99ddbc78de8a4
languageName: node
linkType: hard

Expand Down

0 comments on commit a27628b

Please sign in to comment.