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"
|
||||
)
|
||||
|
||||
var ErrNoAddress = errors.New("no-address")
|
||||
|
||||
// GenerateReportID creates a 12-character random string using only unambiguous
|
||||
// capital letters and numbers
|
||||
func GenerateReportID() (string, error) {
|
||||
|
|
@ -366,7 +368,7 @@ func publicReportCreate(ctx context.Context, setter_report modelpublicreport.Rep
|
|||
}
|
||||
addr = &geo_res.Address
|
||||
} else {
|
||||
return result, fmt.Errorf("empty address")
|
||||
return result, ErrNoAddress
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package resource
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"slices"
|
||||
"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)
|
||||
if err != nil {
|
||||
if errors.Is(err, platform.ErrNoAddress) {
|
||||
return nil, nhttp.NewBadRequest("empty-address")
|
||||
}
|
||||
return nil, nhttp.NewError("create nuisance report: %w", err)
|
||||
}
|
||||
uri, err := res.router.IDStrToURI("publicreport.ByIDGetPublic", report.PublicID)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
|
||||
<template>
|
||||
<div v-if="visible" class="error-notification" role="alert">
|
||||
<span class="error-icon" aria-hidden="true">✗</span>
|
||||
<span class="error-text">{{ message }}</span>
|
||||
<button
|
||||
v-if="dismissible"
|
||||
|
|
@ -57,7 +56,8 @@ const props = withDefaults(
|
|||
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,
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -477,6 +477,7 @@ import { useStoreLocal } from "@/store/local";
|
|||
import { useStorePublicReport } from "@/store/publicreport";
|
||||
import type { Marker } from "@/types";
|
||||
import {
|
||||
type APIError,
|
||||
type Geocode,
|
||||
type GeocodeSuggestion,
|
||||
type PublicReport,
|
||||
|
|
@ -535,7 +536,16 @@ async function doSubmit() {
|
|||
// Don't set Content-Type, the browser should do it
|
||||
});
|
||||
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;
|
||||
}
|
||||
const data: PublicReport = (await resp.json()) as PublicReport;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ export class Address {
|
|||
public location?: Location,
|
||||
) {}
|
||||
}
|
||||
export interface APIError {
|
||||
message: string;
|
||||
}
|
||||
export interface TegolaURLs {
|
||||
nidus: string;
|
||||
rmo: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue