@@ -4,7 +4,12 @@ import { useParams } from "react-router-dom";
44import { addNote , archiveNote } from "src/apiClient/people" ;
55import { Notes } from "src/components/Notes" ;
66import { useSetPageTitle } from "src/hooks" ;
7- import { useGetPersonQuery , useGetRenterApprovalsQuery } from "src/redux/api" ;
7+ import {
8+ TagType ,
9+ useGetPersonQuery ,
10+ useGetRenterApprovalsQuery ,
11+ } from "src/redux/api" ;
12+ import { invalidateCache } from "src/redux/store" ;
813
914import { BuyGear } from "./BuyGear" ;
1015import { CheckoutStaging } from "./CheckoutStaging" ;
@@ -22,7 +27,7 @@ import { ReturnStaging } from "./ReturnStaging";
2227
2328export function PersonPage ( ) {
2429 const personId = useParams < { personId : string } > ( ) . personId ! ;
25- const { data : person , refetch : refreshPerson } = useGetPersonQuery ( personId ) ;
30+ const { data : person } = useGetPersonQuery ( personId ) ;
2631 const { data : approvalResult } = useGetRenterApprovalsQuery ( {
2732 personID : personId ,
2833 past : false ,
@@ -33,7 +38,6 @@ export function PersonPage() {
3338 return (
3439 < PersonPageContextProvider
3540 person = { person }
36- refreshPerson = { refreshPerson }
3741 // NOTE: This doesn't handle pagination for now, which could be a problem if someone has 50+ active approvals. Unlikely.
3842 approvals = { approvalResult ?. results ?? [ ] }
3943 >
@@ -45,14 +49,8 @@ export function PersonPage() {
4549function PersonPageInner ( ) {
4650 const [ tab , setTab ] = useTab ( ) ;
4751
48- const {
49- person,
50- refreshPerson,
51- checkoutBasket,
52- returnBasket,
53- purchaseBasket,
54- isApproved,
55- } = usePersonPageContext ( ) ;
52+ const { person, checkoutBasket, returnBasket, purchaseBasket, isApproved } =
53+ usePersonPageContext ( ) ;
5654
5755 useSetPageTitle ( person ? `${ person . firstName } ${ person . lastName } ` : "" ) ;
5856
@@ -75,10 +73,14 @@ function PersonPageInner() {
7573 < Notes
7674 notes = { person . notes }
7775 onAdd = { ( note ) => {
78- return addNote ( person . id , note ) . then ( refreshPerson ) ;
76+ return addNote ( person . id , note ) . then ( ( ) =>
77+ invalidateCache ( [ TagType . People ] ) ,
78+ ) ;
7979 } }
8080 onArchive = { ( noteId ) => {
81- archiveNote ( person . id , noteId ) . then ( refreshPerson ) ;
81+ archiveNote ( person . id , noteId ) . then ( ( ) =>
82+ invalidateCache ( [ TagType . People ] ) ,
83+ ) ;
8284 } }
8385 />
8486 { ! isEmpty ( checkoutBasket . items ) && (
0 commit comments