Skip to content

Commit

Permalink
Feature/update deps (#145)
Browse files Browse the repository at this point in the history
* update deps

* update deps

* update deps

* sunsetting

* sunsetting

* sunsetting
  • Loading branch information
rayyildiz committed Jun 22, 2023
1 parent 9e664f1 commit 6e87e2c
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 85 deletions.
14 changes: 0 additions & 14 deletions cmd/cleangcp/main.go

This file was deleted.

151 changes: 80 additions & 71 deletions web/app/src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,95 +1,104 @@
import {FormEvent, useState} from "react";
import './HomePage.css';
import {gql, useMutation} from "@apollo/client";
import {Navigate} from "react-router-dom";
import {Link, Navigate} from "react-router-dom";
import {Helmet} from "react-helmet";
import {WEB_BASE_URL} from "../Constants";
import {Capture, CaptureVariables} from "./__generated__/Capture";


const CAPTURE_TWEET = gql`
mutation Capture($url:String!) {
capture(url:$url) {
id
fullText
favoriteCount
retweetCount
postedAt
author {
userName
screenName
profileImageURL
}
mutation Capture($url:String!) {
capture(url:$url) {
id
fullText
favoriteCount
retweetCount
postedAt
author {
userName
screenName
profileImageURL
}
}
}
}
`;


const HomePage = () => {
const [url, setUrl] = useState('');
const [validation, setValidation] = useState('');
const [url, setUrl] = useState('');
const [validation, setValidation] = useState('');

const [doQuery, {data, loading, error}] = useMutation<Capture, CaptureVariables>(CAPTURE_TWEET)

const [doQuery, {data, loading, error}] = useMutation<Capture, CaptureVariables>(CAPTURE_TWEET)
const handleSummit = async (e: FormEvent) => {
e.preventDefault();
setValidation('');
if (url.length <= 5 || !url.startsWith("http")) {
setValidation("Please enter a valid URL. Example: https://twitter.com/jack/status/20");
} else {
try {
await doQuery({
variables: {url: url}
});
} catch (ex: unknown) {
if (ex instanceof Error) {
console.log(ex.toString());
}

const handleSummit = async (e: FormEvent) => {
e.preventDefault();
setValidation('');
if (url.length <= 5 || !url.startsWith("http")) {
setValidation("Please enter a valid URL. Example: https://twitter.com/jack/status/20");
} else {
try {
await doQuery({
variables: {url: url}
});
} catch (ex:unknown) {
if ( ex instanceof Error) {
console.log(ex.toString());
}
}

}
}
}

if (data && data.capture && data.capture.id.length > 0) {
return <Navigate replace to={`/tweet/${data.capture.id}`}/>
}
if (data && data.capture && data.capture.id.length > 0) {
return <Navigate replace to={`/tweet/${data.capture.id}`}/>
}

return (
<>
<Helmet>
<meta property="og:title" content="Capture Tweet"/>
<meta property="og:url" content={WEB_BASE_URL}/>
<meta property="og:image" content={`${WEB_BASE_URL}/logo192.png`}/>
<title>Capture Tweet | Home</title>
</Helmet>
<div className="wrapper">
<div id="formContent">
<h3>Enter a twitter URL and click <code>CAPTURE</code> button</h3>
{error && <div className="alert alert-warning mt-1 alert-box mx-auto">
<p className="mb-0">{error.message}</p>
</div>
}
{validation.length > 0 && <div className="alert alert-warning mt-1 alert-box mx-auto alert-dismissible" role="alert">
<p className="mb-0">{validation}</p>
<button type="button" className="btn-close" data-dismiss="alert" aria-label="Close" onClick={() => setValidation('')}> </button>
return (
<>
<Helmet>
<meta property="og:title" content="Capture Tweet"/>
<meta property="og:url" content={WEB_BASE_URL}/>
<meta property="og:image" content={`${WEB_BASE_URL}/logo192.png`}/>
<title>Capture Tweet | Home</title>
</Helmet>
<div className="wrapper">
<div id="formContent">

<h3></h3>
<h5><b>Sunsetting:</b> capturetweet is currently readonly.<br/>
capturetweet.com will be shut down on 31.12.2023. if you need anything please <Link to={"/contact"}>contact us</Link>.
</h5>
<h3>Enter a twitter URL and click <code>CAPTURE</code> button</h3>
{error && <div className="alert alert-warning mt-1 alert-box mx-auto">
<p className="mb-0">{error.message}</p>
</div>
}
{validation.length > 0 &&
<div className="alert alert-warning mt-1 alert-box mx-auto alert-dismissible" role="alert">
<p className="mb-0">{validation}</p>
<button type="button" className="btn-close" disabled={true} data-dismiss="alert"
aria-label="Close" onClick={() => setValidation('')}></button>
</div>
}
<form onSubmit={handleSummit} className="mt-2">
<label htmlFor="url" hidden={true}>Enter tweet url</label>
<br/>
<input readOnly={true} autoFocus autoComplete="off" type="text" id="url" name="url"
placeholder="capturetweet.com will be shut down on 2023.12.31" onChange={event => setUrl(event.target.value)}/>
{loading ?
<button className="form-button" type="submit" disabled>
<span className="spinner-border spinner-border-sm mr-2" role="status"
aria-hidden="true"> </span>
Capturing tweet...
</button> :
<button className="form-button" type="submit" onClick={handleSummit} disabled={true}>CAPTURE</button>
}
</form>
</div>
</div>
}
<form onSubmit={handleSummit} className="mt-2">
<label htmlFor="url" hidden={true}>Enter tweet url</label>
<br/>
<input autoFocus autoComplete="off" type="text" id="url" name="url" placeholder="Enter Twitter URL" onChange={event => setUrl(event.target.value)}/>
{loading ?
<button className="form-button" type="submit" disabled>
<span className="spinner-border spinner-border-sm mr-2" role="status" aria-hidden="true"> </span>
Capturing tweet...
</button> :
<button className="form-button" type="submit" onClick={handleSummit}>CAPTURE</button>
}
</form>
</div>
</div>
</>
)
</>
)
};


Expand Down

0 comments on commit 6e87e2c

Please sign in to comment.