diff --git a/assets/js/user-history.js b/assets/js/user-history.js new file mode 100644 index 0000000..26985f7 --- /dev/null +++ b/assets/js/user-history.js @@ -0,0 +1,177 @@ +async function postProductRating(product_id, formData,endpointData,sessionToken) { + const endpoint = `https://${endpointData}/api/v1/products/${product_id}/ratings`; + // const sessionToken = 'your-session-token-here'; // Replace with your actual session token logic + + try { + const response = await fetch(endpoint, { + method: 'POST', + headers: { + 'Authorization': 'Bearer ' + sessionToken, + }, + body: formData + }); + + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + + return await response.json(); + } catch (error) { + console.error('Error:', error); + throw error; + } +} +async function updateOrderRating(product_id,endpointData,sessionToken) { + const endpoint = `https://${endpointData}/api/v1/orders/${product_id}`; + // const sessionToken = 'your-session-token-here'; // Replace with your actual session token logic + + try { + const response = await fetch(endpoint, { + method: 'PATCH', + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ' + sessionToken, + }, + body: JSON.stringify({ + "isRate": true + }) + }); + + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + + return await response.json(); + } catch (error) { + console.error('Error:', error); + throw error; + } +} +async function uploadImageRating(formData,endpointData,sessionToken) { + const endpoint = `https://${endpointData}/api/v1/upload_image`; + // const sessionToken = 'your-session-token-here'; // Replace with your actual session token logic + + try { + const response = await fetch(endpoint, { + method: 'POST', + headers: { + 'Authorization': 'Bearer ' + sessionToken, + }, + body: formData + }); + + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + + return await response.json(); + } catch (error) { + console.error('Error:', error); + throw error; + } +} +async function sendFeedback(variation, rating, + comments, images, videos, customer_id, + order_id, + vendor_id, files, productId, + endpoint, sessionToken +) { + + const formData = new FormData(); + const currentDate = new Date(); + const formattedDate = currentDate + .toISOString().replace(/[-T:]/g, "") + .slice(0, -5); + + + formData.append('variation', variation); + formData.append('rating', rating); + formData.append('comments', comments); + + formData.append('customer_id', + customer_id); + formData.append('order_id', order_id); + formData.append('vendor_id', vendor_id); + images?.forEach((image, index) => { + formData.append( + `images`, + image); + }); + + // Append videos to FormData + videos?.forEach((video, index) => { + formData.append( + `videos`, + video); + }); + + + postProductRating( + productId, + formData, + endpoint, sessionToken + ) + .then(response => { + console.log('Success:', + response); + if (!response) { + throw new Error( + 'Failed to send text message' + ); + } else { + + + updateOrderRating( + order_id, + endpoint, + sessionToken + ) + .then( + response1 => { + console.log( + 'Success:', + response1 + ); + if ( + ! + response1 + ) { + + throw new Error( + ` + update order failed ` + ); + } else { + sendButton1 + [ + order_id + ] + .textContent = + "Submitted"; + sendButton1 + [ + order_id + ] + .disabled = + true + } + }) + .catch(error => { + console + .error( + 'Error:', + error + ); + }); + + + + + } + }) + .catch(error => { + console.error('Error:', + error); + }); + +} \ No newline at end of file diff --git a/product-left-sidebar.php b/product-left-sidebar.php index ebb40a8..24400ff 100644 --- a/product-left-sidebar.php +++ b/product-left-sidebar.php @@ -92,24 +92,34 @@ if (isset($_GET['id'])) { @@ -1628,7 +1638,7 @@ if (isset($_GET['id'])) { alt="" /> -->
-
+ @@ -252,13 +271,15 @@ if ($_SESSION["isVendor"] == true) { --> -
+
- alt="vendor image"> + + alt="vendor image">
@@ -300,13 +321,14 @@ if ($_SESSION["isVendor"] == true) { --> - +
All Refund History
@@ -314,18 +336,36 @@ if ($_SESSION["isVendor"] == true) {
-
All Refunds -
-
To Approve -
-
To Ship -
-
To Receive -
-
To Refund -
-
Complete -
+
+ All Refunds + +
+
+ To Approve + +
+
+ To Ship + +
+
+ To Receive + +
+
+ To Refund + +
+
+ Complete + +
@@ -335,7 +375,7 @@ if ($_SESSION["isVendor"] == true) { - - + + - - + + No Refund/s Yet.

'; - ?> - + ?> + @@ -460,23 +513,36 @@ if ($_SESSION["isVendor"] == true) { $orderExist = true; $totalAmount += $order['total_amount']; ?> - - - product - - - - - - - + + - - + + No To Approve Refund/s Yet.

'; - ?> - + ?> + @@ -499,7 +565,7 @@ if ($_SESSION["isVendor"] == true) { - +
@@ -534,23 +600,36 @@ if ($_SESSION["isVendor"] == true) { $orderExist = true; $totalAmount += $order['total_amount']; ?> - - - - - - - - - - + - - + + No To Ship Refund/s Yet.

'; - ?> - + ?> + @@ -573,7 +652,7 @@ if ($_SESSION["isVendor"] == true) {
product +
- +
@@ -608,26 +687,39 @@ if ($_SESSION["isVendor"] == true) { $orderExist = true; $totalAmount += $order['total_amount']; ?> - - - - - - - - - - - - + No To Receive Refund/s Yet.

'; - ?> - + ?> + @@ -685,26 +777,39 @@ if ($_SESSION["isVendor"] == true) { $orderExist = true; $totalAmount += $order['total_amount']; ?> - - - - - - - - - - - - + No To Refund/s Yet.

'; - ?> - + ?> + @@ -761,28 +866,41 @@ if ($_SESSION["isVendor"] == true) { $orderExist = true; $totalAmount += $order['total_amount']; ?> - - - - - - - - - - - - - - + + - +
product
product
product
+
@@ -348,35 +368,37 @@ $vendorPayoutData = json_decode($response, true); $payoutDate = date("F d, Y", strtotime($val['createdAt'])); $payoutId = $val['_id']; if ((empty($vendorIdCheck) == false) && ($vendorIdCheck == $vendorId) && ($status == "Deposited")) { ?> - - - + + - - - - + + + - - - - - - - - + + + + + + + +
Amount
N/A N/A N/A - -
N/A + +
- + @@ -437,7 +459,7 @@ $vendorPayoutData = json_decode($response, true); - +
@@ -525,7 +547,7 @@ $vendorPayoutData = json_decode($response, true); - +