Skip to content

Commit

Permalink
Add Slider Function
Browse files Browse the repository at this point in the history
  • Loading branch information
Atril33 committed Oct 2, 2023
1 parent b80bff6 commit 7f14da1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import CreateAppointment from './routes/CreateAppointment';
import Layout from './components/Layout';
import NotMatch from './routes/NotMatch';
import Logout from './routes/Logout';
import Test from './routes/Test';

function App() {
return (
Expand All @@ -38,6 +39,7 @@ function App() {
<Route path="logout" element={<Logout />} />
</Route>
<Route path="*" element={<NotMatch />} />
<Route path="test" element={<Test />} />
</Routes>
</BrowserRouter>
<ToastContainer />
Expand Down
43 changes: 43 additions & 0 deletions src/routes/Test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Link } from 'react-router-dom';
import Slider from 'react-slick';
import { fetchdoctors } from '../redux/doctors/doctorSlice';
import 'slick-carousel/slick/slick.css';
import 'slick-carousel/slick/slick-theme.css';

const Test = () => {
const doctorsDispatch = useDispatch();

const allDoctors = useSelector((state) => state.doctors);
const finalDoctorsData = allDoctors.doctors;

useEffect(() => {
doctorsDispatch(fetchdoctors());
}, [doctorsDispatch]);

const settings = {
dots: true,
infinite: true,
speed: 500,
slidesToShow: 3,
slidesToScroll: 1,
};

return (
<>
<Slider {...settings}>
{finalDoctorsData.map((item) => (

<Link to={`/doctor/${item.id}`} className="flex border w-auto justify-center items-center h-[250px] flex-col bg-[blue]" key={item.id}>
<img src={item.photo_url} alt={item.name} />

</Link>

))}
</Slider>
</>
);
};

export default Test;
4 changes: 2 additions & 2 deletions src/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}

.doctor-container {
width: 100%;
width: 70%;
height: auto;
display: flex;
}
Expand Down Expand Up @@ -56,7 +56,7 @@

.doctor-box {
height: auto;
width: 300px;
width: calc(33.33% - 10px);
background: transparent;
border: 1px solid #f3eeee;
display: flex;
Expand Down

0 comments on commit 7f14da1

Please sign in to comment.