parent
b5e5ee0d9c
commit
450e09e09e
51 changed files with 80243 additions and 585 deletions
File diff suppressed because one or more lines are too long
@ -1,42 +1,41 @@ |
||||
const CACHE_NAME = "version-1"; |
||||
const urlsToCache = ['index.html', 'offline.html']; |
||||
const CACHE_NAME = "version-11"; |
||||
const urlsToCache = ["index.html", "offline.html"]; |
||||
|
||||
const self = this; |
||||
|
||||
//Install SW
|
||||
self.addEventListener('install', (event) => { |
||||
self.addEventListener("install", (event) => { |
||||
event.waitUntil( |
||||
caches.open(CACHE_NAME) |
||||
.then((cache) => { |
||||
console.log('Opened cache'); |
||||
caches.open(CACHE_NAME).then((cache) => { |
||||
console.log("Opened cache"); |
||||
|
||||
return cache.addAll(urlsToCache); |
||||
}) |
||||
) |
||||
return cache.addAll(urlsToCache); |
||||
}) |
||||
); |
||||
}); |
||||
|
||||
//Listen for requests
|
||||
self.addEventListener('fetch', (event) => { |
||||
self.addEventListener("fetch", (event) => { |
||||
event.respondWith( |
||||
caches.match(event.request) |
||||
.then(() => { |
||||
return fetch(event.request) |
||||
.catch(() => caches.match('offline.html')); |
||||
}) |
||||
caches.match(event.request).then(() => { |
||||
return fetch(event.request).catch(() => caches.match("offline.html")); |
||||
}) |
||||
); |
||||
}); |
||||
//Activate the SW
|
||||
self.addEventListener('activate', (event) => { |
||||
self.addEventListener("activate", (event) => { |
||||
const cacheWhiteList = []; |
||||
cacheWhiteList.push(CACHE_NAME); |
||||
|
||||
event.waitUntil( |
||||
caches.keys().then((cacheNames) => Promise.all( |
||||
cacheNames.map((cacheName) => { |
||||
if (!cacheWhiteList.includes(cacheName)) { |
||||
return caches.delete(cacheName); |
||||
} |
||||
}) |
||||
)) |
||||
) |
||||
}); |
||||
caches.keys().then((cacheNames) => |
||||
Promise.all( |
||||
cacheNames.map((cacheName) => { |
||||
if (!cacheWhiteList.includes(cacheName)) { |
||||
return caches.delete(cacheName); |
||||
} |
||||
}) |
||||
) |
||||
) |
||||
); |
||||
}); |
||||
|
After Width: | Height: | Size: 498 B |
@ -1,11 +1,14 @@ |
||||
.navbar { |
||||
width: 100%; |
||||
max-width: 1250px; |
||||
width: 100vw; |
||||
|
||||
position: fixed !important; |
||||
top: 0px !important; |
||||
overflow-x: hidden; |
||||
left: 0px !important; |
||||
// text-align: center !important; |
||||
// overflow-x: hidden; |
||||
background-color: white !important; |
||||
z-index: 300; |
||||
|
||||
box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.3); |
||||
padding: 2px 0 !important; |
||||
// margin: 0px auto !important; |
||||
} |
||||
|
@ -1,3 +1,4 @@ |
||||
.products-list{ |
||||
.products-list { |
||||
padding: 20px 20px; |
||||
} |
||||
margin: 0 auto; |
||||
} |
||||
|
@ -1,103 +1,179 @@ |
||||
/* eslint-disable jsx-a11y/anchor-is-valid */ |
||||
import React, { Component } from "react"; |
||||
import { Link } from "react-router-dom"; |
||||
|
||||
import { toast } from "react-toastify"; |
||||
import proxy from "~/Redux/proxy"; |
||||
import basket from "../../../assets/icons/basket.png"; |
||||
import basket2 from "../../../assets/icons/basket2.png"; |
||||
import { connect } from "react-redux"; |
||||
|
||||
import { userProduct } from "~/Redux/actions"; |
||||
import "./index.scss"; |
||||
const grades = [ |
||||
"پیش دبستان", |
||||
"اول", |
||||
"دوم", |
||||
"سوم", |
||||
"چهارم", |
||||
"پنجم", |
||||
"ششم", |
||||
"هفتم", |
||||
"هشتم", |
||||
"نهم", |
||||
"دهم", |
||||
"یازدهم", |
||||
"دوازدهم", |
||||
]; |
||||
|
||||
const maxMobileSize = 550; |
||||
const maxDesktopSize = 1250; |
||||
|
||||
const fontSize = { |
||||
mobile: { |
||||
h1: window.innerWidth > maxMobileSize ? 18 : window.innerWidth / 22, |
||||
h2: window.innerWidth > maxMobileSize ? 16 : window.innerWidth / 34, |
||||
div: window.innerWidth > maxMobileSize ? 18 : window.innerWidth / 32, |
||||
a: window.innerWidth > maxMobileSize ? 15 : window.innerWidth / 26, |
||||
}, |
||||
desktop: { |
||||
h1: window.innerWidth > maxDesktopSize ? 18 : window.innerWidth / 65, |
||||
h2: window.innerWidth > maxDesktopSize ? 15 : window.innerWidth / 75, |
||||
div: window.innerWidth > maxDesktopSize ? 16 : window.innerWidth / 85, |
||||
old: window.innerWidth > maxDesktopSize ? 9 : window.innerWidth / 120, |
||||
}, |
||||
}; |
||||
export default class Product extends Component { |
||||
class Product extends Component { |
||||
render() { |
||||
const { product, id } = this.props; |
||||
|
||||
return ( |
||||
<> |
||||
{window.innerWidth < 1000 ? ( |
||||
<Link |
||||
to={`/products/physical/${product.id}`} |
||||
className="mobile-products-product d-flex flex-column" |
||||
> |
||||
<img |
||||
src={`https://dnvn.ir/api/v1/file/${product.fileIds}`} |
||||
alt={"عکس مجصول"} |
||||
/> |
||||
<div className="mobile-products-product__info d-flex flex-column"> |
||||
<h1 style={{ fontSize: fontSize.mobile.h1 }}>{product.name}</h1> |
||||
<div className="mobile-products-product d-flex flex-column "> |
||||
<Link |
||||
to={`/products/physical/${product.id}`} |
||||
className=" align-items-center d-flex flex-column " |
||||
style={{ textDecoration: "none" }} |
||||
> |
||||
<img |
||||
className="pimg" |
||||
src={`https://dnvn.ir/api/v1/file/${product.fileIds}`} |
||||
alt={"عکس مجصول"} |
||||
/> |
||||
<div className="mobile-products-product__info d-flex flex-column"> |
||||
<h1>{`${product.name} پایه ${grades[product.gradeId]}`}</h1> |
||||
</div> |
||||
</Link> |
||||
|
||||
<div className="mobile-products-product__links d-flex flex-column"> |
||||
<div className="d-flex" style={{ width: "100%" }}> |
||||
<Link |
||||
to={`/products/physical/${product.id}`} |
||||
className="mobile-products-product__links--physical d-flex justify-content-between align-items-center" |
||||
> |
||||
<h2> نسخه چاپی</h2> |
||||
<span>{product.product[1].price} تومان</span> |
||||
</Link> |
||||
<div |
||||
className="mobile-products-product__links--basket d-flex" |
||||
style={{ backgroundColor: "#7fc75d" }} |
||||
onClick={() => { |
||||
proxy.status() |
||||
? this.props.pushToCart({ |
||||
productId: product.product[1].id, |
||||
userId: this.props.id, |
||||
count: 1, |
||||
}) |
||||
: toast.info("ابتدا وارد حساب کاربری خود شوید."); |
||||
}} |
||||
> |
||||
<img src={basket2} alt="" width="20px" height="20px" /> |
||||
</div> |
||||
</div> |
||||
<div className="d-flex" style={{ width: "100%", opacity: 0.3 }}> |
||||
<Link |
||||
to={`/products/digital/${product.id}`} |
||||
className="mobile-products-product__links--ar d-flex justify-content-between align-items-center" |
||||
> |
||||
<h2> الکترونیکی</h2> |
||||
<span>{product.product[0].price} تومان</span> |
||||
</Link> |
||||
<div |
||||
className="mobile-products-product__links--basket d-flex" |
||||
// onClick={() => {
|
||||
// proxy.status()
|
||||
// ? this.props.pushToCart({
|
||||
// productId: product.product[0].id,
|
||||
// userId: this.props.id,
|
||||
// count: 1,
|
||||
// })
|
||||
// : toast.info("ابتدا وارد حساب کاربری خود شوید.");
|
||||
// }}
|
||||
> |
||||
<img src={basket} alt="" width="20px" height="20px" /> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div className="mobile-products-product__links d-flex mt-2"> |
||||
<div |
||||
// to={`/products/physical/${product.id}`}
|
||||
style={{ fontSize: fontSize.mobile.a }} |
||||
className="mobile-products-product__links--physical d-flex justify-content-between align-items-center" |
||||
</div> |
||||
) : null} |
||||
{window.innerWidth > 1000 ? ( |
||||
<article className="products-product d-flex flex-column align-items-center"> |
||||
<Link |
||||
to={`/products/physical/${product.id}`} |
||||
style={{ textDecoration: "none" }} |
||||
> |
||||
<img |
||||
className="pimg" |
||||
src={`https://dnvn.ir/api/v1/file/${product.fileIds}`} |
||||
alt={product.name} |
||||
/> |
||||
<h1 style={{ fontSize: 15 }}> |
||||
{`${product.name} پایه ${grades[product.gradeId]}`} |
||||
</h1> |
||||
</Link> |
||||
<div className="d-flex" style={{ width: "100%" }}> |
||||
<Link |
||||
to={`/products/physical/${product.id}`} |
||||
style={{ fontSize: 12 }} |
||||
className="products-product--physical d-flex justify-content-between align-items-center" |
||||
> |
||||
<h2 style={{ fontSize: fontSize.mobile.h2 }}>کتاب</h2> |
||||
<span style={{ fontSize: fontSize.mobile.h2 }}> |
||||
<h2 style={{ fontSize: 12 }}>نسخه چاپی</h2> |
||||
<span style={{ fontSize: 12 }}> |
||||
{product.product[1].price} تومان |
||||
</span> |
||||
</Link> |
||||
<div |
||||
className="products-product--basket d-flex" |
||||
style={{ backgroundColor: "#7fc75d", marginTop: 0 }} |
||||
onClick={() => { |
||||
proxy.status() |
||||
? this.props.pushToCart({ |
||||
productId: product.product[1].id, |
||||
userId: this.props.id, |
||||
count: 1, |
||||
}) |
||||
: toast.info("ابتدا وارد حساب کاربری خود شوید."); |
||||
}} |
||||
> |
||||
<img src={basket2} alt="" width="20px" height="20px" /> |
||||
</div> |
||||
<a |
||||
href="#" |
||||
</div> |
||||
<div className="d-flex" style={{ width: "100%", opacity: 0.3 }}> |
||||
<Link |
||||
// to={`/products/digital/${product.id}`}
|
||||
style={{ fontSize: fontSize.mobile.a, opacity: 0.3 }} |
||||
className="mobile-products-product__links--ar d-flex justify-content-between align-items-center" |
||||
|
||||
className="products-product--ar d-flex justify-content-between align-items-center" |
||||
> |
||||
<h2 style={{ fontSize: fontSize.mobile.h2 }}>دیجیتال</h2> |
||||
<span style={{ fontSize: fontSize.mobile.h2 }}> |
||||
<h2 style={{ fontSize: 12 }}>نسخه الکترونیک</h2> |
||||
<span style={{ fontSize: 12 }}> |
||||
{product.product[0].price} تومان |
||||
</span> |
||||
</a> |
||||
</Link> |
||||
<div |
||||
className="products-product--basket d-flex" |
||||
// onClick={() => {
|
||||
// proxy.status()
|
||||
// ? this.props.pushToCart({
|
||||
// productId: product.product[0].id,
|
||||
// userId: this.props.id,
|
||||
// count: 1,
|
||||
// })
|
||||
// : toast.info("ابتدا وارد حساب کاربری خود شوید.");
|
||||
// }}
|
||||
> |
||||
<img src={basket} alt="" width="20px" height="20px" /> |
||||
</div> |
||||
</div> |
||||
</Link> |
||||
) : null} |
||||
{window.innerWidth > 1000 ? ( |
||||
<article className="products-product d-flex flex-column align-items-center"> |
||||
<img |
||||
src={`https://dnvn.ir/api/v1/file/${product.fileIds}`} |
||||
alt={product.name} |
||||
/> |
||||
<h1 style={{ fontSize: fontSize.desktop.h1 }}>{product.name}</h1> |
||||
<Link |
||||
to={`/products/physical/${product.id}`} |
||||
style={{ fontSize: fontSize.mobile.a }} |
||||
className="products-product--physical d-flex justify-content-between align-items-center" |
||||
> |
||||
<h2 style={{ fontSize: fontSize.desktop.h2 }}>کتاب</h2> |
||||
<span style={{ fontSize: fontSize.desktop.h2 }}> |
||||
{product.product[1].price} تومان |
||||
</span> |
||||
{/* {!product.status.digital ? ( |
||||
<img src={basket} alt="افزودن به سبد خرید" /> |
||||
) : null} */} |
||||
</Link> |
||||
<Link |
||||
// to={`/products/digital/${product.id}`}
|
||||
style={{ fontSize: fontSize.mobile.a, opacity: 0.3 }} |
||||
className="products-product--ar d-flex justify-content-between align-items-center" |
||||
> |
||||
<h2 style={{ fontSize: fontSize.desktop.h2 }}>دیجیتال</h2> |
||||
<span style={{ fontSize: fontSize.desktop.h2 }}> |
||||
{product.product[0].price} تومان |
||||
</span> |
||||
</Link> |
||||
</article> |
||||
) : null} |
||||
</> |
||||
); |
||||
} |
||||
} |
||||
|
||||
export default connect((state) => ({}), { |
||||
pushToCart: userProduct.add, |
||||
})(Product); |
||||
|
@ -0,0 +1,58 @@ |
||||
import React, { useState } from "react"; |
||||
import { pdfjs, Document, Page } from "react-pdf"; |
||||
import LinearProgress from "@material-ui/core/LinearProgress"; |
||||
|
||||
import "./index.scss"; |
||||
import Navbar from "../Home/Navbar/index"; |
||||
// pdfjs.PDFJS.workerSrc = "/js/pdf.worker.js";
|
||||
pdfjs.GlobalWorkerOptions.workerSrc = "https://dnvn.ir/pdf.worker.min.js"; |
||||
const file = (fileId) => `${window.baseURL}file/${fileId}`; |
||||
|
||||
export default function Sample({ fileId }) { |
||||
const [numPages, setNumPages] = useState(null); |
||||
const [pageNumber, setPageNumber] = useState(1); |
||||
const [progress, setProgress] = useState(null); |
||||
|
||||
function onDocumentLoadSuccess({ numPages }) { |
||||
setNumPages(numPages); |
||||
setProgress(null); |
||||
} |
||||
const id = +window.location.pathname.split("/").slice(-1)[0]; |
||||
console.log(progress); |
||||
return ( |
||||
<div className="sample"> |
||||
<Navbar page="sample" /> |
||||
<br /> |
||||
<br /> |
||||
<br /> |
||||
{progress < 100 ? ( |
||||
<LinearProgress variant="determinate" value={progress} /> |
||||
) : null} |
||||
<Document |
||||
height="400" |
||||
width="300" |
||||
className="sample_documnet" |
||||
onLoadProgress={({ loaded, total }) => { |
||||
console.log({ loaded, total, progress }); |
||||
setProgress((loaded / total) * 100); |
||||
}} |
||||
//file={"../" + id + ".pdf"}
|
||||
//file={"https://dnvn.ir/files/sample/science/7.pdf"}
|
||||
file={file(id)} |
||||
onLoadSuccess={onDocumentLoadSuccess} |
||||
> |
||||
<Page |
||||
pageNumber={pageNumber} |
||||
noData="نمونه ای برای این محصول درج نشده است" |
||||
/> |
||||
</Document> |
||||
<div onClick={() => setPageNumber(Math.max(1, pageNumber - 1))}>قبل</div> |
||||
<p> |
||||
صفجه {pageNumber} از {numPages} |
||||
</p> |
||||
<div onClick={() => setPageNumber(Math.min(numPages, pageNumber + 1))}> |
||||
بعد{" "} |
||||
</div> |
||||
</div> |
||||
); |
||||
} |
@ -0,0 +1,5 @@ |
||||
.sample { |
||||
&_document { |
||||
margin-top: 85px; |
||||
} |
||||
} |
Loading…
Reference in new issue