diff --git a/frontend/package.json b/frontend/package.json index f0d94189..a6932cc5 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -40,7 +40,8 @@ "eject": "react-scripts eject", "lint": "eslint . --ext .ts --ext .tsx", "lint:fix": "yarn lint --fix", - "tsc": "tsc -p tsconfig.json" + "tsc": "tsc -p tsconfig.json", + "postinstall": "patch-package" }, "proxy": "http://localhost:8080", "browserslist": { @@ -56,6 +57,7 @@ ] }, "devDependencies": { - "@types/google-map-react": "^2.1.10" + "@types/google-map-react": "^2.1.10", + "patch-package": "^8.0.1" } } diff --git a/frontend/patches/react-scripts+4.0.0.patch b/frontend/patches/react-scripts+4.0.0.patch new file mode 100644 index 00000000..63d6044c --- /dev/null +++ b/frontend/patches/react-scripts+4.0.0.patch @@ -0,0 +1,13 @@ +diff --git a/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js b/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js +index 00139ee..564d70a 100644 +--- a/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js ++++ b/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js +@@ -179,7 +179,7 @@ function verifyTypeScriptSetup() { + throw new Error(ts.formatDiagnostic(error, formatDiagnosticHost)); + } + +- appTsConfig = readTsConfig; ++ appTsConfig = JSON.parse(JSON.stringify(readTsConfig)); + + // Get TS to parse and resolve any "extends" + // Calling this function also mutates the tsconfig above, diff --git a/frontend/src/pages/AdminPage.tsx b/frontend/src/pages/AdminPage.tsx index c9287641..533a54fb 100644 --- a/frontend/src/pages/AdminPage.tsx +++ b/frontend/src/pages/AdminPage.tsx @@ -164,6 +164,8 @@ const AdminPage = (): ReactElement => { >('idle'); const [migrationSummary, setMigrationSummary] = useState(null); const [migrationProgress, setMigrationProgress] = useState(''); + const [showMigrateConfirm, setShowMigrateConfirm] = useState(false); + const [migrateConfirmText, setMigrateConfirmText] = useState(''); // Create new apartment state const [createModalOpen, setCreateModalOpen] = useState(false); @@ -530,15 +532,13 @@ const AdminPage = (): ReactElement => { } }; - const handleMigrationRun = async () => { - if ( - !window.confirm( - 'Are you sure you want to run the migration? This will modify ALL apartment records in the database.' - ) - ) { - return; - } + const handleMigrationRun = () => { + setMigrateConfirmText(''); + setShowMigrateConfirm(true); + }; + const handleMigrationRunConfirmed = async () => { + setShowMigrateConfirm(false); try { setMigrationStatus('running'); setMigrationProgress('Migrating apartments...'); @@ -1718,6 +1718,41 @@ const AdminPage = (): ReactElement => { > Run Migration + + {/* Confirm migration dialog */} + setShowMigrateConfirm(false)} + maxWidth="sm" + fullWidth + > + Confirm Schema Migration + + + This will batch-write to every apartment record in the + database. This action cannot be undone. Type{' '} + CONFIRM to proceed. + + setMigrateConfirmText(e.target.value)} + /> + + + + + + {/* Migration Progress */} diff --git a/frontend/src/pages/ApartmentPage.tsx b/frontend/src/pages/ApartmentPage.tsx index 7ab7d85f..832bbd8b 100644 --- a/frontend/src/pages/ApartmentPage.tsx +++ b/frontend/src/pages/ApartmentPage.tsx @@ -47,8 +47,6 @@ import MapModal from '../components/Apartment/MapModal'; import LandlordMessagingModal from '../components/Apartment/LandlordMessagingModal'; import ConfirmLandlordMessagingModal from '../components/Apartment/ConfirmLandlordMessagingModal'; import DropDownWithLabel from '../components/utils/DropDownWithLabel'; -import firebase from 'firebase/app'; -import 'firebase/auth'; import AddToFolderPopover from '../components/Folder/AddToFolderPopover'; type Props = {