reza fixed sliders and convert redux to TS

master
RezaAshrafi77 3 years ago
parent 2b1d297722
commit edf81c7074
  1. 9
      src/components/GradeFilter/index.scss
  2. 3
      src/redux/actions-type/index.tsx
  3. 33
      src/redux/actions-type/public.tsx
  4. 49
      src/redux/actions-type/user.tsx
  5. 4
      src/redux/actions/index.js
  6. 4
      src/redux/actions/index.tsx
  7. 25
      src/redux/actions/public.js
  8. 34
      src/redux/actions/public.tsx
  9. 61
      src/redux/actions/user.js
  10. 61
      src/redux/actions/user.tsx
  11. 58
      src/redux/proxy.tsx
  12. 3
      src/redux/reducers/index.js
  13. 3
      src/redux/reducers/index.tsx
  14. 171
      src/redux/reducers/public.js
  15. 171
      src/redux/reducers/public.tsx
  16. 23
      src/redux/reducers/user.tsx
  17. 7
      src/views/Home/Blogs/Blog/index.tsx
  18. 8
      src/views/Home/Books/Book/index.tsx
  19. 21
      src/views/Home/Courses/Course/index.tsx

@ -31,7 +31,7 @@
}
&__active{
background-color: #9CDF52;
box-shadow: 0px 0px 24px #9CDF52;
box-shadow: 0px 0px 20px #9CDF52;
border-radius: 5px;
}
}
@ -113,7 +113,7 @@
h1{
font-size: calc(100vw / 50);
background-color: #9CDF52;
box-shadow: 0px 0px 24px #9CDF52;
box-shadow: 0px 0px 20px #9CDF52;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
padding: 12px 15px;
@ -134,7 +134,7 @@
h1{
font-size: calc(100vw / 30);
background-color: #9CDF52;
box-shadow: 0px 0px 24px #9CDF52;
box-shadow: 0px 0px 20px #9CDF52;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
padding: 12px 15px;
@ -170,8 +170,9 @@
background : #383838;
padding: 10px 20px;
border-radius: 10px;
justify-content:center;
li{
width: calc(100% / 4.45) !important;
width: calc(100% / 4.7) !important;
margin: 8px 5px;
font-size: calc(100vw / 28);
padding: 5px 0px;

@ -0,0 +1,3 @@
// @create-index
export type { default as PublicAction } from "./public";
export type { default as UserAction } from "./user";

@ -0,0 +1,33 @@
interface getHomeData {
type : "public/homePage"
data : any
}
interface getBlogList{
type : "public/blogList"
data : any
}
interface getBlogInfo{
type : "public/blogInfo"
data : any
}
interface error{
type : "error"
data : undefined
}
interface loading{
type : "loading"
data : undefined
}
// interface filterNewProducts{
// }
type PublicAction =getBlogList | getBlogInfo | getHomeData | loading | error;
export default PublicAction;

@ -0,0 +1,49 @@
interface otp {
type : "public/sendOTP"
data : any
}
interface otp_login{
type : "user/otp/login"
data : any
}
// interface switchRole{
// type : "user/switchRole"
// data : Object
// }
interface logout{
type : "user/logout"
data : any
}
interface getUserRole{
type : "user/getUserRole"
data : any
}
interface getProfile{
type : "user/getProfile"
data : any
}
interface setProfile{
type : "user/setProfile"
data : any
}
interface error{
type : "error"
data : undefined
}
interface loading{
type : "loading"
data : undefined
}
type UserAction = otp | otp_login | logout | getUserRole | getProfile | setProfile | error | loading;
export default UserAction;

@ -1,4 +0,0 @@
// @create-index
export { default as publicApi } from "./public.js";
export { default as user } from "./user.js";

@ -0,0 +1,4 @@
// @create-index
export { default as publicApi } from "./public";
export { default as user } from "./user";

@ -1,25 +0,0 @@
import proxy from "../proxy";
const publicApi = {
getHomeData: (data, history) => async (dispatch) =>
await proxy.get("public/homePage", data, { history, dispatch }),
getFaqList: (data, history) => async (dispatch) =>
await proxy.get("faq/list", data, { history, dispatch }),
setFaqActive: (data) => async (dispatch) =>
await dispatch({ type: "public/faq/activate", data: data }),
searchFaq: (data) => async (dispatch) =>
await dispatch({ type: "public/faq/search", data: data }),
getContactData:
(data = {}, history) =>
async (dispatch) =>
await proxy.get("public/contact", data, { history, dispatch }),
getArList: (data, history) => async (dispatch) =>
await proxy.get("public/ar", data, { history, dispatch }),
getBlogList: (data, history) => async (dispatch) =>
await proxy.get("public/blogList", data, { history, dispatch }),
getBlogInfo: (data, history) => async (dispatch) =>
await proxy.get("public/blogInfo", data, { history, dispatch }),
filterNewProducts: (data, history) => async (dispatch) =>
await dispatch({ type: "public/filter", data: data }),
};
export default publicApi;

@ -0,0 +1,34 @@
import { Dispatch } from "redux";
import proxy from "../proxy";
const publicApi = {
getHomeData: (data: undefined, history: any) => async (dispatch: Dispatch) =>
await proxy.get("public/homePage", data, { history, dispatch }),
// getFaqList: (data: undefined, history: any) => async (dispatch: Dispatch) =>
// await proxy.get("faq/list", data, { history, dispatch }),
// setFaqActive: (data: undefined) => async (dispatch: Dispatch) =>
// await dispatch({ type: "public/faq/activate", data: data }),
// searchFaq: (data: String) => async (dispatch: Dispatch) =>
// await dispatch({ type: "public/faq/search", data: data }),
// getContactData:
// (data = {}, history: any) =>
// async (dispatch: Dispatch) =>
// await proxy.get("public/contact", data, { history, dispatch }),
// getArList: (data: undefined, history: any) => async (dispatch: Dispatch) =>
// await proxy.get("public/ar", data, { history, dispatch }),
getBlogList: (data: undefined, history: any) => async (dispatch: Dispatch) =>
await proxy.get("public/blogList", data, { history, dispatch }),
getBlogInfo: (data: String, history: any) => async (dispatch: Dispatch) =>
await proxy.get("public/blogInfo", data, { history, dispatch }),
// filterNewProducts: (data: Object) => async (dispatch: Dispatch) =>
// await dispatch({ type: "public/filter", data: data }),
};
export default publicApi;

@ -1,61 +0,0 @@
import proxy from "../proxy";
const user = {
otp: (data, history) => async (dispatch) =>
await proxy.login("public/sendOTP", data, { history, dispatch }),
// otp:
// (data = {}) =>
// async (dispatch) =>
// dispatch({ type: "public/sendOTP", payload: data }),
otp_login: (data, history) => async (dispatch) =>
await proxy.login("user/otp/login", data, { history, dispatch }),
// otp_login:
// (data = {}) =>
// async (dispatch) =>
// dispatch({ type: "user/otp/login", payload: data }),
register: (data, history) => async (dispatch) =>
await proxy.login("user/register", data, { history, dispatch }),
switchRole: (data, history) => async (dispatch) =>
await proxy.login("user/switchRole", data, { history, dispatch }),
logout: (data, history) => async (dispatch) =>
await proxy.logout("user/logout", data, { history, dispatch }),
getUserRole: (data) => async (dispatch) =>
await proxy.get("user/getUserRole", data, { dispatch }),
list:
(data = {}) =>
async (dispatch) =>
await proxy.get("user/list", data, { dispatch }),
domains:
(data = {}) =>
async (dispatch) =>
await proxy.get("user/domains", data, { dispatch }),
getmothers:
(data = {}) =>
async (dispatch) =>
await proxy.get2("mothers/list", data, {
dispatch,
}),
getProfile:
(data = {}) =>
async (dispatch) =>
await proxy.get("user/getProfile", data, { dispatch }),
setProfile:
(data = {}, data2 = {}) =>
async (dispatch) => {
await proxy.put("user/setProfile", data, { dispatch });
await proxy.get("user/getProfile", data2, { dispatch });
},
add:
(data = {}, data2 = {}) =>
async (dispatch) => {
await proxy.post("user/add", data);
await proxy.get("user/list", data2, { dispatch });
},
del:
(data = {}, data2 = {}) =>
async (dispatch) => {
await proxy.delete("user/delete", data);
await proxy.get("user/list", data2, { dispatch });
},
};
export default user;

@ -0,0 +1,61 @@
import proxy from "../proxy";
import {Dispatch} from 'redux';
const user = {
otp: (data : String) => async (dispatch : Dispatch) =>
await proxy.login("public/sendOTP", data, { dispatch }),
otp_login: (data : Object) => async (dispatch : Dispatch) =>
await proxy.login("user/otp/login", data, { dispatch }),
// register: (data : undefined) => async (dispatch : Dispatch) =>
// await proxy.login("user/register", data, { dispatch }),
// switchRole: (data : String) => async (dispatch : Dispatch) =>
// await proxy.login("user/switchRole", data, { dispatch }),
logout: (data : String) => async (dispatch : Dispatch) =>
await proxy.logout("user/logout", data, { dispatch }),
getUserRole: (data : String) => async (dispatch : Dispatch) =>
await proxy.get("user/getUserRole", data, { dispatch }),
// list:
// (data = {}) =>
// async (dispatch : Dispatch) =>
// await proxy.get("user/list", data, { dispatch }),
// domains:
// (data = {}) =>
// async (dispatch : Dispatch) =>
// await proxy.get("user/domains", data, { dispatch }),
// getmothers:
// (data = {}) =>
// async (dispatch : Dispatch) =>
// await proxy.get("mothers/list", data, {
// dispatch,
// }),
getProfile:
(data = {}) =>
async (dispatch : Dispatch) =>
await proxy.get("user/getProfile", data, { dispatch }),
setProfile:
(data = {}, data2 = {}) =>
async (dispatch : Dispatch) => {
await proxy.put("user/setProfile", data, { dispatch });
await proxy.get("user/getProfile", data2, { dispatch });
},
add:
(data = {}, data2 = {}) =>
async (dispatch : Dispatch) => {
await proxy.post("user/add", data);
await proxy.get("user/list", data2, { dispatch });
},
del:
(data = {}, data2 = {}) =>
async (dispatch : Dispatch) => {
await proxy.delete("user/delete", data);
await proxy.get("user/list", data2, { dispatch });
},
};
export default user;

@ -1,9 +1,11 @@
import { ApiConfig } from "~/constants/defaultValues";
import { ApiConfig } from "../constants/defaultValues";
import axios from "axios";
import {Dispatch} from 'redux';
let { baseUrl } = ApiConfig;
let access = window.localStorage.getItem("access");
baseUrl = baseUrl + "/";
const Axios = axios.create({
withCredentials: true,
validateStatus: null,
@ -11,41 +13,57 @@ const Axios = axios.create({
//headers: access ? { Authorization: `Bearer ${access}` } : {},
});
class Proxy {
get = async (url, params, opt = {}) =>
get = async (url: any, params: any, opt: any = {}, data: any = {}) =>
await this.check(
url,
opt,
async () => await Axios.get(url, { params, ...opt }),
data || params
);
post = async (url: any, params: any, opt: any = {}, data : any = {}) =>
await this.check(
url,
opt,
async () => await Axios.get(url, { params, ...opt })
async () => await Axios.post(url, params, opt),
data || params
);
post = async (url, params, opt = {}) =>
await this.check(url, opt, async () => await Axios.post(url, params, opt));
put = async (url, params, opt = {}) =>
await this.check(url, opt, async () => await Axios.put(url, params, opt));
delete = async (url, params, opt = {}) => {
put = async (url : any, params : any, opt : any = {}, data : any = {}) =>
await this.check(
url,
opt,
async () => await Axios.delete(url, { ...opt, data: params })
async () => await Axios.put(url, params, opt),
data || params
);
delete = async (url : any, params : any, opt : any = {}, data : any = {}) => {
await this.check(
url,
opt,
async () => await Axios.delete(url, { ...opt, data: params }),
data || params
);
};
check = async (url, { dispatch }, fetch) => {
check = async (url : any, { dispatch } : any, fetch : any, params : any) => {
dispatch = dispatch || (() => {});
dispatch({ type: "loading" });
dispatch({ type: url.split("/")[0] + "/" + "loading" });
let response = await fetch();
switch (response.status) {
case 200:
dispatch({ type: url, data: response.data.data });
dispatch({ type: url, data: response.data.data, params });
return response.data.data;
case 401:
if (await this.refresh()) {
let response = await fetch();
dispatch({ type: url, data: response.data.data });
dispatch({ type: url, data: response.data.data, params });
return response.data.data;
}
break;
default:
dispatch({ type: "error", data: response.data });
dispatch({
type: url.split("/")[0] + "/" + "error",
data: response.data,
params,
});
}
return false;
};
@ -54,14 +72,15 @@ class Proxy {
let refresh = localStorage.getItem("refresh");
if (!refresh) window.location.href = "/";
let login = await this.login(
"user/login",
{},
{ headers: { Authorization: `Bearer ${refresh}` } }
);
return login ? true : false;
};
login = async (url, params, { dispatch }) =>
login = async (url : any, params : any, { dispatch } : any) =>
this.post(url, params, {
dispatch: (obj) => {
dispatch: (obj : any) => {
let login = obj.data;
if (!login || !login.refreshToken) return false;
localStorage.setItem("refresh", login.refreshToken);
@ -73,9 +92,9 @@ class Proxy {
},
});
logout = async (url, params, { dispatch }) => {
logout = async (url : any, params : any, { dispatch } : any) => {
this.post(url, params, {
dispatch: (obj) => {
dispatch: (obj : any) => {
localStorage.removeItem("refresh");
localStorage.removeItem("access");
localStorage.removeItem("userData");
@ -93,7 +112,8 @@ class Proxy {
localStorage.removeItem("userData");
return false;
}
return JSON.parse(userData);
return JSON.parse(userData || '');
};
}
const _proxy = new Proxy();

@ -1,3 +0,0 @@
// @create-index
export { default as publicApi } from "./public.js";
export { default as user } from "./user.js";

@ -0,0 +1,3 @@
// @create-index
export { default as publicApi } from "./public";
export { default as user } from "./user";

@ -1,171 +0,0 @@
const initialState = {
homeData: [],
newProducts: [],
levels: [],
faqList: [],
loading: false,
error: null,
searchResult: [],
contactData: null,
arList: [],
blogList: [],
blog: null,
};
const grades = [
"پیش دبستان",
"اول",
"دوم",
"سوم",
"چهارم",
"پنجم",
"ششم",
"هفتم",
"هشتم",
"نهم",
"دهم",
"یازدهم",
"دوازدهم",
];
export default function publicApi(state = initialState, action) {
let { type, data } = action;
switch (type) {
case "public/homePage":
let itemsLevel;
if (window.innerWidth > 1000) {
const jadidTarin = data.filter(
(item) => item.title === "جدیدترین کتابهای دانوین"
);
itemsLevel = jadidTarin[0].data
.map((item) => item.book.gradeId * 1)
.sort((a, b) => a - b)
.map((e) => grades[e]);
itemsLevel.unshift("همه");
}
return {
...state,
loading: false,
levels: window.innerWidth > 1000 ? [...new Set(itemsLevel)] : [],
error: null,
homeData: data,
};
case "public/filter":
const realList =
state.newProducts.length === 0
? state.homeData.filter(
(item) => item.title === "جدیدترین کتابهای دانوین"
)[0].data
: state.newProducts;
if (state.newProducts.length === 0) {
state = {
...state,
newProducts: realList,
};
console.log("here1");
}
const level = data.levels;
const search = data.search;
if (level.length > 0 || search) {
localStorage.setItem("filter", "ON");
} else {
return {
...state,
loading: false,
error: null,
homeData: state.homeData.map((item) =>
item.title === "جدیدترین کتابهای دانوین"
? { ...item, data: state.newProducts }
: { ...item }
),
newProducts: [],
};
}
let byLevelFilter = [];
if (level.length > 0) {
level.map((item1) => {
for (let i = 0; i < realList.length; i++) {
if (grades[realList[i].book.gradeId] === item1) {
byLevelFilter.push(realList[i]);
}
}
});
} else {
byLevelFilter = realList;
}
// let bySubjectFilter = [];
// if (subject.length > 0) {
// subject.map((item1) => {
// for (let i = 0; i < byLevelFilter.length; i++) {
// if (byLevelFilter[i].name === item1) {
// bySubjectFilter.push(byLevelFilter[i]);
// }
// }
// });
// } else {
// bySubjectFilter = byLevelFilter;
// }
const bySearchFilter = search
? byLevelFilter.filter((item1) => item1.name.indexOf(search) !== -1)
: byLevelFilter;
// if (sort === "گران ترین") {
// finalSort = bySearchFilter.sort((item1, item2) => {
// return item1.product[0].price - item2.product[0].price;
// });
// } else {
// finalSort = bySearchFilter;
// }
return {
...state,
loading: false,
error: null,
homeData: state.homeData.map((item) =>
item.title === "جدیدترین کتابهای دانوین"
? { ...item, data: bySearchFilter }
: { ...item }
),
};
case "faq/list":
return { ...state, loading: false, error: null, faqList: data };
case "public/faq/activate":
return {
...state,
loading: false,
error: null,
faqList: state.faqList.map((item) =>
item.id === data
? { ...item, active: !item.active }
: { ...item, active: false }
),
};
case "public/faq/search":
return {
...state,
loading: false,
error: null,
searchResult: state.faqList.filter(
(item) =>
item.title.indexOf(data) !== -1 ||
item.description.indexOf(data) !== -1
),
};
case "public/contact":
return { ...state, loading: false, error: null, contactData: data };
case "public/ar":
return { ...state, loading: false, error: null, arList: data };
case "public/blogList":
return { ...state, loading: false, error: null, blogList: data };
case "public/blogInfo":
return { ...state, loading: false, error: null, blog: data };
case "loading":
return { ...state, loading: true };
case "error":
return { ...state, loading: false, error: data.message };
default:
return state;
}
}

@ -0,0 +1,171 @@
import { PublicAction } from "../actions-type";
const initialState = {
homeData: [],
newProducts: [],
levels: [],
faqList: [],
loading: false,
error: null,
searchResult: [],
contactData: null,
arList: [],
blogList: [],
blog: null,
};
const grades = [
"پیش دبستان",
"اول",
"دوم",
"سوم",
"چهارم",
"پنجم",
"ششم",
"هفتم",
"هشتم",
"نهم",
"دهم",
"یازدهم",
"دوازدهم",
];
export default function publicApi(state = initialState, action: PublicAction) {
let { type, data } = action;
switch (type) {
case "public/homePage":
let itemsLevel;
if (window.innerWidth > 1000) {
const jadidTarin = data.filter(
(item : any) => item.title === "جدیدترین کتابهای دانوین"
);
itemsLevel = jadidTarin[0].data
.map((item : any) => item.book.gradeId * 1)
.sort((a : any, b : any) => a - b)
.map((e : any) => grades[e]);
itemsLevel.unshift("همه");
}
return {
...state,
loading: false,
levels: window.innerWidth > 1000 ? Array.from(new Set(itemsLevel)) : [],
error: null,
homeData: data,
};
// case "public/filter":
// const realList =
// state.newProducts.length === 0
// ? state.homeData.filter(
// (item) => item.title === "جدیدترین کتابهای دانوین"
// )[0].data
// : state.newProducts;
// if (state.newProducts.length === 0) {
// state = {
// ...state,
// newProducts: realList,
// };
// console.log("here1");
// }
// const level = data.levels;
// const search = data.search;
// if (level.length > 0 || search) {
// localStorage.setItem("filter", "ON");
// } else {
// return {
// ...state,
// loading: false,
// error: null,
// homeData: state.homeData.map((item) =>
// item.title === "جدیدترین کتابهای دانوین"
// ? { ...item, data: state.newProducts }
// : { ...item }
// ),
// newProducts: [],
// };
// }
// let byLevelFilter = [];
// if (level.length > 0) {
// level.map((item1) => {
// for (let i = 0; i < realList.length; i++) {
// if (grades[realList[i].book.gradeId] === item1) {
// byLevelFilter.push(realList[i]);
// }
// }
// });
// } else {
// byLevelFilter = realList;
// }
// // let bySubjectFilter = [];
// // if (subject.length > 0) {
// // subject.map((item1) => {
// // for (let i = 0; i < byLevelFilter.length; i++) {
// // if (byLevelFilter[i].name === item1) {
// // bySubjectFilter.push(byLevelFilter[i]);
// // }
// // }
// // });
// // } else {
// // bySubjectFilter = byLevelFilter;
// // }
// const bySearchFilter = search
// ? byLevelFilter.filter((item1) => item1.name.indexOf(search) !== -1)
// : byLevelFilter;
// // if (sort === "گران ترین") {
// // finalSort = bySearchFilter.sort((item1, item2) => {
// // return item1.product[0].price - item2.product[0].price;
// // });
// // } else {
// // finalSort = bySearchFilter;
// // }
// return {
// ...state,
// loading: false,
// error: null,
// homeData: state.homeData.map((item) =>
// item.title === "جدیدترین کتابهای دانوین"
// ? { ...item, data: bySearchFilter }
// : { ...item }
// ),
// };
// case "faq/list":
// return { ...state, loading: false, error: null, faqList: data };
// case "public/faq/activate":
// return {
// ...state,
// loading: false,
// error: null,
// faqList: state.faqList.map((item) =>
// item.id === data
// ? { ...item, active: !item.active }
// : { ...item, active: false }
// ),
// };
// case "public/faq/search":
// return {
// ...state,
// loading: false,
// error: null,
// searchResult: state.faqList.filter(
// (item) =>
// item.title.indexOf(data) !== -1 ||
// item.description.indexOf(data) !== -1
// ),
// };
// case "public/contact":
// return { ...state, loading: false, error: null, contactData: data };
// case "public/ar":
// return { ...state, loading: false, error: null, arList: data };
case "public/blogList":
return { ...state, loading: false, error: null, blogList: data };
case "public/blogInfo":
return { ...state, loading: false, error: null, blog: data };
case "loading":
return { ...state, loading: true };
case "error":
return { ...state, loading: false, error: data.message };
default:
return state;
}
}

@ -1,5 +1,6 @@
import proxy from "../proxy";
import { toast } from "react-toastify";
import { UserAction} from '../actions-type'
const initialState = {
status: proxy.status(),
loading: false,
@ -9,12 +10,12 @@ const initialState = {
mothers: [],
profileStatus: false,
};
export default function user(state = initialState, action) {
export default function user(state = initialState, action : UserAction) {
let { type, data } = action;
switch (type) {
case "user/login":
case "user/register":
case "user/switchRole":
// case "user/login":
// case "user/register":
// case "user/switchRole":
case "public/sendOTP":
toast.success("کد به شماره شما ارسال گردید.");
return { ...state, loading: false, status: data.profile, error: null };
@ -33,16 +34,16 @@ export default function user(state = initialState, action) {
return { ...state, loading: false, status: proxy.status(), error: null };
case "user/getUserRole":
return { ...state, loading: false, userRoles: data, error: null };
case "user/list":
return { ...state, loading: false, list: data, error: null };
case "user/domains":
return { ...state, loading: false, domains: data, error: null };
case "mothers/list":
return { ...state, loading: false, mothers: data, error: null };
// case "user/list":
// return { ...state, loading: false, list: data, error: null };
// case "user/domains":
// return { ...state, loading: false, domains: data, error: null };
// case "mothers/list":
// return { ...state, loading: false, mothers: data, error: null };
case "user/setProfile":
toast.success("تغییرات اعمال شد.");
setTimeout(() => {
window.location = "/";
window.location.pathname = "/";
}, 500);
return { ...state, loading: false, error: null };
case "loading":

@ -1,13 +1,14 @@
import React from "react";
import Avatar from "@material-ui/core/Avatar";
import {Link} from 'react-router-dom';
import "./index.scss";
export default function Blog(props: any) {
const { data } = props;
return (
<article
<Link to={'/'}
className="home-blogs-blog d-flex align-items-end"
style={{ background: `url(${data.imageUrl})` }}
draggable={'false'}
>
{/* <img src={data.imageUrl} alt={data.name} /> */}
<div className="home-blogs-blog__cover"></div>
@ -17,6 +18,6 @@ export default function Blog(props: any) {
<p>{data.text.slice(0, 49)}</p>
</div>
</footer>
</article>
</Link>
);
}

@ -1,18 +1,18 @@
import React from "react";
import Avatar from "@material-ui/core/Avatar";
import {Link} from 'react-router-dom';
import "./index.scss";
export default function Book(props: any) {
const { data } = props;
return (
<article className="home-books-book d-flex flex-column">
<img src={data.imageUrl} alt={data.name} />
<Link to={'/'} className="home-books-book d-flex flex-column" draggable={'false'}>
<img src={data.imageUrl} alt={data.name} draggable={'false'} />
<footer className="d-flex">
<div className="home-books-book__info d-flex flex-column">
<h2>{data.name}</h2>
<p>{data.text.slice(0, 50)}</p>
</div>
</footer>
</article>
</Link>
);
}

@ -1,22 +1,23 @@
import React from "react";
import Avatar from "@material-ui/core/Avatar";
import {Link} from 'react-router-dom';
import "./index.scss";
export default function Course(props: any) {
const { data } = props;
return (
<article className="home-courses-course d-flex flex-column">
<img src={data.imageUrl} alt={data.name} />
<Link to={'/'} className="home-courses-course d-flex flex-column" draggable={'false'}>
<img src={data.imageUrl} alt={data.name} draggable={'false'} />
<footer className="d-flex">
<Avatar src={data.user} style={{width : 40, height : 40}} />
<Avatar src={data.user} style={{ width: 40, height: 40 }} />
<div className="home-courses-course__info d-flex flex-column">
<h2>{data.name}</h2>
{
window.innerWidth > 1007 ?
<p>{data.text.slice(0, 100)}</p> : <p>{data.text.slice(0, 50)}</p>
}
{window.innerWidth > 1007 ? (
<p>{data.text.slice(0, 100)}</p>
) : (
<p>{data.text.slice(0, 50)}</p>
)}
<ul className="d-flex flex-wrap">
{data.tags.length <= 2
? data.tags.map((item: String, i: any) => <li key={i}>{item}</li>)
@ -31,6 +32,6 @@ export default function Course(props: any) {
</ul>
</div>
</footer>
</article>
</Link>
);
}

Loading…
Cancel
Save