From 05d72787b3480fe0c622da736b7aad78c661fa68 Mon Sep 17 00:00:00 2001 From: Robert Istok Date: Mon, 10 Jul 2017 18:58:36 +0300 Subject: [PATCH] Scripts to npm --- client/semantic.json | 2 +- .../Notifications/NotificationItem.js | 157 ++++++++++-------- package.json | 68 ++++---- 3 files changed, 119 insertions(+), 108 deletions(-) diff --git a/client/semantic.json b/client/semantic.json index 26a3c09..952ccea 100644 --- a/client/semantic.json +++ b/client/semantic.json @@ -69,5 +69,5 @@ "state", "visibility" ], - "version": "2.2.9" + "version": "2.2.10" } \ No newline at end of file diff --git a/client/src/components/Header/elements/Notifications/NotificationItem.js b/client/src/components/Header/elements/Notifications/NotificationItem.js index da9b6bc..e7da0a5 100644 --- a/client/src/components/Header/elements/Notifications/NotificationItem.js +++ b/client/src/components/Header/elements/Notifications/NotificationItem.js @@ -11,75 +11,85 @@ import taskDoneLogo from '../../../../assets/task-done.svg'; import cancelLogo from '../../../../assets/cancel.svg'; function formatNotification(type, teacherName, target, info) { - const { course } = target; - if (type === 'attendanceAdd') { - const { enteredFor } = info; - return `You've been marked as present by ${teacherName} for the ${onlyFirstLetters(course.id.name)} ${course.type} at ${formatTime(enteredFor)} `; - } - - if (type === 'attendanceRemove') { - const { enteredFor } = info; - return `${teacherName} removed your attendance for the ${onlyFirstLetters(course.id.name)} ${course.type} at ${formatTime(enteredFor)} `; - } - - if (type === 'gradeAdd') { - const { gradeNumber } = info; - return `${teacherName} added your ${gradeNumber}. grade for the ${onlyFirstLetters(course.id.name)} ${course.type}`; - } - - if (type === 'gradeDelete') { - const { gradeNumber } = info; - return `${teacherName} removed your ${gradeNumber}. grade for the ${onlyFirstLetters(course.id.name)} ${course.type}`; - } - - return `No notification of type ${type} found... :(`; + const { course } = target; + if (type === 'attendanceAdd') { + const { enteredFor } = info; + return `You've been marked as present by ${teacherName} for the ${onlyFirstLetters( + course.id.name + )} ${course.type} at ${formatTime(enteredFor)} `; + } + + if (type === 'attendanceRemove') { + const { enteredFor } = info; + return `${teacherName} removed your attendance for the ${onlyFirstLetters( + course.id.name + )} ${course.type} at ${formatTime(enteredFor)} `; + } + + if (type === 'gradeAdd') { + const { gradeNumber } = info; + return `${teacherName} added your ${gradeNumber}. grade for the ${onlyFirstLetters( + course.id.name + )} ${course.type}`; + } + + if (type === 'gradeDelete') { + const { gradeNumber } = info; + return `${teacherName} removed your ${gradeNumber}. grade for the ${onlyFirstLetters( + course.id.name + )} ${course.type}`; + } + + return `No notification of type ${type} found... :(`; } const NotificationItem = (props) => { - const { - type, - triggeredBy: { name: teacherName }, - timestamp, - target, - seenBy, - info, - user: { _id: userID, profile }, - customItemProps: { onClick } - } = props; - - const lang = profile.group !== undefined ? profile.group.lang : 'ro'; - - return ( - - user === userID) === undefined}> - - - - {formatNotification(type, teacherName, target, info)} - - - {formatTime(timestamp, true)} - - - ); + const { + type, + triggeredBy: { name: teacherName }, + timestamp, + target, + seenBy, + info, + user: { _id: userID, profile }, + customItemProps: { onClick } + } = props; + + const lang = profile.group !== undefined ? profile.group.lang : 'ro'; + + return ( + + user === userID) === undefined}> + + + + {formatNotification(type, teacherName, target, info)} + + + + {formatTime(timestamp)} + + + + ); }; const { shape, string, arrayOf, object, func } = PropTypes; NotificationItem.propTypes = { - type: string.isRequired, - timestamp: string.isRequired, - user: shape({ - _id: string.isRequired, - profile: shape({ name: string.isRequired }) - }), - seenBy: arrayOf(string), - triggeredBy: shape({ name: string.isRequired }).isRequired, - target: shape({ course: shape({ id: shape({ name: string.isRequired }) }) }), - info: object, - customItemProps: shape({ onClick: func.isRequired }).isRequired + type: string.isRequired, + timestamp: string.isRequired, + user: shape({ + _id: string.isRequired, + profile: shape({ name: string.isRequired }) + }), + seenBy: arrayOf(string), + triggeredBy: shape({ name: string.isRequired }).isRequired, + target: shape({ course: shape({ id: shape({ name: string.isRequired }) }) }), + info: object, + customItemProps: shape({ onClick: func.isRequired }).isRequired }; const StyledLink = styled(Link)` @@ -101,7 +111,8 @@ const StyledLink = styled(Link)` const Wrapper = styled.div` display: flex; padding: 12px 16px; - background-color: ${props => props.unSeen === true && props.theme.newNotification}; + background-color: ${props => + props.unSeen === true && props.theme.newNotification}; font-size: 14px; @media screen and (max-width: 768px) { @@ -142,16 +153,16 @@ const Icon = styled.img` margin-right: 15px; content: url(${(props) => { - const { type } = props; - if (type === 'attendanceAdd') { - return calendarLogo; - } else if (type === 'attendanceRemove' || type === 'gradeDelete') { - return documentErrorLogo; - } else if (type === 'gradeAdd') { - return taskDoneLogo; - } - return cancelLogo; -}}); + const { type } = props; + if (type === 'attendanceAdd') { + return calendarLogo; + } else if (type === 'attendanceRemove' || type === 'gradeDelete') { + return documentErrorLogo; + } else if (type === 'gradeAdd') { + return taskDoneLogo; + } + return cancelLogo; + }}); @media screen and (max-width: 768px) { width: 25px; diff --git a/package.json b/package.json index fb7583f..37a8c8e 100644 --- a/package.json +++ b/package.json @@ -1,36 +1,36 @@ { - "name": "server", - "version": "1.0.0", - "private": true, - "main": "index.js", - "license": "MIT", - "engines": { - "node": "7.4.0", - "npm": "4.0.5", - "yarn": "0.24.6" - }, - "dependencies": { - "concurrently": "^3.4.0", - "rimraf": "^2.6.1" - }, - "scripts": { - "build": "concurrently \"cd client && yarn build\" \"cd server && yarn build\"", - "clean": "concurrently \"rimraf node_modules\" \"cd client && rimraf node_modules build\" \"cd server && rimraf node_modules build\"", - "heroku-postbuild": "yarn build", - "install": "(cd client && yarn) && (cd server && yarn)", - "start": "concurrently \"cd client && PORT=3000 yarn start\" \"cd server && PORT=3001 yarn start\"", - "start:prod": "cd server && yarn start:prod", - "format": "prettier-eslint \"src/**/*.js\"" - }, - "devDependencies": { - "babel-eslint": "^7.1.1", - "eslint": "^3.19.0", - "eslint-config-airbnb": "^15.0.1", - "eslint-plugin-import": "^2.2.0", - "eslint-plugin-jsx-a11y": "^5.0.1", - "eslint-plugin-react": "^7.0.1", - "prettier": "^1.5.2", - "prettier-eslint": "^6.1.0", - "prettier-eslint-cli": "^3.4.2" - } + "name": "server", + "version": "1.0.0", + "private": true, + "main": "index.js", + "license": "MIT", + "engines": { + "node": "7.4.0", + "npm": "4.0.5", + "yarn": "0.24.6" + }, + "dependencies": { + "concurrently": "^3.4.0", + "rimraf": "^2.6.1" + }, + "scripts": { + "build": "concurrently \"cd client && npm run build\" \"cd server && npm run build\"", + "clean": "concurrently \"rimraf node_modules\" \"cd client && rimraf node_modules build\" \"cd server && rimraf node_modules build\"", + "heroku-postbuild": "npm run build", + "instal": "npm install && cd client && npm install && cd ../server && npm install", + "start": "concurrently \"cd client && PORT=3000 npm run start\" \"cd server && PORT=3001 npm run start\"", + "start:prod": "cd server && npm run start:prod", + "format": "prettier-eslint \"src/**/*.js\"" + }, + "devDependencies": { + "babel-eslint": "^7.1.1", + "eslint": "^3.19.0", + "eslint-config-airbnb": "^15.0.1", + "eslint-plugin-import": "^2.2.0", + "eslint-plugin-jsx-a11y": "^5.0.1", + "eslint-plugin-react": "^7.0.1", + "prettier": "^1.5.2", + "prettier-eslint": "^6.1.0", + "prettier-eslint-cli": "^3.4.2" + } }