fixed bug on edit and delete bank function

This commit is contained in:
jouls 2024-05-15 18:10:19 +08:00
parent 68959b61ce
commit 092afe0fa1
1 changed files with 8 additions and 8 deletions

View File

@ -584,6 +584,7 @@ if ($_SESSION["isCustomer"] == true) {
</div>
<div id="editDelete" style="display:flex; float:right; width:20px; margin-top:20px; margin-right:-20px; margin-top:30px;">
<!-- <i class="fa-solid fa-pen" style="font-size:15px; float:right;"></i></a> -->
<i onclick="deleteBank('<?php echo $vendor['_id']; ?>', <?php echo $bank_index; ?>, true)"
class="fa-regular fa-trash-can" style="font-size:15px; float:right;"></i>
</div>
@ -1473,7 +1474,6 @@ if ($_SESSION["isCustomer"] == true) {
<!-- Script added by Louie for Dynamic Edit Modal Box. May 08, 2024 -->
<script>
const vendorid = `<?php echo $_SESSION["LoggedInVendorId"]; ?>`;
$('#editBankModal').on('shown.bs.modal', function (event) {
var jsonString = $(event.relatedTarget).data('value');
var jsonObject = JSON.parse(jsonString);
@ -1488,9 +1488,8 @@ if ($_SESSION["isCustomer"] == true) {
$('#editBankBtn').on('click', function() {
console.log(vendorid)
// function updateAddress(){
// Retrieve existing addresses from the API
const vendorid = `<?php echo $_SESSION["LoggedInVendorId"]; ?>`;
console.log("The vendorid is", vendorid)
// fetch('https://api.obanana.shop/api/v1/customers/65482e8d209ff8d348bd30fd')
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/vendors/' + vendorid)
.then(response => response.json())
@ -1551,15 +1550,16 @@ if ($_SESSION["isCustomer"] == true) {
<!-- Script added by Louie for Deleting Bank Information. May 08, 2024 -->
<script>
const vendorid = `<?php echo $_SESSION["LoggedInVendorId"]; ?>`;
function deleteBank(vendorid, bankIndex) {
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/vendors/' + vendorid)
const vendorId = `<?php echo $_SESSION["LoggedInVendorId"]; ?>`;
function deleteBank(vendorId, bankIndex) {
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/vendors/' + vendorId)
.then(response => response.json())
.then(data => {
let existingBank = data.bank_acount_details || [];
if (bankIndex >= 0 && bankIndex < existingBank.length) {
existingBank.splice(bankIndex, 1);
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/vendors/' + vendorid, {
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/vendors/' + vendorId, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json'