Skip to content

Commit

Permalink
feat: open edit form after cloning subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Ribeiro committed Sep 1, 2024
1 parent ba5bd35 commit add2d26
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion endpoints/subscription/clone.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
if ($cloneStmt->execute()) {
$response = [
"success" => true,
"message" => translate('success', $i18n)
"message" => translate('success', $i18n),
"id" => $db->lastInsertRowID()
];
echo json_encode($response);
} else {
Expand Down
9 changes: 7 additions & 2 deletions scripts/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ function cloneSubscription(event, id) {
})
.then(data => {
if (data.success) {
fetchSubscriptions();
const id = data.id;
fetchSubscriptions(id, event);
showSuccessMessage(decodeURI(data.message));
} else {
showErrorMessage(data.message || translate('error'));
Expand Down Expand Up @@ -288,7 +289,7 @@ function closeLogoSearch() {
logoResults.innerHTML = "";
}

function fetchSubscriptions() {
function fetchSubscriptions(id, event) {
const subscriptionsContainer = document.querySelector("#subscriptions");
let getSubscriptions = "endpoints/subscriptions/get.php";

Expand Down Expand Up @@ -317,6 +318,10 @@ function fetchSubscriptions() {
mainActions.classList.remove("hidden");
}
}

if (id && event) {
openEditSubscription(event, id);
}
})
.catch(error => {
console.error(translate('error_reloading_subscription'), error);
Expand Down

0 comments on commit add2d26

Please sign in to comment.