Browse Source

Small fixes

master
Miguel Moreno 1 year ago
parent
commit
6c99c8e72e
  1. 2
      client/package.json
  2. 6
      client/src/collections.js
  3. 4
      client/src/components/layout/Navbar.js
  4. 11
      client/src/components/layout/ProductPreview.js
  5. 4
      client/src/components/pages/Collection.js
  6. 3
      client/src/styles/partials/containers.scss
  7. 5
      client/src/styles/partials/global.scss
  8. 2
      docker-compose.yml
  9. 3
      server/.env
  10. 139
      server/package-lock.json
  11. 3
      server/package.json
  12. 42
      server/routes/sendEmail.js
  13. 14
      server/routes/setCookie.js
  14. 31
      server/server.js
  15. 25
      server/transporter.js

2
client/package.json

@ -27,7 +27,7 @@
"react-vertical-timeline-component": "^2.5.0"
},
"scripts": {
"start": "react-scripts start",
"start": "PORT=3000 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"

6
client/src/collections.js

@ -435,13 +435,15 @@ const collections = [
'name': 'Light Table I',
'code': 'MP-TAB-LIGHTI',
'img': './../img/collections/placeholder.png',
'dimensions': '31 x 31 x 22'
'dimensions': '31 x 31 x 22',
'file': 'files/lighttable.pdf'
},
{
'name': 'Light Table II',
'code': 'MP-TAB-LIGHII',
'img': './../img/collections/placeholder.png',
'dimensions': '34 x 34 x 26'
'dimensions': '34 x 34 x 26',
'file': 'files/lighttable.pdf'
}
]
}

4
client/src/components/layout/Navbar.js

@ -18,7 +18,7 @@ const Navbar = React.forwardRef((props, ref) => {
const toggleDarkMode = async () => {
toggleTheme(true)
const request = await axios.post('/api/setcookie/darkmode')
const request = await axios.post('/api/tasks/darkmode')
if (request.data.msg === 'success') {
setCookieChange(true)
setTimeout(() => setCookieChange(false), 3000)
@ -29,7 +29,7 @@ const Navbar = React.forwardRef((props, ref) => {
const toggleLightMode = async () => {
toggleTheme(false)
const request = await axios.post('/api/setcookie/lightmode')
const request = await axios.post('/api/tasks/lightmode')
if (request.data.msg === 'success') {
setCookieChange(true)
setTimeout(() => setCookieChange(false), 3000)

11
client/src/components/layout/ProductPreview.js

@ -1,12 +1,21 @@
import React from 'react'
import { Link } from 'react-router-dom'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import Pdf from '../../files/lighttable.pdf'
const ProductPreview = ({ name, img, code, dimensions}) => (
const ProductPreview = ({ name, img, code, dimensions, file}) => (
<div className="product-preview">
<img src={img} alt={name}/>
<div className="content">
<h3>{name}</h3>
<p>{code ? code : 'N/A'}</p>
<p>{dimensions === 'N/A' ? 'N/A' : dimensions ? `${dimensions} inches` : 'N/A'}</p>
{file ?
<Link to={Pdf} target="_blank">
See product spec sheet <FontAwesomeIcon icon="angle-right" />
</Link>
: null
}
</div>
</div>
)

4
client/src/components/pages/Collection.js

@ -22,7 +22,6 @@ const Collection = ({ match }) => {
products: collection.products,
showcase: collection.showcase,
items: collection.list,
file: collection.file
}
} else {
return {
@ -31,7 +30,6 @@ const Collection = ({ match }) => {
products: [],
showcase: '',
items: [],
file: ''
}
}
})
@ -67,7 +65,7 @@ const Collection = ({ match }) => {
</>
:
content[index].products.line.map((product, i) => (
<ProductPreview name={product.name} code={product.code} img={product.img} dimensions={product.dimensions} />
<ProductPreview name={product.name} code={product.code} img={product.img} dimensions={product.dimensions} file={product.file} />
))
}
</div>

3
client/src/styles/partials/containers.scss

@ -406,6 +406,9 @@
}
.content{
padding-top: 2rem;
a {
line-height: 3rem;
}
}
}
}

5
client/src/styles/partials/global.scss

@ -11,4 +11,9 @@
font-family: $montserrat-light;
line-height: 2rem;
}
a {
text-decoration: none;
color: $green;
font-family:$montserrat-medium;
}
}

2
docker-compose.yml

@ -16,7 +16,7 @@ services:
server:
build:
context: ./server/
command: /usr/app/node_modules/.bin/nodemon server.js
command: /usr/app/node_modules/.bin/nodemon app/server.js
image: mamapats_server
ports:
- "4000:4000"

3
server/.env

@ -1 +1,2 @@
PORT=8000
PORT=4000
DB_CONNECTION="mongodb://186.64.123.227:27017/collections"

139
server/package-lock.json

@ -194,6 +194,11 @@
"integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==",
"dev": true
},
"bluebird": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
"integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA=="
},
"body-parser": {
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
@ -265,6 +270,11 @@
}
}
},
"bson": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/bson/-/bson-1.1.3.tgz",
"integrity": "sha512-TdiJxMVnodVS7r0BdL42y/pqC9cL2iKynVwA0Ho3qbsQYr428veL3l7BQyuqiw+Q5SqqoT0m4srSY/BlZ9AxXg=="
},
"bytes": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
@ -1911,6 +1921,11 @@
"integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==",
"dev": true
},
"kareem": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.1.tgz",
"integrity": "sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw=="
},
"kind-of": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
@ -2015,6 +2030,12 @@
"p-is-promise": "^2.0.0"
}
},
"memory-pager": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz",
"integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==",
"optional": true
},
"merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
@ -2106,6 +2127,74 @@
}
}
},
"mongodb": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.3.3.tgz",
"integrity": "sha512-MdRnoOjstmnrKJsK8PY0PjP6fyF/SBS4R8coxmhsfEU7tQ46/J6j+aSHF2n4c2/H8B+Hc/Klbfp8vggZfI0mmA==",
"requires": {
"bson": "^1.1.1",
"require_optional": "^1.0.1",
"safe-buffer": "^5.1.2",
"saslprep": "^1.0.0"
}
},
"mongoose": {
"version": "5.7.10",
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.7.10.tgz",
"integrity": "sha512-KpQosHPXmlNJKZbiP19mtmC0icaziRlB+xZ14R8q7jY7+OgbbynLD9VWSFb1CyzJX5ebdkVSGmay9HXn341hTA==",
"requires": {
"bson": "~1.1.1",
"kareem": "2.3.1",
"mongodb": "3.3.3",
"mongoose-legacy-pluralize": "1.0.2",
"mpath": "0.6.0",
"mquery": "3.2.2",
"ms": "2.1.2",
"regexp-clone": "1.0.0",
"safe-buffer": "5.1.2",
"sift": "7.0.1",
"sliced": "1.0.1"
},
"dependencies": {
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
"mongoose-legacy-pluralize": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz",
"integrity": "sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ=="
},
"mpath": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/mpath/-/mpath-0.6.0.tgz",
"integrity": "sha512-i75qh79MJ5Xo/sbhxrDrPSEG0H/mr1kcZXJ8dH6URU5jD/knFxCVqVC/gVSW7GIXL/9hHWlT9haLbCXWOll3qw=="
},
"mquery": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.2.tgz",
"integrity": "sha512-XB52992COp0KP230I3qloVUbkLUxJIu328HBP2t2EsxSFtf4W1HPSOBWOXf1bqxK4Xbb66lfMJ+Bpfd9/yZE1Q==",
"requires": {
"bluebird": "3.5.1",
"debug": "3.1.0",
"regexp-clone": "^1.0.0",
"safe-buffer": "5.1.2",
"sliced": "1.0.1"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
}
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
@ -2597,6 +2686,11 @@
"safe-regex": "^1.1.0"
}
},
"regexp-clone": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-1.0.0.tgz",
"integrity": "sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw=="
},
"registry-auth-token": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.4.0.tgz",
@ -2646,6 +2740,15 @@
"integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=",
"dev": true
},
"require_optional": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz",
"integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==",
"requires": {
"resolve-from": "^2.0.0",
"semver": "^5.1.0"
}
},
"resolve": {
"version": "1.12.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz",
@ -2655,6 +2758,11 @@
"path-parse": "^1.0.6"
}
},
"resolve-from": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz",
"integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c="
},
"resolve-url": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz",
@ -2695,11 +2803,19 @@
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"saslprep": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz",
"integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==",
"optional": true,
"requires": {
"sparse-bitfield": "^3.0.3"
}
},
"semver": {
"version": "5.7.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz",
"integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==",
"dev": true
"integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA=="
},
"semver-diff": {
"version": "2.1.0",
@ -2797,12 +2913,22 @@
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
"dev": true
},
"sift": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/sift/-/sift-7.0.1.tgz",
"integrity": "sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g=="
},
"signal-exit": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=",
"dev": true
},
"sliced": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz",
"integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E="
},
"snapdragon": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz",
@ -2935,6 +3061,15 @@
"integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=",
"dev": true
},
"sparse-bitfield": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz",
"integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=",
"optional": true,
"requires": {
"memory-pager": "^1.0.2"
}
},
"spawn-command": {
"version": "0.0.2-1",
"resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2-1.tgz",

3
server/package.json

@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"start": "node server.js"
"start": "node app/server.js"
},
"author": "",
"license": "ISC",
@ -14,6 +14,7 @@
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express-validator": "^6.2.0",
"mongoose": "^5.7.10",
"nodemailer": "^6.3.0"
},
"devDependencies": {

42
server/routes/sendEmail.js

@ -1,42 +0,0 @@
const router = require('express').Router()
const { transporter, transport } = require('./../transporter')
const { check, validationResult } = require('express-validator')
router.post('/',
[
check('name').isLength({ min: 3 }),
check('email').isEmail(),
check('message').isLength({ min: 3 })
],
async (req, res) => {
const errors = validationResult(req)
if (!errors.isEmpty()) {
res.json({ errors: errors.array })
return res.status(422).json({ errors: errors.array(), message: 'fail'})
}
const name = await req.body.name
const email = await req.body.email
const message = await req.body.message
const content = await `Name: ${name}\nEmail address: ${email}\nMessage: ${message}`
try {
} catch(err) {
if(err)
res.send(err)
}
let info = await transporter.sendMail({
from: `"MamaPats Mailer" <${transport.auth.user}>`,
to: 'migalmoreno@tutanota.com',
subject: 'New message from contact form',
text: content
}, (err, data) => {
if (err) {
res.json({ message: 'fail' })
} else {
res.json({ message: 'success' })
}
})
})
module.exports = router

14
server/routes/setCookie.js

@ -1,14 +0,0 @@
const router = require('express').Router()
router.post('/darkmode', (req, res) => {
res.cookie('darkTheme', 'true')
res.json({'msg': 'success'})
})
router.post('/lightmode', (req, res) => {
res.cookie('darkTheme', 'false')
res.json({'msg': 'success'})
})
module.exports = router

31
server/server.js

@ -1,31 +0,0 @@
const express = require('express')
const emailRoute = require('./routes/sendEmail')
const cookieRoute = require('./routes/setCookie')
const path = require('path')
const cookieParser = require('cookie-parser')
// Constants
const PORT = process.env.PORT || 4000;
const HOST = '0.0.0.0'
const CLIENT_BUILD_PATH = path.join(__dirname, '../client/build')
// Express app
const app = express()
// Cookie parser middlware
app.use(cookieParser())
// Static files middleware
app.use(express.static(CLIENT_BUILD_PATH))
// Body parser middleware
app.use(express.json())
app.get('*', (req, res) => {
res.sendFile(path.join(CLIENT_BUILD_PATH, 'index.html'))
})
// Route middleware
app.use('/api/sendemail', emailRoute)
app.use('/api/setcookie', cookieRoute)
app.listen(PORT, HOST, () => console.log('Server is up and running'))

25
server/transporter.js

@ -1,25 +0,0 @@
const nodemailer = require('nodemailer')
const creds = require('./config')
const transport = {
host: 'mail.mamapats.com.pe',
port: 465,
secure: true,
auth: {
user: creds.USER,
pass: creds.PASS
}
}
const transporter = nodemailer.createTransport(transport)
transporter.verify((error, success) => {
if (error) {
console.log(error)
} else {
console.log('Server is ready to send messages')
}
})
module.exports.transporter = transporter
module.exports.transport = transport
Loading…
Cancel
Save