-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyorders.js
98 lines (71 loc) · 3.72 KB
/
Myorders.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import React, { useEffect, useState } from 'react'
export default function Myorders() {
const [orderData, setorderData] = useState({})
const fetchMyOrder = async () => {
console.log(localStorage.getItem('phoneNumber'))
await fetch("http://localhost:5000/api/myorderData", {
// credentials: 'include',
// Origin:"http://localhost:3000/login",
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body:JSON.stringify({
phoneNumber:localStorage.getItem('phoneNumber')
})
}).then(async (res) => {
let response = await res.json()
await setorderData(response)
})
// await res.map((data)=>{
// console.log(data)
// })
}
useEffect(() => {
fetchMyOrder()
}, [])
return (
<div>
<div>
</div>
<div className='container'>
<div className='row'>
{orderData !== {} ? Array(orderData).map(data => {
return (
data.orderData ?
data.orderData.order_data.slice(0).reverse().map((item) => {
return (
item.map((arrayData) => {
return (
<div >
{arrayData.order_date ? <div className='m-auto mt-5'>
{data = arrayData.order_date}
<hr />
</div> :
<div className='col-12 col-md-6 col-lg-3' >
<div className="card mt-3" style={{ width: "16rem", maxHeight: "360px" }}>
<div className="card-body">
<h5 className="card-title">{arrayData.service}</h5>
<div className='container w-100 p-0' style={{ height: "38px" }}>
<span className='m-1'>{arrayData.qty}</span>
<span className='m-1'>{data}</span>
<div className=' d-inline ms-2 h-100 w-20 fs-5' >
₹{arrayData.price}/-
</div>
</div>
</div>
</div>
</div>
}
</div>
)
})
)
}) : ""
)
}) : ""}
</div>
</div>
</div>
)
}