From b068a0b42d67e7b6fc072c857fe8c219c796c625 Mon Sep 17 00:00:00 2001 From: Zach Ghera Date: Wed, 22 Jul 2020 13:47:38 -0400 Subject: [PATCH 01/11] Remove state, func, and all associated references. --- .../components/ViewTrips/delete-trip-button.js | 8 +------- frontend/src/components/ViewTrips/index.js | 18 ------------------ .../components/ViewTrips/save-trip-modal.js | 4 ---- frontend/src/components/ViewTrips/trip.js | 7 +------ 4 files changed, 2 insertions(+), 35 deletions(-) diff --git a/frontend/src/components/ViewTrips/delete-trip-button.js b/frontend/src/components/ViewTrips/delete-trip-button.js index 7b54297b..3561df75 100644 --- a/frontend/src/components/ViewTrips/delete-trip-button.js +++ b/frontend/src/components/ViewTrips/delete-trip-button.js @@ -14,8 +14,6 @@ const LIMIT_QUERY_DOCS_RETRIEVED = 5; * * @param {Object} props These are the props for this component: * - tripId: Document ID for the current Trip document. - * - refreshTripsContainer: Handler that refreshes the TripsContainer - * component upon trip creation (Remove when fix Issue #62). */ const DeleteTripsButton = (props) => { /** @@ -78,8 +76,6 @@ const DeleteTripsButton = (props) => { /** * Deletes a trip and its subcollection of activities corrsponding to the * `tripId` prop and then refreshes the TripsContainer component. - * - * TODO(Issue #62): Remove refreshTripsContainer. */ async function deleteTrip() { if (window.confirm('Are you sure you want to delete this trip? This' + @@ -101,9 +97,7 @@ const DeleteTripsButton = (props) => { }).catch(error => { console.error("Error removing document: ", error); }); - - props.refreshTripsContainer(); - } + } } return ( diff --git a/frontend/src/components/ViewTrips/index.js b/frontend/src/components/ViewTrips/index.js index 08ce2971..19a1c731 100644 --- a/frontend/src/components/ViewTrips/index.js +++ b/frontend/src/components/ViewTrips/index.js @@ -16,27 +16,12 @@ class ViewTrips extends React.Component { constructor() { super(); this.state = { showModal: false, - refreshTripsContainer: false, refreshSaveTripModal: false, tripId: null, defaultFormObj: null, }; } - /** - * Handler that flips `refreshTripsContainer` property which causes that - * TripsContainer component to be reloaded. - * - * This allows a trip creator's view trips page to be updated in real time. - * - * In the future, the use of refreshTripContainer and the key prop on Trips - * container should be removed with the addition of real time listening with - * onShapshot (Issue #62). - */ - refreshTripsContainer = () => { - this.setState({ refreshTripsContainer: !this.state.refreshTripsContainer }); - } - /** * Handler that flips `refreshSaveTripModal` property which causes that * save/edit trip component to be reloaded. @@ -97,7 +82,6 @@ class ViewTrips extends React.Component { ); diff --git a/frontend/src/components/ViewTrips/save-trip-modal.js b/frontend/src/components/ViewTrips/save-trip-modal.js index 00a2a352..f1e892a3 100644 --- a/frontend/src/components/ViewTrips/save-trip-modal.js +++ b/frontend/src/components/ViewTrips/save-trip-modal.js @@ -162,8 +162,6 @@ function createFormGroup(controlId, formLabel, inputType, * @param {Object} props These are the props for this component: * - show: Boolean that determines if the add trips modal should be displayed. * - handleClose: Event handler responsible for closing the add trips modal. - * - refreshTripsContainer: Handler that refreshes the TripsContainer - * component upon trip creation (Remove when fix Issue #62). * - tripId: For adding a new trip, this will be null. For editting an existing * trip, this will the document id associated with the trip. * - defaultFormObj: Object containing the placeholder/default values for the @@ -272,12 +270,10 @@ class SaveTripModal extends React.Component { /** * Handles submission of the form which includes: * - Creation of the trip. - * - Refreshing the trips container. * - Closing the modal. */ handleSubmitForm = () => { this.saveTrip(); - this.props.refreshTripsContainer(); this.props.handleClose(); } diff --git a/frontend/src/components/ViewTrips/trip.js b/frontend/src/components/ViewTrips/trip.js index 0bbbcd5c..22e6a0fa 100644 --- a/frontend/src/components/ViewTrips/trip.js +++ b/frontend/src/components/ViewTrips/trip.js @@ -52,8 +52,6 @@ export function getCollaboratorEmails(collaboratorUidArr) { * - tripData: Object holding a Trip document fields and corresponding values. * - tripId: Document ID for the current Trip document. * - handleEditTrip: Handler that displays the edit trip modal. - * - refreshTripsContainer: Handler that refreshes the TripsContainer - * component upon trip creation (Remove when fix Issue #62). * - key: Special React attribute that ensures a new Trip instance is * created whenever this key is updated */ @@ -81,10 +79,7 @@ const Trip = (props) => {

{description}

{collaboratorEmailsStr}

- +