Skip to content
This repository was archived by the owner on Feb 11, 2021. It is now read-only.

Commit 46b3f11

Browse files
authored
Merge pull request #214 from new5558/master
version 0.92 beta
2 parents 52654b4 + 777b90f commit 46b3f11

File tree

21 files changed

+179
-71
lines changed

21 files changed

+179
-71
lines changed

README.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,50 @@
1-
# CU Blood Component Template
1+
# CU Blood FrontEnd
22

33

44
## Starting Development Server
55
```
6-
yarn go
6+
yarn start:prod
77
```
88

99
Runs the app in the development mode.<br>
1010
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
1111

12+
## Run production mode
13+
```
14+
yarn install
15+
yarn gencss
16+
yarn next:build
17+
yarn start
18+
```
19+
20+
Need pm2 to always run the node
21+
and nginx to reverse proxy to port 80
22+
23+
### There is a login bug when login from localhost
24+
Since this is only appear in localhost, there will not be a fix for this.
25+
- we have provided manual login for localhost use by the following steps:
26+
1. login from http://next.fives.cloud and copy cookie named "connect.sid" which has value familair to the image
27+
28+
![image](https://user-images.githubusercontent.com/12471844/52804631-423db700-30b7-11e9-8fdf-45b9e28567f7.png)
29+
30+
2. open localhost:3000 and use browser's dev tool to create new cookie named "connect.sid" with the same value copied from the previous step.
31+
32+
![image](https://user-images.githubusercontent.com/12471844/52804581-23d7bb80-30b7-11e9-9b71-886e0c6e393a.png)
33+
34+
3. refreshthe web. you will be now logged in.
35+
36+
![image](https://user-images.githubusercontent.com/12471844/52804671-5b466800-30b7-11e9-928a-9d96375c24ea.png)
37+
38+
1239
## Directory Referencing
1340

1441
Symbol | Directory | Example Usage
1542
--- | --- | ---
16-
@ | ./components | `import FacebookCard from '@/shared-components/FacebookCard'`
43+
@ | ./components | `import FacebookCard from '@/shared-components/FacebookCard'`
44+
45+
46+
## Available deployment sites
47+
https://new5558.surge.sh << old build before migrate from static site to express rendering.
48+
https://cu-blood.herokuapp.com << master branch CI/CD NO DOCKER.
49+
https://poom-cublood.herokuapp.com << poom branch CI/CD NO DOCKER.
50+
http://next.fives.cloud << production branch (same as master but less frequent update)(digital ocean 5$ droplet) NO CD ONLY MANUAL DEPLOY.

components/announcement/local-components/AnnouncementCard.jsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
import React from 'react'
1+
import React, {Component} from 'react'
2+
import moment from 'moment';
3+
import I18 from '@/core/i18n';
4+
let i18n = I18.i18n;
25

3-
export default class AnnouncementCard extends React.Component {
6+
export default class AnnouncementCard extends Component {
47
render() {
5-
68
const { text, date, image } = this.props
7-
9+
i18n.language === 'th' ? moment.locale('th') : moment.locale('en');
10+
811
return (
912
<div className={"bg-white flex flex-col justify-between shadow-md text-black rounded-lg lg:mb-0 m-5 mt-10"} style={{ width: "19rem" }}>
1013
<div className="bg-white flex bg-center bg-cover" style={{ height: '150px', borderTopLeftRadius: '0.5rem', borderTopRightRadius: '0.5rem', backgroundImage: "url(" + image + ")"}}></div>
1114
<div className="flex flex-row items-center px-6 bg-white my-5">
1215
<div className="pl-2 font-semibold text-lg font-cu-body text-pink-dark">
13-
{date}
16+
{moment(date).format('DD MMMM YYYY')}
1417
</div>
1518
</div>
1619
<div className="px-8 pb-3 bg-white text-sm mb-3 font-cu-body text-lg leading-normal select-none">

components/home/local-components/Statistic.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ class Statistic extends Component {
4242
<div className="flex flex-col sm:flex-row w-full items-center">
4343
<div className={`${contentStyle} pt-6 sm:border-b-0 sm:border-r sm:pr-6`}>
4444
{/* <StatisticContent number={statNumber[2]} content={statContent[2]} /> */}
45-
<StatisticContent number={data[3]} content={t('bloodTypeO')} />
45+
<StatisticContent number={data[2]} content={t('bloodTypeO')} />
4646
</div>
4747
<div className={`text-center w-full sm:w-1/2 sm:border-b-0 pt-6 sm:pl-6 sm:flex sm:justify-center`}>
4848
{/* <StatisticContent number={statNumber[3]} content={statContent[3]} /> */}
49-
<StatisticContent number={data[0]} content={t('bloodTypeAB')} />
49+
<StatisticContent number={data[3]} content={t('bloodTypeAB')} />
5050
</div>
5151
</div>
5252
<div className="sm:absolute w-full h-full">

components/home/local-components/UrgentAnnouncement.jsx

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,40 @@
11
import React, { Component } from "react";
2+
import moment from 'moment';
3+
import I18 from '@/core/i18n';
4+
let i18n = I18.i18n;
25

36
class UrgentAnnouncement extends Component {
47
render() {
5-
6-
return (
8+
const { commonsData = {}, t } = this.props;
9+
i18n.language === 'th' ? moment.locale('th') : moment.locale('en');
10+
const startDate = moment(commonsData.startDate);
11+
const endDate = moment(commonsData.endDate);
12+
const regisEndDate = moment(commonsData.registrationEndDate);
13+
const now = moment();
14+
const startAndEndMonth = startDate.format('M') === endDate.format('M')
15+
? startDate.format('MMMM')
16+
: startDate.format('MMM') + '-' + endDate.format('MMM');
17+
18+
return commonsData.startDate ?
19+
(
720
<div className="bg-cb-red flex justify-center sm:block">
821
<div className="flex flex-col sm:flex-row py-6 justify-center sm:items-center font-cu-heading text-white">
922
<div className=" sm:pb-0 sm:pr-4 md:pr-8 mb-3 sm:mb-0 flex justify-start sm:justify-end">
10-
{this.contentDate(`18-21`, `มกราคม`)}
11-
{this.contentDesc(`วันบริจาคเลือด`, `อีก 3 วัน`)}
23+
{this.contentDate(startDate.format('D') + "-" + endDate.format('D'), startAndEndMonth)}
24+
{this.contentDesc(t('donationDate'), `${t('left')} ${endDate.diff(now, 'days')} ${t('days')}`)}
1225
</div>
1326
<div className="sm:border-l border-t w-full sm:w-px sm:h-16 special-color"></div>
1427
<div className=" sm:pl-4 md:pl-8 mt-3 sm:mt-0 flex items-end">
15-
{this.contentDate(17, `มกราคม`)}
16-
{this.contentDesc(`ปิดการลงทะเบียน`, `อีก 2 วัน`)}
28+
{this.contentDate(regisEndDate.format('D'), regisEndDate.format('MMMM'))}
29+
{this.contentDesc(t('endOfRegistrationDate'), `${t('left')} ${regisEndDate.diff(now, 'days')} ${t('days')}`)}
1730
</div>
1831
</div>
1932
</div>
20-
);
33+
)
34+
:
35+
(
36+
null
37+
)
2138
}
2239

2340
contentDate = (date, month) => {
@@ -39,4 +56,4 @@ class UrgentAnnouncement extends Component {
3956
}
4057
}
4158

42-
export default UrgentAnnouncement;
59+
export default I18.withNamespaces('index')(UrgentAnnouncement);

components/profile/local-components/Enrollment.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Enrollment extends Component {
5252
return (
5353
<div className="bg-cb-grey-lighter pb-10">
5454
<div className="layout-wide">
55-
<Header english="ENROLLMENT" thai="ลงทะเบียนเข้าร่วม" englishColor="text-cb-pink" borderColor="border-cb-red" />
55+
<Header english={t('enrollmentSmallHeader')} thai={t('enrollmentBigHeader')} englishColor="text-cb-pink" borderColor="border-cb-red" />
5656
<Card>
5757
<Detail bigText="ขณะนี้ข้อมูลมีปัญหา โปรดลองใหม่อีกครั้ง" smallText="Error in retrieving information, please try again later"/>
5858
</Card>
@@ -68,7 +68,7 @@ class Enrollment extends Component {
6868
return(
6969
<div className="bg-cb-grey-lighter pb-10">
7070
<div className="layout-wide">
71-
<Header english="ENROLLMENT" thai="ลงทะเบียนเข้าร่วม" englishColor="text-cb-pink" borderColor="border-cb-red" />
71+
<Header english={t('enrollmentSmallHeader')} thai={t('enrollmentBigHeader')} englishColor="text-cb-pink" borderColor="border-cb-red" />
7272
<Card>
7373
<Detail bigText="ขณะนี้ไม่ได้อยู่ในช่วงเปิดให้ลงทะเบียน" smallText="Currently, it is not in the registration period."/>
7474
</Card>
@@ -109,7 +109,7 @@ class Enrollment extends Component {
109109
return (
110110
<div className="bg-cb-grey-lighter pb-10">
111111
<div className="layout-wide">
112-
<Header english="ENROLLMENT" thai="ลงทะเบียนเข้าร่วม" englishColor="text-cb-pink" borderColor="border-cb-red" />
112+
<Header english={t('enrollmentSmallHeader')} thai={t('enrollmentBigHeader')} englishColor="text-cb-pink" borderColor="border-cb-red" />
113113
<Card>
114114
<div className="w-full mb-8 font-cu-heading flex flex-col md:flex-row text-center md:text-left justify-between items-center">
115115
<div className="text-3xl">{commonsInfo.name}</div>

components/profile/local-components/EnrollmentHistory.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ class EnrollmentHistory extends Component {
1212
const commonsInfo = this.props.commonsInfo;
1313
const sessionInfo = this.props.sessionInfo;
1414
const content = (commonsInfo !== null) && (sessionInfo !== null) ? this.chooseContent(sessionInfo, commonsInfo) : null
15-
15+
const { t } = this.props;
16+
1617
if (commonsInfo === null) {
1718
return(
1819
<div className="bg-cb-grey-lighter pb-10">
1920
<div className="layout-wide">
20-
<Header english="ENROLLMENT" thai="ลงทะเบียนเข้าร่วม" englishColor="text-cb-pink" borderColor="border-cb-red" />
21+
<Header english={t('enrollmentHistorySmallHeader')} thai={t('enrollmentHistoryBigHeader')} englishColor="text-cb-pink" borderColor="border-cb-red" />
2122
<div className="mb-8"><Card><Detail bigText="ขณะนี้ข้อมูลมีปัญหา โปรดลองใหม่อีกครั้ง" smallText="Error in retrieving information, please try again later"/></Card></div>
2223
</div>
2324
</div>
@@ -28,7 +29,7 @@ class EnrollmentHistory extends Component {
2829
return(
2930
<div className="bg-cb-grey-lighter pb-10">
3031
<div className="layout-wide">
31-
<Header english="ENROLLMENT" thai="ลงทะเบียนเข้าร่วม" englishColor="text-cb-pink" borderColor="border-cb-red" />
32+
<Header english={t('enrollmentHistorySmallHeader')} thai={t('enrollmentHistoryBigHeader')} englishColor="text-cb-pink" borderColor="border-cb-red" />
3233
<div className="mb-8"><Card><Detail bigText="ไม่มีประวัติการเข้าร่วมกิจกรรม" smallText="No enrollment history is available"/></Card></div>
3334
</div>
3435
</div>
@@ -37,7 +38,7 @@ class EnrollmentHistory extends Component {
3738
return(
3839
<div className="bg-cb-grey-lighter">
3940
<div className="layout-wide pb-2">
40-
<Header english="ENROLLMENT HISTORY" thai="ประวัติการเข้าร่วมกิจกรรม" englishColor="text-cb-pink" borderColor="border-cb-red" />
41+
<Header english={t('enrollmentHistorySmallHeader')} thai={t('enrollmentHistoryBigHeader')} englishColor="text-cb-pink" borderColor="border-cb-red" />
4142
{content}
4243
</div>
4344
</div>
@@ -62,4 +63,4 @@ class EnrollmentHistory extends Component {
6263
}
6364
}
6465

65-
export default EnrollmentHistory;
66+
export default I18.withNamespaces('profile')(EnrollmentHistory);

components/profile/local-components/PersonalInfo.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class PersonalInfo extends Component {
1313
return (
1414
<div className="layout-wide">
1515
<div className="flex items-center justify-between">
16-
<Header english="PERSONAL INFORMATION" thai="ข้อมูลส่วนตัว" englishColor="text-cb-pink" borderColor="border-cb-red" />
16+
<Header english={t('personalInfoSmallHeader')} thai={t('personalInfoBigHeader')} englishColor="text-cb-pink" borderColor="border-cb-red" />
1717
<Link href="/u/updateInfo" prefetch>
1818
<div className="flex font-cu-heading text-sm items-center">
1919
<div className="mr-2 hidden sm:block">{t('changeUserInfo')}</div>
@@ -49,7 +49,7 @@ class PersonalInfo extends Component {
4949
}}
5050
</UserInfoConsumer>
5151
<hr className="w-full max-w-xs border border-cb-grey-border" />
52-
<Header english="MEDICAL CONDITIONS" thai="โรคประจำตัว / ประวัติการแพ้ยา" englishColor="text-cb-pink" borderColor="border-cb-red" />
52+
<Header english={t('medicalInfoSmallHeader')} thai={t('medicalInfoBigHeader')} englishColor="text-cb-pink" borderColor="border-cb-red" />
5353
<UserInfoConsumer>
5454
{({ userInfo }) => {
5555
if ((userInfo === null) || (userInfo === undefined)) {

components/shared-components/UserLogin.jsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ class UserLogin extends Component {
88
const { onSubmit, errorMessage, username, password, onChange, formValid, t} = this.props;
99
return (
1010
<div>
11-
<Header borderColor="border-cb-red" english="LOGIN" thai="เข้าสู่ระบบ" englishColor="text-cb-pink" />
12-
<div className="text-red mb-4">{errorMessage}</div>
11+
<Header borderColor="border-cb-red" english={t('userLoginTitleSmall')} thai={t('userLoginTitleBig')} englishColor="text-cb-pink" />
12+
<div className="text-red mb-4">{t(errorMessage)}</div>
1313
<form onSubmit={onSubmit}>
14-
<span className="font-cu-heading">อีเมล์</span>
14+
<span className="font-cu-heading">{t('userLogin_Email')}</span>
1515
<input autocomplete="new-username" className="bg-cb-grey-light rounded-lg mt-2 w-full h-8 mb-10 p-6" value={username} onChange={onChange} type="text" name="username" />
1616
<div className="flex justify-between">
17-
<span className="font-cu-heading">รหัสผ่าน</span>
18-
<span className="font-cu-heading font-semibold text-grey">ลืมรหัสผ่าน</span>
17+
<span className="font-cu-heading">{t('userLogin_Password')}</span>
18+
<span className="font-cu-heading font-semibold text-grey">{t('userLoginForgotPassword')}</span>
1919
</div>
2020
<input autocomplete="new-password" className="bg-cb-grey-light rounded-lg mt-2 w-full h-8 mb-10 p-6" value={password} onChange={onChange} type="password" name="password" />
2121
<div className="flex flex-row justify-between items-center">
22-
<Link href="/registerForm"><a className="no-underline"><span className="font-cu-heading text-grey underline">ลงทะเบียน</span></a></Link>
23-
<button disabled={!formValid} type="submit" className="px-10 py-3 text-white bg-cb-pink rounded-lg btn" id="confirm">เข้าสู่ระบบ</button>
22+
<Link href="/registerForm"><a className="no-underline"><span className="font-cu-heading text-grey underline">{t('userLoginRegister')}</span></a></Link>
23+
<button disabled={!formValid} type="submit" className="px-10 py-3 text-white bg-cb-pink rounded-lg btn" id="confirm">{t('userLoginLogin')}</button>
2424
</div>
2525
</form>
2626
</div>

pages/announcement.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import Footer from '@/shared-components/Footer';
55
import FacebookButton from '@/shared-components/FacebookButton';
66
import axios from 'axios';
77
import map from 'lodash/map';
8-
import moment from 'moment';
98

109
class Notice extends React.Component {
1110
constructor(props) {
@@ -16,7 +15,6 @@ class Notice extends React.Component {
1615
totalPage: this.props.numberOfPage,
1716
isButtonDisabledRight: false,
1817
isButtonDisabledLeft: true,
19-
2018
}
2119
}
2220

@@ -117,19 +115,11 @@ class Notice extends React.Component {
117115

118116
const lengthOfArray = this.state.totalPage;
119117

120-
//format date
121-
const announcementDateMoment = (props) => {
122-
let data = moment(announcementDate[props]).format('DD MMMM YYYY');
123-
return(
124-
data
125-
);
126-
}
127-
128118
//array for cards
129119
const AnnouncementCardLoop = () => {
130120
let data = [];
131121
for(let i = 0; i < lengthOfArray; i++) {
132-
data.push(<AnnouncementCard key={i} text={announcementTitle[i]} date={announcementDateMoment(i)} image={announcementImage[i]}/>);
122+
data.push(<AnnouncementCard key={i} text={announcementTitle[i]} date={announcementDate[i]} image={announcementImage[i]}/>);
133123
}
134124

135125
return data;

0 commit comments

Comments
 (0)