reymesson1 / septimoejercicio

1 stars 0 forks source link

Create Quotation #66

Closed reymesson1 closed 5 years ago

reymesson1 commented 5 years ago

class Quotation extends React.Component{

    constructor(){

        super();
        this.state = {

            showModal: false,
            inputText: '',
            masterAPI: [],
            parameter: ''
        }
    }

    componentDidMount(){

            fetch(API_URL+'/quotation', {

                method: 'post',
                headers: API_HEADERS,
                body: JSON.stringify({"id":this.props.params.quotationid })
            })
            .then((response)=>response.json())
            .then((responseData)=>{
                this.setState({

                    masterAPI: responseData
                })
            })

            this.setState({
                parameter: this.props.params.quotationid                
        })

    }

    render(){

        let nextState = this.state.masterAPI;

        let obj = nextState[0];

        let name;

        if(obj){

                        name = obj.name.toUpperCase();
        }

        return(
            <div>
                <Grid>
                    <Row>   
                        <Col md={6}>                     
                        <Panel>      
                            <Col xs={2}>
                                <h5 style={{'font-weight':'bold'}}>Name: </h5>                                
                            </Col>
                            <Col xs={10}>
                                <h5>{name}</h5>
                            </Col>                                
                            <Col xs={2}>
                                <h5 style={{'font-weight':'bold'}}>Address: </h5>                                
                            </Col>
                            <Col xs={10}>
                                <h5>{name}</h5>
                            </Col>                                
                            <Col xs={2}>
                                <h5 style={{'font-weight':'bold'}}>Phone:</h5>                                
                            </Col>
                            <Col xs={10}>
                                <h5>{name}</h5>
                            </Col>                                
                            <Col xs={2}>
                                <h5 style={{'font-weight':'bold'}}>RNC: </h5>                                
                            </Col>
                            <Col xs={10}>
                                <h5>{name}</h5>
                            </Col>                                
                            <Col xs={2}>
                                <h5 style={{'font-weight':'bold'}}>Email: </h5>                                
                            </Col>
                            <Col xs={10}>
                                <h5>{name}</h5>
                            </Col>                                                                
                        </Panel>
                        </Col>                     
                        <Col md={6}>                     
                        <Panel>
                            <h5 style={{'font-weight':'bold'}}>Quote-Id: </h5>
                            <h5 style={{'font-weight':'bold'}}>Date: </h5>
                            <h5 style={{'font-weight':'bold'}}>Valid-Date: </h5>
                        </Panel>
                        </Col>                     
                    </Row>                    
                    <Row>                    
                    <Table striped bordered condensed hover>
                    <thead>
                        <tr>
                        <th>#</th>
                        <th>Description</th>
                        <th>Quantity</th>
                        <th>Unit</th>
                        <th>Price</th>
                        <th>Amount</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                        <td>1</td>
                        <td>Mark</td>
                        <td>Otto</td>
                        <td>@mdo</td>
                        <td>@mdo</td>
                        <td>@mdo</td>
                        </tr>
                        <tr>
                        <td>2</td>
                        <td>Jacob</td>
                        <td>Thornton</td>
                        <td>@fat</td>
                        <td>@fat</td>
                        <td>@fat</td>
                        </tr>
                        <tr>
                        <td>3</td>                            
                        <td>Jacob</td>
                        <td>Thornton</td>
                        <td>@fat</td>
                        <td>@fat</td>
                        <td>@fat</td>                            
                        </tr>
                    </tbody>
                    </Table>                        
                    </Row>                    
                    <Row>      
                        <Col md={6}>                                              
                        </Col>
                        <Col md={6}>              
                            <Panel>
                                <h5 style={{'font-weight':'bold'}}>Sub-Total</h5>
                                <h5 style={{'font-weight':'bold'}}>Imp</h5>
                                <h5 style={{'font-weight':'bold'}}>Total</h5>
                            </Panel>
                        </Col>
                    </Row>                                                                                                             
                </Grid>
            </div>
        );
    }

}

reymesson1 commented 5 years ago

app.post('/quotation', masterController.masterQuotation)

reymesson1 commented 5 years ago

exports.masterQuotation = async(req,res)=>{

var id = req.body.id;

var master = await Master.find({"id":id})

res.send(master);

}

reymesson1 commented 5 years ago
reymesson1 commented 5 years ago

class QuotationPanel extends React.Component{

render(){

    let nextState = this.props.masterAPI;

    let obj = nextState[0];

    console.log(obj)

    return(
        <div>
           <h5 style={{'font-weight':'bold'}}>Name: {obj}</h5>
            <h5 style={{'font-weight':'bold'}}>Address: </h5>
            <h5 style={{'font-weight':'bold'}}>Phone Number: </h5>
            <h5 style={{'font-weight':'bold'}}>RNC: </h5>
            <h5 style={{'font-weight':'bold'}}>Email: </h5>
        </div>
    )

}

}