Begin work on saving compliance report
This commit is contained in:
parent
3ad95e1365
commit
553b65556a
22 changed files with 2419 additions and 42 deletions
|
|
@ -40,8 +40,10 @@ import { computedAsync } from "@vueuse/core";
|
|||
|
||||
import type { Image } from "@/components/ImageUpload.vue";
|
||||
import { useStoreDistrict } from "@/rmo/store/district";
|
||||
import { useStoreLocal } from "@/store/local";
|
||||
import { useStoreLocation } from "@/store/location";
|
||||
import Intro from "@/rmo/content/compliance/Intro.vue";
|
||||
import { type District, PermissionAccess } from "@/type/api";
|
||||
import { type District, PermissionAccess, type PublicReport } from "@/type/api";
|
||||
import { Locator } from "@/type/map";
|
||||
import { type Contact } from "@/rmo/content/compliance/Contact.vue";
|
||||
import { type Permission } from "@/rmo/content/compliance/Permission.vue";
|
||||
|
|
@ -95,10 +97,13 @@ const compliance = ref<Compliance>({
|
|||
},
|
||||
});
|
||||
const props = defineProps<Props>();
|
||||
const report = ref<PublicReport | null>();
|
||||
const district = computedAsync(async (): Promise<District | undefined> => {
|
||||
const districts = await districtStore.list();
|
||||
return districts.find((district: District) => district.slug == props.slug);
|
||||
});
|
||||
const storeLocal = useStoreLocal();
|
||||
const storeLocation = useStoreLocation();
|
||||
function doEvidence() {
|
||||
console.log("evidence", compliance.value);
|
||||
}
|
||||
|
|
@ -111,4 +116,29 @@ function doLocator() {
|
|||
function doPermission() {
|
||||
console.log("permission", compliance.value.permission);
|
||||
}
|
||||
async function createReport(report_id: string, loc?: GeolocationPosition) {
|
||||
const formData = new FormData();
|
||||
formData.append;
|
||||
const resp = await fetch("/api/rmo/compliance", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
// Don't set Content-Type, the borwser should do it
|
||||
});
|
||||
if (!resp.ok) {
|
||||
const content = await resp.text();
|
||||
console.error("Failed to create compliance report", resp.status, content);
|
||||
}
|
||||
}
|
||||
onMounted(() => {
|
||||
const session_id = storeLocal.getSessionID();
|
||||
storeLocation
|
||||
.get()
|
||||
.then((loc: GeolocationPosition) => {
|
||||
createReport(session_id, loc);
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log("failed to get location", e);
|
||||
createReport(session_id);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue