Skip to content

Commit

Permalink
Feat: Fetct issue-templates from backend
Browse files Browse the repository at this point in the history
  • Loading branch information
KBandipo authored and Ifycode committed Nov 28, 2024
1 parent 36da123 commit 2787a09
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions @dev-client/views/@plugin_githubsync/githubsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getLastIndexOfCharaterInString } from '../@library_external/transform.j

const submitIssueForm = document.getElementById('submitIssueForm');
const displayToastrMessage = document.getElementById('displayToastrMessage');
const issueTemplatesDropdown = document.getElementById('issueTemplates');

/* ----------------------------------
Submit an Issue ticket through UI
Expand Down Expand Up @@ -48,6 +49,36 @@ if (response.status === 401){
}
});

const fetchTemplates = async () => {
try {
const response = await fetch(`${backend_URL}/issue-templates`);
if (!response.ok) {
throw new Error(`Failed to fetch templates: ${response.statusText}`);
}
const templates = await response.json();
return templates.templates;
} catch (error) {
console.error('Error fetching templates:', error);
displayToastrMessage.innerHTML = 'Could not load issue templates.';
return;
}
};

const fetchTemplatesDropdown = async () => {
const templates = await fetchTemplates();
templates.forEach((template) => {
const option = document.createElement('option');
option.value = template.path;
option.textContent = template.name
issueTemplatesDropdown.appendChild(option);
});
};


fetchTemplatesDropdown();



/* --------------------------------
Fetch repositories on page load
-------------------------------- */
Expand Down

0 comments on commit 2787a09

Please sign in to comment.