-
Notifications
You must be signed in to change notification settings - Fork 59
biography fetaure #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
biography fetaure #140
Changes from all commits
ec95144
a24024f
45f528f
68d93ea
4df2370
0455c76
eb197e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| "prepare": "husky" | ||
| }, | ||
| "dependencies": { | ||
| "@google/generative-ai": "^0.24.1", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major ❓ Verification inconclusiveVerify that the dependency is used in the codebase. The Run the following script to verify if this dependency is actually used: If the dependency is unused, consider removing it to avoid bloating the bundle. If it's for future use, it should be added in a separate PR when actually needed. 🏁 Script executed: #!/bin/bash
# Search for imports of @google/generative-ai in the codebase
rg -n --type=ts --type=js --type=jsx -C3 '@google/generative-ai|google/generative-ai'Length of output: 27 🏁 Script executed: #!/bin/bash
# Search for any import or require of @google/generative-ai in JS/TS files
rg -n '@google/generative-ai' -C3 --glob '*.{js,jsx,ts,tsx}'Length of output: 0 Remove unused dependency 🤖 Prompt for AI Agents |
||
| "@radix-ui/react-accordion": "^1.2.2", | ||
| "@radix-ui/react-dialog": "^1.1.4", | ||
| "@radix-ui/react-icons": "^1.3.2", | ||
|
|
@@ -50,6 +51,8 @@ | |
| "@types/node": "^22.10.2", | ||
| "@types/react": "^19.0.2", | ||
| "@types/react-dom": "^19.0.2", | ||
| "@typescript-eslint/eslint-plugin": "^8.46.1", | ||
| "@typescript-eslint/parser": "^8.46.1", | ||
| "@vitejs/plugin-react": "^4.3.4", | ||
| "autoprefixer": "^10.4.20", | ||
| "eslint": "^9.17.0", | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,16 +9,12 @@ Api.interceptors.response.use( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (response) => response, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (error) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (error.response) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // The request was made and the server responded with a status code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // that falls out of the range of 2xx | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toast.error(`Error: ${error.response.status} - ${error.response.statusText}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error("API Error:", error.response.data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (error.request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // The request was made but no response was received | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toast.error("Error: No response from server. Please check your internet connection."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error("API Error: No response received", error.request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Something happened in setting up the request that triggered an Error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toast.error("Error: Something went wrong with the request."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error("API Error:", error.message); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -42,6 +38,7 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setDoc, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from "firebase/firestore"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { app, db } from "./Auth/firebase"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const fetchFireStore = (setPlaylist, setLikedSongs) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let auth = getAuth(app); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onAuthStateChanged(auth, async (user) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -229,3 +226,19 @@ export async function fetchSongsByIds(songIds) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { success: false, data: [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export async function fetchArtistBio(artistName) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const apiKey = import.meta.env.VITE_THEAUDIODB_API_KEY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const url = `https://www.theaudiodb.com/api/v1/json/${apiKey}/search.php?s=${artistName}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const response = await axios.get(url); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (response.data && response.data.artists) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return response.data.artists[0].strBiographyEN; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error("Error fetching artist biography:", error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+230
to
+244
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add URL encoding and array safety checks. The function has several issues that could cause runtime errors:
Apply this diff to fix these issues: export async function fetchArtistBio(artistName) {
try {
const apiKey = import.meta.env.VITE_THEAUDIODB_API_KEY;
+ if (!apiKey) {
+ console.error("VITE_THEAUDIODB_API_KEY is not configured");
+ return null;
+ }
- const url = `https://www.theaudiodb.com/api/v1/json/${apiKey}/search.php?s=${artistName}`;
+ const encodedArtist = encodeURIComponent(artistName);
+ const url = `https://www.theaudiodb.com/api/v1/json/${apiKey}/search.php?s=${encodedArtist}`;
const response = await axios.get(url);
- if (response.data && response.data.artists) {
+ if (response.data?.artists && response.data.artists.length > 0) {
return response.data.artists[0].strBiographyEN;
}
return null;
} catch (error) {
console.error("Error fetching artist biography:", error);
return null;
}
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import PropTypes from "prop-types"; | ||
| import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; | ||
|
|
||
| const ArtistBio = ({ artistData, bioText }) => { | ||
| // Use the fetched bioText. If it's not available, fall back to the placeholder. | ||
| const bio = | ||
| bioText || | ||
| `A celebrated artist known for a unique blend of genres, ${artistData?.name} has captivated audiences worldwide with their soulful melodies and profound lyrics. Rising from humble beginnings, their passion for music has led them on a journey of sonic exploration, resulting in a discography that is both timeless and innovative.`; | ||
|
|
||
| return ( | ||
| <div className="mt-8"> | ||
| <Card> | ||
| <CardHeader> | ||
| <CardTitle>About {artistData?.name}</CardTitle> | ||
| </CardHeader> | ||
| <CardContent> | ||
| {/* The 'whitespace-pre-wrap' class helps preserve formatting like newlines from the API */} | ||
| <p className="text-muted-foreground whitespace-pre-wrap">{bio}</p> | ||
| </CardContent> | ||
| </Card> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| // Add prop validation to satisfy the linter | ||
| ArtistBio.propTypes = { | ||
| artistData: PropTypes.shape({ | ||
| name: PropTypes.string, | ||
| bio: PropTypes.oneOfType([ | ||
| PropTypes.string, | ||
| PropTypes.shape({ | ||
| text: PropTypes.string, | ||
| }), | ||
| ]), | ||
| }), | ||
| bioText: PropTypes.string, | ||
| }; | ||
|
|
||
| export default ArtistBio; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Reorder env keys to satisfy dotenv-linter
dotenv-linterflags Line 6 becauseVITE_FIREBASE_APP_IDis expected beforeVITE_FIREBASE_AUTH_DOMAIN. Please reorder the entries to clear the warning.Based on static analysis hints
📝 Committable suggestion
🧰 Tools
🪛 dotenv-linter (3.3.0)
[warning] 6-6: [UnorderedKey] The VITE_FIREBASE_APP_ID key should go before the VITE_FIREBASE_AUTH_DOMAIN key
(UnorderedKey)
🤖 Prompt for AI Agents