-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip adding remote url and update info
- Loading branch information
Showing
11 changed files
with
118 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { useState } from "react"; | ||
import axios from "axios"; | ||
import { log } from "../lib/utils"; | ||
import Papa from "papaparse"; | ||
|
||
const PLACEHOLDER_URL = ""; | ||
|
||
function LoadSource({ | ||
setData, | ||
currentValue, | ||
}: { | ||
setData: Function; | ||
currentValue: string | null; | ||
}) { | ||
const [loading, setLoading] = useState(false); | ||
const [url, setUrl] = useState(currentValue || PLACEHOLDER_URL); | ||
|
||
async function getData() { | ||
setLoading(true); | ||
try { | ||
let testUrl = new URL(url); | ||
if (testUrl) { | ||
axios.defaults.timeout = 5000; | ||
const response = await axios.get(url); | ||
console.log("response.data", response.data); | ||
if (response.data) { | ||
setData({ remoteUrl: url, data: response.data }); | ||
} | ||
} | ||
} catch (error) { | ||
log(error); | ||
} finally { | ||
setLoading(false); | ||
} | ||
} | ||
|
||
return ( | ||
<div | ||
style={{ | ||
marginTop: 10, | ||
marginBottom: 10, | ||
width: "100%", | ||
}} | ||
> | ||
{loading && <p>Loading...</p>} | ||
<div className="bg-base-200 p-4 my-5"> | ||
<label className="label">Url</label> | ||
<input | ||
className="input w-full" | ||
type="text" | ||
value={url} | ||
onChange={(e) => setUrl(e.target.value)} | ||
/> | ||
</div> | ||
<button className="btn btn-primary" onClick={() => getData()}> | ||
USE REMOTE DATA | ||
</button> | ||
</div> | ||
); | ||
} | ||
|
||
export default LoadSource; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.