Skip to content

Commit

Permalink
albums done
Browse files Browse the repository at this point in the history
  • Loading branch information
SalveSayali-23 committed Jan 30, 2024
1 parent 3a7d475 commit 96ba1ab
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
14 changes: 13 additions & 1 deletion qtify/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import React, { useEffect, useState } from "react";
import Navbar from "./components/Navbar/Navbar";
import HeroSection from "./components/HeroSection/HeroSection";
import { fetchTopAlbumsData } from "./components/api/api";
import { fetchTopAlbumsData , fetchNewAlbumsData} from "./components/api/api";
import Section from "./components/Section/Section";
import styles from "./App.module.css"

const App = () => {
const [albumsData, setAlbumsData] = useState([]);
const [newAlbumsData, setNewAlbumsData] = useState([]);

const generateTopAlbums = async () => {
try {
Expand All @@ -19,8 +20,18 @@ const App = () => {
}
};

const generateNewAlbums = async () => {
try {
const data = await fetchNewAlbumsData();
setNewAlbumsData(data);
} catch (e) {
console.log(e);
}
};

useEffect(() => {
generateTopAlbums();
generateNewAlbums()
}, []);

return (
Expand All @@ -35,6 +46,7 @@ const App = () => {
{/* instead of mappibg card data for every section, lets create a section component and render it directly here */}
<div className={styles.sectionWrapper}>
<Section data={albumsData} title="Top Albums" type="album" />
<Section data={newAlbumsData} title="New Albums" type="album" />
</div>
</div>
);
Expand Down
24 changes: 12 additions & 12 deletions qtify/src/components/Carousel/CarouselLeftNavigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import React, { useEffect, useState } from "react";
import { useSwiper } from "swiper/react";
import LeftArrow from "../../assets/leftarrow.svg";
import styles from "./Carousel.module.css"

import styles from "./Carousel.module.css";

const CarouselLeftNavigation = () => {
const swiper = useSwiper();
Expand All @@ -13,19 +12,20 @@ const CarouselLeftNavigation = () => {
setIsBeginning(swiper.isBeginning);
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}, [isBeginning]);

return (
<div >
{!isBeginning ?(
<button className={styles.leftNavigation}
onClick={() => {
swiper.slidePrev();
}}><img src={LeftArrow}

/></button>

): null}
{!isBeginning ? (
<button className={styles.leftNavigation}

onClick={() => {
swiper.slidePrev();
}}
>
<img src={LeftArrow} />
</button>
) : null}
</div>
);
};
Expand Down
10 changes: 10 additions & 0 deletions qtify/src/components/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,14 @@ export const fetchTopAlbumsData=async ()=>{
}catch(e){
console.log(e)
}
}

export const fetchNewAlbumsData=async ()=>{
try{
const response=await axios.get(`${BackendEndpoint}/albums/new`);
console.log(response);
return response.data;
}catch(e){
console.log(e)
}
}

0 comments on commit 96ba1ab

Please sign in to comment.