const API_KEY = 'eyJhbGciOiJIUzI1NiJ9.eyJ0aWQiOjI5NDk3ODg0MiwiYWFpIjoxMSwidWlkIjo1MTI1OTUwMSwiaWFkIjoiMjAyMy0xMS0wOFQyMToxNTozNC4wMDBaIiwicGVyIjoibWU6d3JpdGUiLCJhY3RpZCI6MTk2NTU4ODksInJnbiI6InVzZTEifQ.PWCK5DBoPhqTJa601jNYCYgQopx0_ATRykQrWd5MffM';
const BOARD_ID = '9931703587';
const COLUMN_ID_ORG = 'name';
const COLUMN_ID_AGENCY = 'text_mkv9zcrk'; // Agency/Organization column ID
const COLUMN_ID_REP_TYPE = 'color_mkv7268f';
async function fetchMondayData() {
const query = `
query {
boards(ids: ${BOARD_ID}) {
items_page(limit: 500) {
items {
name
column_values {
id
text
}
}
}
}
}
`;
try {
const response = await fetch('https://api.monday.com/v2', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': API_KEY
},
body: JSON.stringify({ query })
});
const data = await response.json();
if (data.errors) throw new Error(data.errors[0].message);
const items = data.data.boards[0].items_page.items;
renderTable(items);
} catch (error) {
console.error('Error fetching data:', error);
document.getElementById('medical-direction-table').innerHTML = '${omdName}
${fullRepresenting}
`;
tbody.appendChild(row);
}
});
table.appendChild(tbody);
const container = document.getElementById('medical-direction-table');
if (container) container.innerHTML = '';
container.appendChild(table);
}
document.addEventListener('DOMContentLoaded', () => {
fetchMondayData();
});
Failed to load data. Check console for details.
'; } } function renderTable(items) { const table = document.createElement('table'); table.style.width = '100%'; table.style.borderCollapse = 'collapse'; table.style.fontFamily = 'Arial, sans-serif'; table.style.color = '#333'; const thead = document.createElement('thead'); const headerRow = document.createElement('tr'); ['OMD Name', 'Representing'].forEach(text => { const th = document.createElement('th'); th.style.border = '1px solid #ddd'; th.style.padding = '12px'; th.style.textAlign = 'left'; th.style.backgroundColor = '#f2f2f2'; th.textContent = text; headerRow.appendChild(th); }); thead.appendChild(headerRow); table.appendChild(thead); const tbody = document.createElement('tbody'); items.forEach(item => { let omdName = '', representing = '', repType = ''; omdName = item.name || 'N/A'; item.column_values.forEach(col => { if (col.id === COLUMN_ID_AGENCY) representing = col.text || 'N/A'; if (col.id === COLUMN_ID_REP_TYPE) repType = col.text || ''; }); if (omdName || representing) { const fullRepresenting = representing + (repType ? ' (' + repType + ')' : ''); const row = document.createElement('tr'); row.innerHTML = `
RSS - Posts