Question:
[ what the code need to let the admin approve or reject the pending teacher in custom admin dashboard and the required design and where i should replace the id of my UI elements:.]
Product:
[ Wix Editor]
Question:
[ what the code need to let the admin approve or reject the pending teacher in custom admin dashboard and the required design and where i should replace the id of my UI elements:.]
Product:
[ Wix Editor]
If you have code that isn’t working can you please share it and the error message you’re getting?
I don’t have any experience in wix coding i find this code there is no errors but when i click on the button it does not working.
import wixData from 'wix-data';
$w.onReady(function () {
// Load the pending teacher registrations into the repeater
loadPendingRegistrations();
});
function loadPendingRegistrations() {
wixData.query("Shadow_Teachers")
.eq("status", "pending")
.find()
.then((results) => {
$w("#requestsRepeater").data = results.items.map((item) => {
return {
_id: item._id, // Store the item ID for use in onClick handlers
};
});
})
.catch((err) => {
console.error("Error loading pending registrations", err);
});
}
export function approveButton_click(event, $w) {
const itemId = event.context.itemId; // Get the item ID from the button's context
approveRegistration(itemId);
}
/**
* Adds an event handler that runs when the element is clicked.
[Read more](https://www.wix.com/corvid/reference/$w.ClickableMixin.html#onClick)
* @param {$w.MouseEvent} event
*/
export function dismissButton_click(event, $w) {
const itemId = event.context.itemId; // Get the item ID from the button's context
rejectRegistration(itemId);
}
function approveRegistration(id) {
updateRegistrationStatus(id, "approved");
}
function rejectRegistration(id) {
updateRegistrationStatus(id, "rejected");
}
function updateRegistrationStatus(id, status) {
wixData.update("Shadow_Teachers", id, { status: status })
.then(() => {
console.log("Registration status updated successfully");
loadPendingRegistrations(); // Refresh the repeater
})
.catch((err) => {
console.error("Error updating registration status", err);
}
Unfortunately without any coding experience the people on this forum are unlikely to be able to help you with this code. You might want to consider the Wix Marketplace: https://www.wix.com/marketplace