aa
This commit is contained in:
@@ -44,6 +44,7 @@ export type Action =
|
||||
| { type: "SET_RATING"; placeId: number; value: number }
|
||||
| { type: "SET_NOTES"; placeId: number; value: string }
|
||||
| { type: "ADD_PLACE"; place: Place }
|
||||
| { type: "PATCH_PLACE"; placeId: number; patch: Partial<Place> }
|
||||
| { type: "DELETE_PLACE"; placeId: number }
|
||||
| { type: "TOAST"; value: string }
|
||||
| { type: "CLEAR_TOAST"; key: number }
|
||||
@@ -122,6 +123,12 @@ export function reducer(state: AppState, action: Action): AppState {
|
||||
}
|
||||
case "ADD_PLACE":
|
||||
return { ...state, places: [action.place, ...state.places] };
|
||||
case "PATCH_PLACE": {
|
||||
const places = state.places.map((p) =>
|
||||
p.id === action.placeId ? { ...p, ...action.patch } : p,
|
||||
);
|
||||
return { ...state, places };
|
||||
}
|
||||
case "DELETE_PLACE":
|
||||
return {
|
||||
...state,
|
||||
|
||||
Reference in New Issue
Block a user