about summary refs log tree commit diff
path: root/client/src/Components/Response.js
diff options
context:
space:
mode:
authorMelonai <einebeere@gmail.com>2021-01-20 23:18:09 +0100
committerMelonai <einebeere@gmail.com>2021-01-20 23:18:09 +0100
commit826c7c47785ee01d2b9267919132ada696425344 (patch)
tree901cc90be9a953a6c3f968b6c1abe33cc13774b4 /client/src/Components/Response.js
parent2953dec527cedaabaa5f0eb48637c5ddd4a4103b (diff)
downloadshorest-826c7c47785ee01d2b9267919132ada696425344.tar.zst
shorest-826c7c47785ee01d2b9267919132ada696425344.zip
Remade the client in SvelteKit
Diffstat (limited to 'client/src/Components/Response.js')
-rw-r--r--client/src/Components/Response.js55
1 files changed, 0 insertions, 55 deletions
diff --git a/client/src/Components/Response.js b/client/src/Components/Response.js
deleted file mode 100644
index f69000a..0000000
--- a/client/src/Components/Response.js
+++ /dev/null
@@ -1,55 +0,0 @@
-import React, {useEffect, useState} from 'react';
-import axios from "axios";
-import Loader from "./Loader";
-import CopyButton from "./CopyButton";
-import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { faBomb } from '@fortawesome/free-solid-svg-icons';
-
-function Response(props){
-    const CancelToken = axios.CancelToken;
-    const [requestState, setRequestState] = useState({loading: true, cancel: CancelToken.source()});
-
-    useEffect(() => {
-        axios.post('/', {url: "https://" + props.url}, {cancelToken: requestState.cancel.token})
-            .then((r) => {
-                setRequestState({loading: false, hash: r.data.hash, cancel: requestState.cancel});
-            }).catch((e) => {
-                if (!axios.isCancel(e)) {
-                    setRequestState({loading: false, error: true, cancel: requestState.cancel});
-                }
-            });
-
-        return () => {
-            requestState.cancel.cancel();
-        };
-    }, [props.url, requestState.cancel])
-
-    let text;
-    let rightItem;
-    if (!requestState.loading) {
-        if (!requestState.error) {
-            rightItem = <CopyButton hash={requestState.hash}/>;
-            if (props.url.length < 20) {
-                text =
-                    <span>The short link for <strong>{props.url}</strong> is<br/><strong>sho.rest/{requestState.hash}</strong></span>;
-            } else {
-                text =
-                    <span>The short link for your URL is<br/><strong>sho.rest/{requestState.hash}</strong></span>;
-            }
-        } else {
-            rightItem = <FontAwesomeIcon className="right-item" icon={faBomb}/>;
-            text = <span>There was an error.</span>
-        }
-    } else {
-        text = <Loader/>
-    }
-
-    return (
-        <div className={"response-container" + (requestState.error ? " disabled" : "")}>
-            <div className={"title response-text" + (requestState.error ? " disabled" : "")}>{text}</div>
-            {rightItem}
-        </div>
-    )
-}
-
-export default Response;
\ No newline at end of file