fix: :ambulance: Fix waiting list passenger deletion #213
Tim Izzo tim@octree.ch
Tue, 16 Nov 2021 17:28:43 +0100
4 files changed,
19 insertions(+),
9 deletions(-)
M
backend/.gitignore
→
backend/.gitignore
@@ -113,4 +113,5 @@ exports
.cache build .env -.env.bckp+.env.bckp +.strapi-updater.json
D
backend/.strapi-updater.json
@@ -1,5 +0,0 @@
-{ - "latest": "3.6.8", - "lastUpdateCheck": 1636016463733, - "lastNotification": 1635762618236 -}
M
frontend/containers/WaitingList/index.tsx
→
frontend/containers/WaitingList/index.tsx
@@ -15,6 +15,7 @@ import useEventStore from '../../stores/useEventStore';
import { useUpdateEventMutation, useUpdateCarMutation, + ComponentPassengerPassenger, } from '../../generated/graphql'; const WaitingList = () => {@@ -58,12 +59,13 @@ [event]
); const removePassenger = useCallback( - async passengerIndex => { + async (removingPassenger: ComponentPassengerPassenger) => { try { const waitingList = event.waitingList - .filter((_, idx) => idx !== passengerIndex) + .filter(passenger => passenger.id !== removingPassenger?.id) .map(({__typename, ...item}) => item); await updateEvent({ + refetchQueries: ['eventByUUID'], variables: {uuid: event.uuid, eventUpdate: {waitingList}}, }); addToEvent(event.id);
M
frontend/lib/apolloClient.ts
→
frontend/lib/apolloClient.ts
@@ -54,7 +54,19 @@ const createApolloClient = () => {
return new ApolloClient({ ssrMode: typeof window === 'undefined', link: from([authLink, errorLink, httpLink(`${STRAPI_URL}/graphql`)]), - cache: new InMemoryCache(), + cache: new InMemoryCache({ + typePolicies: { + Event: { + fields: { + waitingList: { + merge(existing, incoming) { + return incoming; + }, + }, + }, + }, + }, + }), }); };