-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shipping info #51
Merged
Merged
Shipping info #51
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
046b962
add success message page
someyaaltous 86dac15
added shipping info page
someyaaltous 9a0e480
delete success massage
someyaaltous 596afa3
Revert "delete success massage"
someyaaltous 3ba07cd
change file shiiping_info from function to class
someyaaltous 19a3833
change file shiiping_info from function to class
someyaaltous 2135e53
deleted success_massage file
someyaaltous 5ef7ce5
added shipping info in App.js
someyaaltous f9b559c
solve conflicts
someyaaltous ad6243f
FE shipping info
someyaaltous efd15b9
delete consol.log
someyaaltous 13e41b5
fix conflict
someyaaltous f30d80b
solve comments
someyaaltous 071a289
solve comment
someyaaltous 00d3761
solve comment
someyaaltous c3b0f8c
solve comment
someyaaltous 3d3af72
solve comment
someyaaltous 8c9d23e
solve comment
someyaaltous 5cb0b5d
solve comment
someyaaltous ca1088c
solve comment
someyaaltous 7cb8a53
solve comment
someyaaltous a050c31
solve comment
someyaaltous File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import React, { Component } from "react"; | ||
import "./style.css"; | ||
import swal from "sweetalert"; | ||
import NavBar from "../Navbar"; | ||
import axios from "axios"; | ||
|
||
class shippingInfo extends Component { | ||
state = { | ||
username: "", | ||
phone: "", | ||
Address: "", | ||
Extra_Note: "" | ||
}; | ||
|
||
changeInput = ({ target: { value, name } }) => { | ||
this.setState({ [name]: value }); | ||
}; | ||
|
||
handleSubmit = event => { | ||
event.preventDefault(); | ||
const { username, phone, Address, Extra_Note } = this.state; | ||
|
||
axios | ||
.post("/shipping_info", { username, phone, Address, Extra_Note }) | ||
.then(res => { | ||
if (res.data) { | ||
swal({ | ||
title: | ||
"Your Order is processed Contact us on phone No : 0598121490", | ||
icon: "success", | ||
button: "Home!" | ||
}).then(function() { | ||
window.location.href = "/"; | ||
}); | ||
} | ||
}); | ||
}; | ||
|
||
render() { | ||
const { username, phone, Address, Extra_Note } = this.state; | ||
return ( | ||
<div> | ||
<NavBar /> | ||
|
||
<h1>Shipping info</h1> | ||
<form className="flex-container" onSubmit={this.handleSubmit}> | ||
<label for="username"></label> | ||
<input | ||
type="text" | ||
placeholder="Name" | ||
name="username" | ||
onChange={this.changeInput} | ||
value={username} | ||
required | ||
></input> | ||
<label for="phone"></label> | ||
<input | ||
type="tel" | ||
name="phone" | ||
placeholder="Phone 059-123-1234" | ||
onChange={this.changeInput} | ||
pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" | ||
value={phone} | ||
required | ||
></input> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the validation for this |
||
|
||
<label for="Address"></label> | ||
<input | ||
type="text" | ||
placeholder="Address" | ||
name="Address" | ||
onChange={this.changeInput} | ||
value={Address} | ||
required | ||
></input> | ||
<label for="Extra Note"></label> | ||
<input | ||
type="text" | ||
placeholder="Extra Note" | ||
name="Extra_Note" | ||
onChange={this.changeInput} | ||
value={Extra_Note} | ||
></input> | ||
<button type="submit" className="confirm"> | ||
Confirm | ||
</button> | ||
</form> | ||
</div> | ||
); | ||
} | ||
} | ||
export default shippingInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.flex-container { | ||
display: flex; | ||
flex-direction: column; | ||
border: 1px #000000; | ||
} | ||
.flex-container input[type="text"] { | ||
border: 0px; | ||
border-bottom: solid 1px; | ||
width: 95%; | ||
margin: 6% auto 6% auto; | ||
font-size: 1.2em; | ||
} | ||
.confirm { | ||
text-align: center; | ||
align-items: center; | ||
width: 193px; | ||
height: 63px; | ||
background-color: #50bb00; | ||
border-radius: 5px; | ||
border: 0px; | ||
color: white; | ||
margin: 20% 50% auto 24%; | ||
font-size: 1.2em | ||
} | ||
.flex-container input[type="tel"] { | ||
border: 0px; | ||
border-bottom: solid 1px; | ||
width: 95%; | ||
margin: 6% auto 6% auto; | ||
font-size: 1.2em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const postOrder = require('../database/queries/post_order') | ||
|
||
const addOrder = (req, res) => { | ||
const { username, phone, Address, Extra_Note, orderID = 3 } = req.body | ||
// The orderID will be token from the cookie after making the login page | ||
|
||
postOrder(username, phone, Address, Extra_Note, orderID) | ||
.then(() => res.status(200).json({ res: 'success true' })) | ||
.catch(err => err.status(500).json({ err: 'error for post shipping info' })) | ||
} | ||
module.exports = addOrder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
const getProduct = require('../database/queries/getAllProduct.js') | ||
|
||
exports.getAllProduct = (request, response) => { | ||
getProduct().then(result => response.json(result)).catch(err => response.json(err)) | ||
} | ||
getProduct().then(result => response.json(result)).catch(err => response.json(err)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const dbConnection = require('../db_connection') | ||
|
||
const postOrder = (name, address, phone, note, ID) => { | ||
return dbConnection | ||
.query( | ||
'UPDATE "order" SET name=$1,address=$2,phone=$3,note=$4 WHERE ID=$5', | ||
[name, address, phone, note, ID] | ||
) | ||
.then(res => res.rows) | ||
|
||
.catch(err => err) | ||
} | ||
module.exports = postOrder |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Sweet alert confirmation message will appear here even the form didn't send the data to the backend.
you should check first if the form data is already sent to the backend after that let the sweet alert message appear.