#!/bin/sh

# This file is part of the element-web-patches.
#
# element-web-patches is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# element-web-patches is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with element-web-patches. If not, see <https://www.gnu.org/licenses/>.

echo "Deleting login footer..."

error() {
    echo "Failed to patch, exiting..."
    exit 1
}

patch_content=$(cat << EOF
--- a/components.json
+++ b/components.json
@@ -1,5 +1,4 @@
 {
-    "src/components/views/auth/AuthFooter.tsx": "src/components/views/auth/VectorAuthFooter.tsx",
     "src/components/views/auth/AuthHeaderLogo.tsx": "src/components/views/auth/VectorAuthHeaderLogo.tsx",
     "src/components/views/auth/AuthPage.tsx": "src/components/views/auth/VectorAuthPage.tsx"
 }
--- a/src/components/views/auth/VectorAuthPage.tsx
+++ b/src/components/views/auth/VectorAuthPage.tsx
@@ -8,7 +8,6 @@ Please see LICENSE files in the repository root for full details.
 import * as React from "react";

 import SdkConfig from "../../../SdkConfig";
-import VectorAuthFooter from "./VectorAuthFooter";

 export default class VectorAuthPage extends React.PureComponent<React.PropsWithChildren> {
     private static welcomeBackgroundUrl?: string;
@@ -68,7 +67,6 @@ export default class VectorAuthPage extends React.PureComponent<React.PropsWithC
                         {this.props.children}
                     </div>
                 </div>
-                <VectorAuthFooter />
             </div>
         );
     }
EOF
)

(cd "${1}" && echo "${patch_content}" | patch -p1) || error
rm -f "${1}"/src/components/views/auth/VectorAuthFooter.tsx \
      "${1}"/test/unit-tests/components/views/auth/VectorAuthFooter-test.tsx \
      "${1}"/test/unit-tests/components/views/auth/__snapshots__/VectorAuthFooter-test.tsx.snap