parent
34f4980ad5
commit
f4756637d6
5 changed files with 67 additions and 48 deletions
|
|
@ -29,6 +29,8 @@ import (
|
||||||
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/types"
|
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var ErrNoAddress = errors.New("no-address")
|
||||||
|
|
||||||
// GenerateReportID creates a 12-character random string using only unambiguous
|
// GenerateReportID creates a 12-character random string using only unambiguous
|
||||||
// capital letters and numbers
|
// capital letters and numbers
|
||||||
func GenerateReportID() (string, error) {
|
func GenerateReportID() (string, error) {
|
||||||
|
|
@ -366,7 +368,7 @@ func publicReportCreate(ctx context.Context, setter_report modelpublicreport.Rep
|
||||||
}
|
}
|
||||||
addr = &geo_res.Address
|
addr = &geo_res.Address
|
||||||
} else {
|
} else {
|
||||||
return result, fmt.Errorf("empty address")
|
return result, ErrNoAddress
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package resource
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"slices"
|
"slices"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -125,6 +126,9 @@ func (res *nuisanceR) Create(ctx context.Context, r *http.Request, n nuisanceFor
|
||||||
}
|
}
|
||||||
report, err := platform.PublicReportNuisanceCreate(ctx, setter_report, setter_nuisance, n.Location, n.Address, uploads)
|
report, err := platform.PublicReportNuisanceCreate(ctx, setter_report, setter_nuisance, n.Location, n.Address, uploads)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, platform.ErrNoAddress) {
|
||||||
|
return nil, nhttp.NewBadRequest("empty-address")
|
||||||
|
}
|
||||||
return nil, nhttp.NewError("create nuisance report: %w", err)
|
return nil, nhttp.NewError("create nuisance report: %w", err)
|
||||||
}
|
}
|
||||||
uri, err := res.router.IDStrToURI("publicreport.ByIDGetPublic", report.PublicID)
|
uri, err := res.router.IDStrToURI("publicreport.ByIDGetPublic", report.PublicID)
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="visible" class="error-notification" role="alert">
|
<div v-if="visible" class="error-notification" role="alert">
|
||||||
<span class="error-icon" aria-hidden="true">✗</span>
|
|
||||||
<span class="error-text">{{ message }}</span>
|
<span class="error-text">{{ message }}</span>
|
||||||
<button
|
<button
|
||||||
v-if="dismissible"
|
v-if="dismissible"
|
||||||
|
|
@ -57,7 +56,8 @@ const props = withDefaults(
|
||||||
dismissible?: boolean;
|
dismissible?: boolean;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
message: "Something went wrong. Your request could not be completed. Please try again.",
|
message:
|
||||||
|
"Something went wrong. Your request could not be completed. Please try again.",
|
||||||
dismissible: true,
|
dismissible: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -477,6 +477,7 @@ import { useStoreLocal } from "@/store/local";
|
||||||
import { useStorePublicReport } from "@/store/publicreport";
|
import { useStorePublicReport } from "@/store/publicreport";
|
||||||
import type { Marker } from "@/types";
|
import type { Marker } from "@/types";
|
||||||
import {
|
import {
|
||||||
|
type APIError,
|
||||||
type Geocode,
|
type Geocode,
|
||||||
type GeocodeSuggestion,
|
type GeocodeSuggestion,
|
||||||
type PublicReport,
|
type PublicReport,
|
||||||
|
|
@ -535,7 +536,16 @@ async function doSubmit() {
|
||||||
// Don't set Content-Type, the browser should do it
|
// Don't set Content-Type, the browser should do it
|
||||||
});
|
});
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
errorMessage.value = "Something went wrong. Your request could not be completed. Please try again.";
|
if (resp.status == 400) {
|
||||||
|
const data: APIError = (await resp.json()) as APIError;
|
||||||
|
if (data.message == "empty-address") {
|
||||||
|
errorMessage.value =
|
||||||
|
"You must provide either an address, or a location on the map, otherwise we don't have much to work with.";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errorMessage.value =
|
||||||
|
"Something went wrong. Your request could not be completed. Please try again.";
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const data: PublicReport = (await resp.json()) as PublicReport;
|
const data: PublicReport = (await resp.json()) as PublicReport;
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,9 @@ export class Address {
|
||||||
public location?: Location,
|
public location?: Location,
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
export interface APIError {
|
||||||
|
message: string;
|
||||||
|
}
|
||||||
export interface TegolaURLs {
|
export interface TegolaURLs {
|
||||||
nidus: string;
|
nidus: string;
|
||||||
rmo: string;
|
rmo: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue