From 32f1c47f44bea04e561784472910bbc3ab7d81bb Mon Sep 17 00:00:00 2001 From: Ali Josheghani Date: Fri, 24 May 2024 15:14:06 +0330 Subject: [PATCH] feat : completed turotial page with fake data --- src/pages/tutorial/index.tsx | 10 +- src/pages/tutorial/section/Tutorials.tsx | 54 +++++++++ .../tutorial/section/components/Leran.tsx | 105 ++++++++++++++++++ .../section/components/ListTutorial.tsx | 29 +++++ 4 files changed, 193 insertions(+), 5 deletions(-) create mode 100644 src/pages/tutorial/section/Tutorials.tsx create mode 100644 src/pages/tutorial/section/components/Leran.tsx create mode 100644 src/pages/tutorial/section/components/ListTutorial.tsx diff --git a/src/pages/tutorial/index.tsx b/src/pages/tutorial/index.tsx index 5329bbe..bd34f44 100644 --- a/src/pages/tutorial/index.tsx +++ b/src/pages/tutorial/index.tsx @@ -1,11 +1,11 @@ -import Alert from "../../components/alert/Alert"; +import Tutorials from "./section/Tutorials"; const Tutorial = () => { return ( -
- - به زودی صفحه اموزش اضافه می شود - +
+
+ +
); }; diff --git a/src/pages/tutorial/section/Tutorials.tsx b/src/pages/tutorial/section/Tutorials.tsx new file mode 100644 index 0000000..d4812b5 --- /dev/null +++ b/src/pages/tutorial/section/Tutorials.tsx @@ -0,0 +1,54 @@ +import { useState } from "react"; +import Learn from "./components/Leran"; +import ListTutorials from "./components/ListTutorial"; +import { TutorialList } from "../../../types/props"; + +const Tutorials = () => { + const tutorialList: TutorialList = [ + { + id: 1, + name: "آموزش اشتراکی اندروید", + }, + { + id: 2, + name: "آموزش اشتراکی آیفون", + }, + { + id: 3, + name: "آموزش cisco در اندروید", + }, + { + id: 4, + name: "آموزش cisco در آیفون", + }, + { + id: 5, + name: "آموزش سرویس مولتی", + }, + { + id: 6, + name: "آموزش cisco در ویندوز", + }, + { + id: 7, + name: "آموزش open vpn در اندروید", + }, + ]; + const [activeTutorial, setActiveTutorial] = useState(1); + return ( +
+

آموزش

+

+ برای انتخاب آموزش مورد نظر کلیک کنید تا آموزش براتون نمایش داده شود +

+ + +
+ ); +}; + +export default Tutorials; diff --git a/src/pages/tutorial/section/components/Leran.tsx b/src/pages/tutorial/section/components/Leran.tsx new file mode 100644 index 0000000..aab4059 --- /dev/null +++ b/src/pages/tutorial/section/components/Leran.tsx @@ -0,0 +1,105 @@ +import { useEffect, useState } from "react"; +import { LearnProps } from "../../../../types/props"; + +import v2ray from "../../../../assets/tutorial/android/v2ray.png"; +import eshterki1 from "../../../../assets/tutorial/ios/1-eshterki.jpg"; +import eshterki2 from "../../../../assets/tutorial/ios/2-eshteraki.jpg"; +import eshterki3 from "../../../../assets/tutorial/ios/3-eshteraki.jpg"; +import eshterki4 from "../../../../assets/tutorial/ios/4-eshteraki.jpg"; +import Button from "../../../../components/button"; + +const Learn = ({ activeTutorial, tutorialList }: LearnProps) => { + const data = [ + { + id: 1, + images: [ + { + id: 1, + url: v2ray, + alt: "v2ray", + }, + ], + btn: "دانلود برنامه", + }, + { + id: 2, + images: [ + { + id: 1, + url: eshterki1, + alt: "eshterki1", + }, + { + id: 2, + url: eshterki2, + alt: "eshteraki2", + }, + { + id: 3, + url: eshterki3, + alt: "eshterki3", + }, + { + id: 4, + url: eshterki4, + alt: "eshterki4", + }, + ], + btn: null, + }, + { + id: 3, + images: [], + btn: null, + }, + { + id: 4, + images: [], + btn: null, + }, + { id: 5, images: [], btn: null }, + { id: 6, images: [], btn: null }, + { id: 7, images: [], btn: null }, + ]; + const [tutotialImage, setTutorialImage] = useState(data); + const [list, setList] = useState(tutorialList); + useEffect(() => { + setList(tutorialList?.filter((id) => id.id === activeTutorial)); + setTutorialImage(data?.filter((id) => id.id === activeTutorial)); + }, [activeTutorial]); + return ( +
+ {list?.map((i) => { + return ( +

+ {i.name} +

+ ); + })} + {tutotialImage?.map((i) => { + return ( +
+
+ {i.images?.map((i, index) => { + return ( + {i.alt} + ); + })} +
+ {i.btn && } +
+ ); + })} +
+ ); +}; + +export default Learn; diff --git a/src/pages/tutorial/section/components/ListTutorial.tsx b/src/pages/tutorial/section/components/ListTutorial.tsx new file mode 100644 index 0000000..8741906 --- /dev/null +++ b/src/pages/tutorial/section/components/ListTutorial.tsx @@ -0,0 +1,29 @@ +import { ListTutorialsProps } from "../../../../types/props"; + +const ListTutorials = ({ + tutorialList, + activeTutorial, + setActiveTutorial, +}: ListTutorialsProps) => { + return ( +
+
    + {tutorialList?.map((i) => { + return ( +
  • setActiveTutorial(i.id)} + key={i.id} + > + {i.name} +
  • + ); + })} +
+
+ ); +}; + +export default ListTutorials;