-
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.
- Loading branch information
1 parent
a0fb60d
commit 685834c
Showing
6 changed files
with
182 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ dist-ssr | |
*.njsproj | ||
*.sln | ||
*.sw? | ||
.env |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
import Input from "./components/Input" | ||
import Navbar from "./components/Navbar" | ||
import { useState } from "react"; | ||
import Calculator from "./api/Calculator"; | ||
import Input from "./components/Input"; | ||
import Navbar from "./components/Navbar"; | ||
|
||
function App() { | ||
const [id, setid] = useState<string>(""); | ||
|
||
const handleID = (id: string) => { | ||
if (id === "") { | ||
throw new Error("Invalid URL"); | ||
} | ||
setid(id); | ||
}; | ||
|
||
return ( | ||
<div className="bg-zinc-900 text-zinc-200 h-screen font-mono"> | ||
<Navbar /> | ||
<Input /> | ||
<Input sendID={handleID} /> | ||
<Calculator pID={id} /> | ||
</div> | ||
) | ||
); | ||
} | ||
|
||
export default App | ||
export default App; |
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 |
---|---|---|
@@ -1,9 +1,44 @@ | ||
function Calculator() { | ||
import React, { useEffect } from 'react'; | ||
import axios from 'axios'; | ||
|
||
type CalculatorProps = { | ||
pID: string; | ||
}; | ||
|
||
const Calculator: React.FC<CalculatorProps> = ({ pID }) => { | ||
useEffect(() => { | ||
const getVideoIDs = async () => { | ||
try { | ||
const response = await axios.get(`https://www.googleapis.com/youtube/v3/playlistItems`, { | ||
params: { | ||
part: 'snippet', | ||
playlistId: pID, | ||
key: import.meta.env.VITE_API_KEY | ||
}, | ||
headers: { | ||
'x-api-key': import.meta.env.VITE_API_KEY | ||
} | ||
}); | ||
|
||
console.log('Playlist Items:', response.data.items); | ||
} catch (error) { | ||
console.error('Error fetching playlist items:', error); | ||
} | ||
}; | ||
|
||
if (pID) { | ||
getVideoIDs(); | ||
} | ||
}, [pID]); | ||
|
||
console.log('Playlist ID:', pID); | ||
|
||
return ( | ||
<div> | ||
|
||
<p>Playlist ID: {pID}</p> | ||
<p>Video ID: {pID}</p> | ||
</div> | ||
) | ||
} | ||
); | ||
}; | ||
|
||
export default Calculator | ||
export default Calculator; |
This file was deleted.
Oops, something went wrong.