Don't compliance report on root Compliance page
We're now doing that through our two entrypoint pages.
This commit is contained in:
parent
8fd86d478c
commit
bcc5151116
2 changed files with 49 additions and 75 deletions
|
|
@ -18,25 +18,14 @@ export const useStorePublicReport = defineStore("publicreport", () => {
|
|||
_byID.value.set(pr.public_id, pr);
|
||||
}
|
||||
// Actions
|
||||
async function byID(id: string): Promise<PublicReport | undefined> {
|
||||
loading.value = true;
|
||||
try {
|
||||
const url = `/api/publicreport/${id}`;
|
||||
const response = await fetch(url);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
const body: PublicReportDTO = await response.json();
|
||||
const report = PublicReport.fromJSON(body);
|
||||
_byID.value.set(id, report);
|
||||
return report;
|
||||
} catch (err) {
|
||||
console.error("Error loading users:", err);
|
||||
throw err;
|
||||
async function byID(id: string): Promise<PublicReport> {
|
||||
const r = _byID.value.get(id);
|
||||
if (r) {
|
||||
return r;
|
||||
}
|
||||
return fetchByID(id);
|
||||
}
|
||||
async function byURI(uri: string): Promise<PublicReport | undefined> {
|
||||
async function byURI(uri: string): Promise<PublicReport> {
|
||||
const id = uri.split("/").pop() || "";
|
||||
if (!id) {
|
||||
throw new Error(`${uri} is not a recognized public report URI`);
|
||||
|
|
@ -54,11 +43,34 @@ export const useStorePublicReport = defineStore("publicreport", () => {
|
|||
_byID.value.set(result.public_id, result);
|
||||
return result;
|
||||
}
|
||||
async function fetchByID(id: string): Promise<PublicReport> {
|
||||
const uri = `/api/publicreport/${id}`;
|
||||
return fetchByURI(uri);
|
||||
}
|
||||
async function fetchByURI(uri: string): Promise<PublicReport> {
|
||||
loading.value = true;
|
||||
try {
|
||||
const response = await fetch(uri);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
const body: PublicReportDTO = await response.json();
|
||||
const report = PublicReport.fromJSON(body);
|
||||
_byID.value.set(report.public_id, report);
|
||||
return report;
|
||||
} catch (err) {
|
||||
console.error("Error loading users:", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
return {
|
||||
// Actions
|
||||
add,
|
||||
byID,
|
||||
byURI,
|
||||
createCompliance,
|
||||
fetchByID,
|
||||
fetchByURI,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue