Skip to content

Commit

Permalink
Added validation and layout changes and search dummy
Browse files Browse the repository at this point in the history
  • Loading branch information
kirandroid committed May 29, 2019
1 parent a751121 commit 7332818
Show file tree
Hide file tree
Showing 10 changed files with 358 additions and 100 deletions.
6 changes: 3 additions & 3 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class App extends React.Component {
const adminPanes = [
{
menuItem: 'Home',
render: () => <Home />
render: () => <Home role={this.state.role} />
},
{ menuItem: 'Event', render: () => <Event role={this.state.role} /> },
{ menuItem: 'All Bookings', render: () => <Booking role={this.state.role} /> },
Expand All @@ -94,7 +94,7 @@ export default class App extends React.Component {
const user = [
{
menuItem: 'Home',
render: () => <Home />
render: () => <Home role={this.state.role} />
},
{ menuItem: 'Event', render: () => <Event role={this.state.role} userId={this.state.userId} /> },
{ menuItem: 'My Bookings', render: () => <Booking role={this.state.role} userId={this.state.userId} /> },
Expand Down Expand Up @@ -127,7 +127,7 @@ export default class App extends React.Component {
const guest = [
{
menuItem: 'Home',
render: () => <Home />
render: () => <Home role={this.state.role} />
},
{ menuItem: 'Event', render: () => <Event role={this.state.role} /> },
{ menuItem: 'Activities', render: () => <Activities role={this.state.role} /> },
Expand Down
42 changes: 23 additions & 19 deletions src/layouts/body/tabs/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ export default class Home extends Component {
home_slider: [],
test: [
{
IMAGE: 'https://patancollege.edu.np/wp-content/uploads/2019/05/sports-day-00040.jpg'
IMAGE:
'https://pic.001all.com/Wallpaper/Desktop%20Wallpaper/Sports/FTP/1366%20x%20768/College%20basketball%20hot%20wallpapers%201366%20x%20768%20Pixels%20Resolution.jpg'
},
{
IMAGE: 'https://patancollege.edu.np/wp-content/uploads/2019/05/sports-day-00022.jpg'
IMAGE:
'https://patancollege.https://live-beds-uni-cdnep.azureedge.net/live-beds-uni-media/266390/breeam-thumbnail.jpg.np/wp-content/uploads/2019/05/sports-day-00022.jpg'
},
{
IMAGE: 'https://patancollege.edu.np/wp-content/uploads/2019/05/sports-day-00083.jpg'
IMAGE: 'https://patancollege.edu.np/wp-content/uploads/2018/07/image055.jpg'
},
{
IMAGE: 'https://patancollege.edu.np/wp-content/uploads/2018/05/IMG-20180411-WA0017.jpg'
IMAGE: 'https://images6.alphacoders.com/427/thumb-1920-427408.jpg'
},
{
IMAGE: 'https://patancollege.edu.np/wp-content/uploads/2019/04/PCPS-SW19-BB-00012.jpg'
Expand Down Expand Up @@ -117,21 +119,23 @@ export default class Home extends Component {
<Typography variant="h5" component="h2">
News And Notice
</Typography>
<AddNewsNoticeModal
trigger={
<Button
type="submit"
variant="contained"
color="primary"
style={{ marginRight: '10px' }}
onClick={() => {
console.log('YOYOYOY');
}}
>
Add Item
</Button>
}
/>
{this.props.role == 'Admin' ? (
<AddNewsNoticeModal
trigger={
<Button
type="submit"
variant="contained"
color="primary"
style={{ marginRight: '10px' }}
onClick={() => {
console.log('YOYOYOY');
}}
>
Add Item
</Button>
}
/>
) : null}
</Grid>
</div>
<Grid item xs={12}>
Expand Down
3 changes: 2 additions & 1 deletion src/layouts/component/Item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import CardContent from '@material-ui/core/CardContent';
import Button from '@material-ui/core/Button';
import NoticeModal from '../component/noticeModal';
import moment from 'moment';
import LinesEllipsis from 'react-lines-ellipsis';

export default ({ title, desc, created, type, onClick }) => (
<Card
Expand All @@ -30,7 +31,7 @@ export default ({ title, desc, created, type, onClick }) => (
{moment(created).fromNow()}
</Typography>
<Typography variant="body2" component="p">
{desc}
<LinesEllipsis text={desc} maxLine="4" ellipsis="..." trimRight basedOn="letters" />
</Typography>
</CardContent>
<CardActions>
Expand Down
105 changes: 88 additions & 17 deletions src/layouts/component/addActivityModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ export default class AddActivityModal extends React.Component {
activityImage: '',
activityType: '',
file: '',
imagePreviewUrl: ''
imagePreviewUrl: '',
activityDescriptionError: false,
activityNameError: false,
activityImageError: false,
activityTypeError: false,
fileError: false
};
this._handleImageChange = this._handleImageChange.bind(this);
}
Expand Down Expand Up @@ -87,6 +92,12 @@ export default class AddActivityModal extends React.Component {
activityName: e.target.value,
changed: true
})}
error={this.state.activityNameError == true ? true : false}
helperText={
this.state.activityNameError == true ? (
'Activity Name is invalid or already used'
) : null
}
label="Activity Name"
margin="normal"
variant="outlined"
Expand All @@ -99,6 +110,12 @@ export default class AddActivityModal extends React.Component {
activityDescription: e.target.value,
changed: true
})}
error={this.state.activityDescriptionError == true ? true : false}
helperText={
this.state.activityDescriptionError == true ? (
'Description is invalid or already used'
) : null
}
multiline
rowsMax="4"
label="Activity Description"
Expand All @@ -115,6 +132,12 @@ export default class AddActivityModal extends React.Component {
activityType: e.target.value,
changed: true
})}
error={this.state.activityTypeError == true ? true : false}
helperText={
this.state.activityTypeError == true ? (
'Type is invalid or already used'
) : null
}
row
>
<FormControlLabel value="SPORTS" control={<Radio />} label="Sports" />
Expand Down Expand Up @@ -145,24 +168,72 @@ export default class AddActivityModal extends React.Component {
primary
disabled={this.state.changed ? false : true}
onClick={() => {
var bodyFormData = new FormData();
bodyFormData.append('imageFile', this.state.file);
bodyFormData.append('ACT_NAME', this.state.activityName);
bodyFormData.append('ACT_DESCRIPTION', this.state.activityDescription);
bodyFormData.append('ACT_TYPE', this.state.activityType);
if (this.state.activityDescription == '') {
this.setState({
activityDescriptionError: true
});
} else {
this.setState({
activityDescriptionError: false
});
}
if (this.state.activityName == '') {
this.setState({
activityNameError: true
});
} else {
this.setState({
activityNameError: false
});
}
if (this.state.activityType == '') {
this.setState({
activityTypeError: true
});
} else {
this.setState({
activityTypeError: false
});
}
if (this.state.file == '') {
this.setState({
fileError: true
});
alert('Image file Empty');
} else {
this.setState({
fileError: false
});
}

axios({
method: 'post',
url: apiurl + '/api/addactivity',
data: bodyFormData,
config: { headers: { 'Content-Type': 'multipart/form-data' } }
})
.then(function(response) {
console.log(response);
if (
this.state.activityDescriptionError == false &&
this.state.activityNameError == false &&
this.state.activityTypeError == false &&
this.state.fileError == false
) {
var bodyFormData = new FormData();
bodyFormData.append('imageFile', this.state.file);
bodyFormData.append('ACT_NAME', this.state.activityName);
bodyFormData.append('ACT_DESCRIPTION', this.state.activityDescription);
bodyFormData.append('ACT_TYPE', this.state.activityType);

axios({
method: 'post',
url: apiurl + '/api/addactivity',
data: bodyFormData,
config: { headers: { 'Content-Type': 'multipart/form-data' } }
})
.catch(function(response) {
console.log(response);
});
.then(function(response) {
alert('Success!');
console.log(response);
})
.catch(function(response) {
console.log(response);
});
} else {
alert('Something went wrong!');
}
}}
/>
</div>
Expand Down
17 changes: 11 additions & 6 deletions src/layouts/component/addEventModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export default class AddEventModal extends React.Component {
eventStatus: "",
eventEndDate: Date.now(),
file: "",
imagePreviewUrl: ""
imagePreviewUrl: "",
eventButton: "Add Event"
};
this._handleImageChange = this._handleImageChange.bind(this);
}
Expand Down Expand Up @@ -218,7 +219,7 @@ export default class AddEventModal extends React.Component {
}}
>
<Button
content="Add Event"
content={this.state.eventButton}
primary
onClick={() => {
var bodyFormData = new FormData();
Expand All @@ -240,11 +241,15 @@ export default class AddEventModal extends React.Component {
data: bodyFormData,
config: { headers: { "Content-Type": "multipart/form-data" } }
})
.then(function(response) {
console.log(response);
.then(res => {
this.setState({
eventButton : "LOADING"
})
})
.catch(function(response) {
console.log(response);
.catch(res => {
this.setState({
eventButton : "ERROR"
})
});
}}
/>
Expand Down
17 changes: 14 additions & 3 deletions src/layouts/component/authModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export default class AuthModal extends React.Component {
showPassword: false,
changed: false,
usernameError: false,
passwordError: false
passwordError: false,
loginButton: 'Login'
};
}

Expand Down Expand Up @@ -122,6 +123,9 @@ export default class AuthModal extends React.Component {
style={{ marginRight: "10px" }}
disabled={this.state.changed ? false : true}
onClick={() => {
this.setState({
loginButton: "LOADING"
})
axios
.post(apiurl + "/api/login", {
STUDENT_ID: this.state.username,
Expand Down Expand Up @@ -156,20 +160,27 @@ export default class AuthModal extends React.Component {
console.log("Status 204");
this.setState({
usernameError: true,
passwordError: true
passwordError: true,
loginButton: "ERROR"
});
<Confirm content="Incorrent Student ID or Password!" />;
} else {
this.setState({
loginButton: "ERROR"
});
console.log("Other");
<Confirm content="Student ID Doesnot Exist!" />;
}
})
.catch(error => {
this.setState({
loginButton: "ERROR"
});
console.log(error);
});
}}
>
Login
{this.state.loginButton}
</Button>

<SignUpModal
Expand Down
33 changes: 28 additions & 5 deletions src/layouts/component/header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import UserAvatar from 'react-user-avatar';
import { Dropdown, Image } from 'semantic-ui-react';
import LoadingModal from '../component/loadingModal';
import AuthModal from '../component/authModal';
import SearchModal from '../component/searchModal';

import Pouchdb from 'pouchdb-browser';
var userdb = Pouchdb('user');
Expand Down Expand Up @@ -48,23 +49,45 @@ const style = {
};

export default class Header extends React.Component {
constructor(props) {
super(props);
this.state = {
title: ''
};
}
render() {
return (
<div>
<AppBar position="static" color="#fff" style={{ elevation: 0 }}>
<Toolbar>
<Grid container direction="row" justify="space-between" alignItems="center">
<Typography variant="h6" color="inherit" style={style.logo}>
{/* <Typography variant="h6" color="inherit" style={style.logo}>
KIOSK
</Typography>
</Typography> */}
<div>
<Image
src="https://lh3.googleusercontent.com/1_Hzer-EW36Y0gfOdhpWwIgyusDEcFocH3f4GWiFJaPxCqrZl3x4udSZFf8nXgOb425fvA96eEt0AgyE5bo9vA=s0"
size="small"
centered
/>
</div>
<Paper style={style.root} elevation={1}>
<InputBase
onChange={(e) =>
this.setState({
title: e.target.value
})}
style={style.input}
placeholder="Search for some awesome Events and Programmes!!"
/>
<IconButton style={style.iconButton} aria-label="Search">
<Search />
</IconButton>
<SearchModal
searchTitle={this.state.title}
trigger={
<IconButton style={style.iconButton} aria-label="Search" onClick={() => {}}>
<Search />
</IconButton>
}
/>
</Paper>

<Dropdown
Expand Down
Loading

0 comments on commit 7332818

Please sign in to comment.