@@ -4,14 +4,15 @@ import { getSession, useSession } from "next-auth/client";
4
4
import moment from "moment" ;
5
5
import db from "../firebase" ;
6
6
import { doc , getDocs , collection } from "firebase/firestore" ;
7
+ import Order from "../components/Order" ;
7
8
function Orders ( { orders } ) {
8
9
// const { data: session } = useSession();
9
10
const [ session ] = useSession ( ) ;
10
11
console . log ( orders ) ;
11
12
return (
12
13
< >
13
14
< Header />
14
- < div className = "bg-gray-100 h-screen mt-28" >
15
+ < div className = "bg-gray-100 min- h-screen mt-28" >
15
16
< Head >
16
17
< title > Orders</ title >
17
18
</ Head >
@@ -28,7 +29,7 @@ function Orders({ orders }) {
28
29
< h2 > { orders ?. length } Orders</ h2 >
29
30
30
31
< div className = "mt-5 space-y-4" >
31
- { /* { orders?.map(
32
+ { orders ?. map (
32
33
( { id, amount, amountShipping, items, timestamp, images } ) => (
33
34
< Order
34
35
key = { id }
@@ -40,7 +41,7 @@ function Orders({ orders }) {
40
41
images = { images }
41
42
/>
42
43
)
43
- )} */ }
44
+ ) }
44
45
</ div >
45
46
</ main >
46
47
</ div >
@@ -83,37 +84,3 @@ export async function getServerSideProps(context) {
83
84
} ,
84
85
} ;
85
86
}
86
-
87
- // Firebase db
88
- // const docRef = doc(db, "users", session.user.email, );
89
- // const stripeOrders = await getDoc(docRef);
90
- // console.log(docSnap);
91
- // const stripeOrders = await db
92
- // .collection("users")
93
- // .doc(session.user.email)
94
- // .collection("orders")
95
- // .orderBy("timestamp", "desc")
96
- // .get();
97
-
98
- // const colRef = collection(db, "users");
99
- // const docsSnap = await getDocs(colRef);
100
- // Stripe orders
101
- // const orders = await Promise.all(
102
- // // map through each order and get the data
103
- // // each one would be a promise. so Promise.all will wait
104
- // //for all of them to resolve
105
- // stripeOrders.docs.map(async (order) => ({
106
- // id: order.id,
107
- // amount: order.data().amount, // / 100,
108
- // //amountShipping: order.data().amount_shipping / 100,
109
- // images: order.data().images,
110
- // // get the timestamp from firebase and convert it to a date object
111
- // // so we can format it
112
- // timestamp: moment(order.data().timestamp.toDate()).unix(),
113
- // items: (
114
- // await stripe.checkout.sessions.listLineItems(order.id, {
115
- // limit: 100,
116
- // })
117
- // ).data,
118
- // }))
119
- // );
0 commit comments