Skip to content

Commit

Permalink
Scripts to npm
Browse files Browse the repository at this point in the history
  • Loading branch information
robertistok committed Jul 10, 2017
1 parent 47c1ecd commit 05d7278
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 108 deletions.
2 changes: 1 addition & 1 deletion client/semantic.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@
"state",
"visibility"
],
"version": "2.2.9"
"version": "2.2.10"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<StyledLink
to={`/courses/${target.course.id._id}/${lang}`}
onClick={onClick}
>
<Wrapper unSeen={seenBy.find(user => user === userID) === undefined}>
<InfoWrapper>
<Icon type={type} />
<span>
{formatNotification(type, teacherName, target, info)}
</span>
</InfoWrapper>
<Timestamp>{formatTime(timestamp, true)}</Timestamp>
</Wrapper>
</StyledLink>
);
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 (
<StyledLink
to={`/courses/${target.course.id._id}/${lang}`}
onClick={onClick}
>
<Wrapper unSeen={seenBy.find(user => user === userID) === undefined}>
<InfoWrapper>
<Icon type={type} />
<span>
{formatNotification(type, teacherName, target, info)}
</span>
</InfoWrapper>
<Timestamp>
{formatTime(timestamp)}
</Timestamp>
</Wrapper>
</StyledLink>
);
};

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)`
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
68 changes: 34 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit 05d7278

Please sign in to comment.