Skip to content

Commit

Permalink
Business catogery is done and stop for the presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
yapa-ymtl committed Nov 5, 2020
1 parent 4b639b4 commit 1653cf6
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 28 deletions.
1 change: 1 addition & 0 deletions debug.log
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
[1102/203206.196:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1104/123506.087:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1104/212931.404:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1105/012142.129:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
55 changes: 37 additions & 18 deletions src/components/BusinessAppointmentCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ export default class BusinessAppointmentCard extends Component {

}

appointmentFinished=()=>{
var dateDirect=this.props.date.getFullYear()+'/'+(this.props.date.getMonth()+1)+'/'+this.props.date.getDate();
var userId = firebase.auth().currentUser.uid;
firebase.database().ref('Appointments/'+userId+'/'+dateDirect+'/'+this.props.service.key).update({
crntState:"done",
});

firebase.database().ref('Appointments/'+this.props.service.userId+'/'+dateDirect+'/'+this.props.service.key).update({
crntState:"done",
});
this.props.fromChild(this.props.service.number);
}

render() {
let addCancleModelClose=()=>this.setState({addCancleModelShow:false});
if(typeof this.props.service !== 'undefined')
Expand All @@ -49,7 +62,7 @@ export default class BusinessAppointmentCard extends Component {
this.props.service.crntState==="done"?
(
<Card body outline color="success">
<CardTitle><Badge>{this.props.service.number}</Badge><b>{this.props.service.title}</b></CardTitle>
<CardTitle><b>{this.props.service.title}</b></CardTitle>
<CardText>
<Row>
<Col sm="10" xs="12">
Expand All @@ -64,23 +77,29 @@ export default class BusinessAppointmentCard extends Component {
)
:
(
<Card body outline color="info">
<CardTitle><Badge size="lg">{this.props.service.number}</Badge><b> {this.props.service.title}</b></CardTitle>
<CardText>
<Row>
<Col sm="8" xs="12">
{this.props.service.description}
</Col>
<Col sm="2" xs="6">
<MDBBtn size="sm" color="success" >Finished</MDBBtn>
</Col>
<Col sm="2" xs="6">
<MDBBtn size="sm" color="danger" onClick={()=>this.setState({addCancleModelShow:true,isOpen: false})} >Remove</MDBBtn>
<CancleModal show={this.state.addCancleModelShow} onHide={addCancleModelClose} fromChild={this.recieveChildValue}/>
</Col>
</Row>
</CardText>
</Card>
this.props.service.crntState==="to be"?
(
<Card body outline color="info">
<CardTitle><Badge size="lg">{this.props.service.number}</Badge><b> {this.props.service.title}</b></CardTitle>
<CardText>
<Row>
<Col sm="8" xs="12">
{this.props.service.description}
</Col>
<Col sm="2" xs="6">
<MDBBtn size="sm" style={{color:"white"}} onClick={this.appointmentFinished} >Finished</MDBBtn>
</Col>
<Col sm="2" xs="6">
<MDBBtn size="sm" color="danger" onClick={()=>this.setState({addCancleModelShow:true,isOpen: false})} >Remove</MDBBtn>
<CancleModal show={this.state.addCancleModelShow} onHide={addCancleModelClose} fromChild={this.recieveChildValue}/>
</Col>
</Row>
</CardText>
</Card>
):
(
<></>
)
)

)
Expand Down
13 changes: 12 additions & 1 deletion src/components/ClientAppointmentCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@ export default class ClientAppointmentCard extends Component {

this.state = {
addCancleModelShow:false,
businessName:null,
}
}

componentWillMount()
{
firebase.database().ref('Users/' + this.props.service.businessId).once('value').then((snapshot)=> {
this.setState({
businessName:snapshot.val().username,
})
});
}

recieveChildValue=(e)=>{
if(e==1)
{
Expand All @@ -32,6 +42,7 @@ export default class ClientAppointmentCard extends Component {

}


render() {
let addCancleModelClose=()=>this.setState({addCancleModelShow:false});
if(typeof this.props.service !== 'undefined')
Expand Down Expand Up @@ -78,7 +89,7 @@ export default class ClientAppointmentCard extends Component {
:
(
<Card body outline color="info">
<CardTitle><Badge>{this.props.service.number}</Badge><b> {this.props.service.title}</b></CardTitle>
<CardTitle><Badge style={{fontSize:23}}>{this.props.service.number}</Badge><b style={{fontSize:20}}> {this.props.service.title}</b><i style={{fontSize:13}}> at {this.state.businessName}</i></CardTitle>
<CardText>
<Row>
<Col sm="10" xs="12">
Expand Down
89 changes: 80 additions & 9 deletions src/components/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react';
import {MDBBtn,MDBIcon} from "mdbreact";
import {Spinner} from 'reactstrap'
import firebase, { database } from 'firebase'
import Select from 'react-select';

import BusinessCard from './homePage/appointmentCard'
import Card from './homePage/card'
Expand All @@ -21,6 +22,7 @@ class Home extends Component {
loading:true,
noAppointment:false,
noBusiness:false,
business_type:null,
}
}

Expand Down Expand Up @@ -90,14 +92,65 @@ class Home extends Component {
}
}

handleSelect=(e)=>{

var ref = firebase.database().ref('Users/');
var data_array=[];
ref.on("value", (data)=> {
var data_list= data.val();
if(data_list)
{
var keys=Object.keys(data_list);

var j=0;
for(var i=0;i<keys.length;i++)
{
if(e.value===null)
{
if(data_list[keys[i]].type!="client")
{
data_array[j]=data_list[keys[i]];
data_array[j].key=keys[i];
j++;
}
}
else if(data_list[keys[i]].businessTypes===e.value)
{
data_array[j]=data_list[keys[i]];
data_array[j].key=keys[i];
j++;
}
}
this.setState({
serviceList:data_array,
loading:false,
})
}
else
{
this.setState({
noBusiness:true,
})
}
}, function (error) {
console.log("Error: " + error.code);
});
}


render() {

const services=this.state.serviceList.map(service=><Card service={service}/>);
const apponointments=this.state.serviceList.map(service=><BusinessCard service={service}/>);
/* for(var x in services)
{
console.log("X>>"+x+" "+ services[x].email);
} */

const businessTypes = [
{label:"None",value:null},
{label:"Medical Center",value:"Medical Center"},
{label:"Saloon",value:"Saloon"},
{label:"Shop",value:"Shop"},
{label:"Other",value:"Other"},
];

let styleParagraph={
color:'black',
fontSize:20,
Expand All @@ -110,7 +163,7 @@ class Home extends Component {
<div class="py-5"style={{backgroundColor:'rgba(253,237,236,0.7)',borderRadius:10} }>
<h2 className="card-title h2 my-4 py-2" style={{color:'black'}}>Why are you wasting time in a queue?</h2>
<p className="mb-4 pb-2 px-md-5 mx-md-5" style={styleParagraph}>Make an appointment easily from the world best appointment website. It will make your job easier</p>
<MDBBtn rounded size="lg" className="btn "gradient="aqua"><MDBIcon icon="plus" className="ml-2" /> Make an appointment</MDBBtn>
<MDBBtn rounded size="lg" className="btn "gradient="aqua"><MDBIcon icon="plus" className="ml-2" onclick={this.makeAppointment} /> Make an appointment</MDBBtn>
</div>
</div>
</div>
Expand All @@ -119,12 +172,30 @@ class Home extends Component {
{
this.props.authenticated==="business"?
(
this.state.noAppointment?<div >No appointments today </div>:
<div>{apponointments}</div>
<div>
{this.state.noAppointment?<h2 >No appointments today </h2>:{apponointments}}
</div>
):
(
this.state.noBusiness?<div>No registered businesses</div>:
<div>{services}</div>
<>
<div className="row">
<div className="col-md-3 col-sm-2"></div>
<div className="col-md-6 col-sm-8">
<label htmlFor="defaultFormRegisterNameEx" className="grey-text">
Business type
</label>
<Select
onChange={this.handleSelect}
options={ businessTypes }
autoFocus={true}
/>
</div>
<div className="col-md-3 col-sm-2"></div>
</div>
{
this.state.noBusiness?<div>No registered businesses</div>:<div>{services}</div>
}
</>
)
}

Expand Down

0 comments on commit 1653cf6

Please sign in to comment.