all repos — caroster @ 0106eb023ccf03f53408d4a3a523b5430f51d898

[Octree] Group carpool to your event https://caroster.io

fix: :ambulance: Fix waiting list passenger deletion

#213
Tim Izzo tim@octree.ch
Tue, 16 Nov 2021 17:28:43 +0100
commit

0106eb023ccf03f53408d4a3a523b5430f51d898

parent

f27c94bbe69c23f12e6cfb1f28f9c1bc2ef9514c

4 files changed, 19 insertions(+), 9 deletions(-)

jump to
M backend/.gitignorebackend/.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.tsxfrontend/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.tsfrontend/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; + }, + }, + }, + }, + }, + }), }); };