Skip to content

Commit

Permalink
Added student id insert, fixed guest booking bug, fixed some layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
kirandroid committed May 29, 2019
1 parent 7332818 commit 4b8e74f
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 198 deletions.
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default class App extends React.Component {
{ menuItem: 'All Bookings', render: () => <Booking role={this.state.role} /> },
{ menuItem: 'Activities', render: () => <Activities role={this.state.role} /> },
{ menuItem: 'Services', render: () => <Services role={this.state.role} /> },
{ menuItem: 'User', render: () => <User /> }
{ menuItem: 'User', render: () => <User role={this.state.role} /> }
];

const user = [
Expand Down
45 changes: 6 additions & 39 deletions src/layouts/body/tabs/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ export default class Home extends Component {
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.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/2018/07/image055.jpg'
},
Expand All @@ -36,35 +32,16 @@ export default class Home extends Component {
},
{
IMAGE: 'https://patancollege.edu.np/wp-content/uploads/2018/12/image00007.jpeg'
},
{
IMAGE:
'https://images.unsplash.com/photo-1474650919751-b7e21a1b180f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80'
}
]
};
this.fetchData();
}

// componentWillReceiveProps(newprops) {
// if (newprops) {
// this.fetchData();
// console.log('Fetched');
// } else {
// console.log('Not');
// }
// }

// componentDidMount() {
// this.fetchData();
// axios
// .get(apiurl + `/api/newsnotice`)
// .then((res) => {
// const newsNotices = res.data;
// console.log(res.data);
// this.setState({ newsNotices });
// })
// .catch((err) => {
// console.log(err);
// });
// }

fetchData() {
axios.get(apiurl + `/api/newsnotice`).then((res) => {
const newsNotices = res.data;
Expand Down Expand Up @@ -96,22 +73,12 @@ export default class Home extends Component {
flex: 1,
width: null,
height: 400,
objectFit: 'cover'
objectFit: 'cover',
paddingRight: 10
}}
src={slider.IMAGE}
/>
))}
{/* {this.state.home_slider.map((slider_img) => (
<img
style={{
flex: 1,
width: 1000,
height: 300,
objectFit: 'cover'
}}
src={slider_img.IMAGE}
/>
))} */}
</Flickity>
</Grid>
<div style={{ padding: 10 }}>
Expand Down
21 changes: 19 additions & 2 deletions src/layouts/body/tabs/admin/User.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { Component } from 'react';
import axios from 'axios';
// import { users } from "../../../../store/data";
import UserCard from '../../../component/userCard';
import { Grid, Paper, CircularProgress } from '@material-ui/core';
import { Grid, Paper, CircularProgress, Button } from '@material-ui/core';
import { apiurl } from '../../../../store/data';
import AddStudentIDModal from '../../../component/AddStudentIDModal';

export default class User extends Component {
constructor(props) {
Expand All @@ -23,6 +23,23 @@ export default class User extends Component {
render() {
return (
<div style={{ flexGrow: 1, padding: 10 }}>
{this.props.role == 'Admin' ? (
<AddStudentIDModal
trigger={
<Button
type="submit"
variant="contained"
color="primary"
style={{ marginRight: '10px' }}
onClick={() => {
console.log('YOYOYOY');
}}
>
Add Student ID
</Button>
}
/>
) : null}
<Grid container>
{this.state.users.map((user) => (
<Grid item xs={3} style={{ padding: 5 }} key={user.ID}>
Expand Down
81 changes: 81 additions & 0 deletions src/layouts/component/AddStudentIDModal.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import React from 'react';
import { Image, Modal, Grid, Button } from 'semantic-ui-react';
import { TextField, FormLabel, FormControlLabel, RadioGroup, Radio } from '@material-ui/core';
import axios from 'axios';
import { apiurl } from '../../store/data';

export default class AddStudentIDModal extends React.Component {
constructor(props) {
super(props);
this.state = {
studentID: 1,
addButton: 'Add ID'
};
}

render() {
return (
<Modal trigger={this.props.trigger} size="small">
<Modal.Header>
<div
style={{
display: 'flex',
justifyContent: 'center'
}}
>
<h3>Add Student ID</h3>
</div>
</Modal.Header>
<Modal.Content>
<Grid columns={1} stretched={true}>
<Grid.Row>
<Grid.Column>
<TextField
label="Student ID"
fullWidth
margin="normal"
onChange={(e) =>
this.setState({
studentID: e.target.value
})}
variant="outlined"
/>
</Grid.Column>
</Grid.Row>
</Grid>
</Modal.Content>
<Modal.Actions>
<div
style={{
display: 'flex',
justifyContent: 'center'
}}
>
<Button
content={this.state.addButton}
primary
onClick={() => {
axios
.post(apiurl + '/api/addstudentid', {
STUDENT_ID: this.state.studentID
})
.then((response) => {
this.setState({
addButton: 'LOADING'
});
console.log(response);
})
.catch((error) => {
this.setState({
addButton: 'ERROR'
});
console.log(error);
});
}}
/>
</div>
</Modal.Actions>
</Modal>
);
}
}
Loading

0 comments on commit 4b8e74f

Please sign in to comment.