Set up bridge folder + changes to Events/Jobs

- Copied bridge folder from frm.so
- All handlers in handlers.js added from frm.so
- Modified Events and Jobs pages' default events/jobs to model data structure from SQL/server
- Set up getJobs(), checkForUpdates() on both Events/Jobs to fetch new items and update when needed
This commit is contained in:
2026-03-15 16:00:37 -04:00
parent cb11d68fa7
commit 0d5e68188d
6 changed files with 136 additions and 20 deletions

View File

@@ -3,6 +3,7 @@ import "./JobsGrid.js"
import "./JobCard.js"
import "./JobForm.js"
import "../../components/SearchBar.js"
import server from "../../_/code/bridge/serverFunctions.js"
css(`
jobs- {
@@ -25,11 +26,16 @@ css(`
class Jobs extends Shadow {
jobs = [
{
id: 1,
network_id: 2,
creator_id: 1,
title: "Austin Chapter Lead",
description: "This is the description",
salary: "1% of Local Revenue",
salary: 50000.00,
company: "Hyperia",
location: "1234 location"
location: "1234 location",
created: "2026-03-12 13:41:41.0722",
updated_at: "2026-03-12 13:41:41.0722"
}
]
@@ -49,7 +55,7 @@ class Jobs extends Shadow {
SearchBar()
if (this.jobs == "") {
if (this.jobs == "" || this.jobs == []) {
LoadingCircle()
} else if (this.jobs.length > 0) {
for (let i = 0; i < this.jobs.length; i++) {
@@ -70,6 +76,37 @@ class Jobs extends Shadow {
.height(100, pct)
.width(100, pct)
}
async getJobs(networkId) {
const fetchedJobs = await server.getJobs(networkId)
if (this.checkForUpdates(this.jobs, fetchedJobs)) {
this.jobs = fetchedJobs
this.rerender()
}
}
connectedCallback() {
this.getJobs(global.currentNetwork.id)
}
checkForUpdates(currentJobs, fetchedJobs) {
if (currentJobs.length !== fetchedJobs.length) return true;
const currentMap = new Map(currentJobs.map(job => [job.id, job]));
for (const fetchedJob of fetchedJobs) {
const currentJob = currentMap.get(fetchedJob.id);
// new job added
if (!currentJob) return true;
// existing job changed
if (currentJob.updated_at !== fetchedJob.updated_at) {
return true;
}
}
return false;
}
}
register(Jobs)