Skip to content

Commit

Permalink
Merge pull request #168 from HKN-UCSD/49-pages-reload-everytime-someo…
Browse files Browse the repository at this point in the history
…ne-does-an-event-action

49 pages reload everytime someone does an event action
  • Loading branch information
hkn-devteam authored May 25, 2024
2 parents cffd0ef + a9b137a commit 04793d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
19 changes: 11 additions & 8 deletions frontend/src/Components/Events/CustomizableEventConsole.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@
}
}
async function copyToClipboard(text, sign_tab) {
async function copyToClipboard(text, rsvpd_tab) {
if(text.length == 0){
alert("No checked off attendees!");
}else{
if(sign_tab){
if(rsvpd_tab){
try {
await navigator.clipboard.writeText(text);
alert("Checked-Off attendee's email copied to clipboard!");
alert("RSVP'd attendee's email copied to clipboard!");
} catch (err) {
console.error("Failed to copy:", err);
alert("Failed to copy text to clipboard.");
}
}else{
try {
await navigator.clipboard.writeText(text);
alert("RSVP'd attendee's email copied to clipboard!");
alert("Checked-Off attendee's email copied to clipboard!");
} catch (err) {
console.error("Failed to copy:", err);
alert("Failed to copy text to clipboard.");
Expand Down Expand Up @@ -97,6 +97,12 @@
try {
// Call your asynchronous function that returns a promise
indexedRows = await fetchEventTable(event);
emailsRsvp = [];
indexedRows.forEach((row) => {
if (row["RSVP Id"] !== undefined) {
emailsRsvp.push(row["Email"]);
}
});
emailsCheckedOff = [];
indexedRows.forEach((row) => {
if (row["Check Off Id"] !== undefined) {
Expand Down Expand Up @@ -136,6 +142,7 @@
"Sign In Time",
];
filters = [(row) => row["Sign In Time"] != undefined];
// TODO: Consider making a config file defining tables and their names/columns
</script>

<!-- Event Action Bar -->
Expand Down Expand Up @@ -267,10 +274,6 @@
Copy Emails
</button>
</div>
<button on:click={() => copyToClipboard(emailsCheckedOff)}
>
Copy Emails
</button>

<table style="margin-top: 0px;">
<tr>
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/Components/Events/eventutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,14 @@ export async function fetchEventTable(event) {
row[actionRecord["action"] + " Time"] = new Date(
actionRecord["action_time"],
).toLocaleString();
row[actionRecord["action"] + " Id"] = actionRecord["pk"]; // storing a record's id is necessary for deleting action records
// storing a record's id is necessary for deleting action records
// as well as for deciding whether to produce an undo version of
// this action
row[actionRecord["action"] + " Id"] = actionRecord["pk"];
row["Points"] += actionRecord["points"];

// remember the action record's id and that it is associated with this user and this action,
// so that when generating buttons, we can trigger an un-delete.
});


// for each user, update its relevant row with email and name
relatedUsers.forEach((user) => {
const userId = user["user_id"];
Expand Down

0 comments on commit 04793d9

Please sign in to comment.