Don't show "send compliance mailer" if org isn't configured for Lob

This commit is contained in:
Eli Ribble 2026-04-23 15:50:58 +00:00
parent 72a8ed5c16
commit 516dd6f429
No known key found for this signature in database
4 changed files with 51 additions and 37 deletions

View file

@ -46,28 +46,6 @@ func (o Organization) CountTrap(ctx context.Context) (uint, error) {
}
return uint(result), nil
}
func (o Organization) HasServiceArea() bool {
return o.model.ServiceAreaGeometry.IsValue()
}
func (o Organization) IsCatchall() bool {
return o.model.IsCatchall
}
func (o Organization) MarshalJSON() ([]byte, error) {
to_marshal := map[string]any{}
to_marshal["id"] = o.ID
to_marshal["name"] = o.Name()
to_marshal["service_area"] = o.ServiceArea
return json.Marshal(to_marshal)
}
func (o Organization) Name() string {
return o.model.Name
}
func (o Organization) PhoneOffice() string {
return o.model.OfficePhone.GetOr("")
}
func (o Organization) IsSyncOngoing() bool {
return IsSyncOngoing(o.ID)
}
func (o Organization) FieldseekerSyncLatest(ctx context.Context) (*models.FieldseekerSync, error) {
sync, err := o.model.FieldseekerSyncs(sm.OrderBy("created").Desc()).One(ctx, db.PGInstance.BobDB)
if err != nil {
@ -79,6 +57,32 @@ func (o Organization) FieldseekerSyncLatest(ctx context.Context) (*models.Fields
return sync, nil
}
func (o Organization) HasServiceArea() bool {
return o.model.ServiceAreaGeometry.IsValue()
}
func (o Organization) IsCatchall() bool {
return o.model.IsCatchall
}
func (o Organization) IsSyncOngoing() bool {
return IsSyncOngoing(o.ID)
}
func (o Organization) LobAddressID() string {
return o.model.LobAddressID.GetOr("")
}
func (o Organization) MarshalJSON() ([]byte, error) {
to_marshal := map[string]any{}
to_marshal["id"] = o.ID
to_marshal["name"] = o.Name()
to_marshal["service_area"] = o.ServiceArea
to_marshal["lob_address_id"] = o.model.LobAddressID
return json.Marshal(to_marshal)
}
func (o Organization) Name() string {
return o.model.Name
}
func (o Organization) PhoneOffice() string {
return o.model.OfficePhone.GetOr("")
}
func (o Organization) ServiceRequestRecent(ctx context.Context) ([]*models.FieldseekerServicerequest, error) {
results, err := o.model.Servicerequests(sm.OrderBy("creationdate").Desc(), sm.Limit(10)).All(ctx, db.PGInstance.BobDB)
if err != nil {

View file

@ -23,9 +23,10 @@ func Session(r *router) *sessionR {
}
type organization struct {
ID int32 `json:"id"`
Name string `json:"name"`
ServiceArea *types.ServiceArea `json:"service_area"`
ID int32 `json:"id"`
LobAddressID string `json:"lob_address_id"`
Name string `json:"name"`
ServiceArea *types.ServiceArea `json:"service_area"`
}
type session struct {
@ -89,9 +90,10 @@ func (res *sessionR) Get(ctx context.Context, r *http.Request, user platform.Use
Review: counts.Review,
},
Organization: organization{
ID: user.Organization.ID,
Name: user.Organization.Name(),
ServiceArea: user.Organization.ServiceArea,
ID: user.Organization.ID,
LobAddressID: user.Organization.LobAddressID(),
Name: user.Organization.Name(),
ServiceArea: user.Organization.ServiceArea,
},
Self: *u,
URLs: sessionURL{

View file

@ -4,19 +4,25 @@
<p>select a site to see actions</p>
</template>
<template v-if="selectedSite">
<ButtonLoading
@click="emit('doRequestComplianceMailer', selectedSite?.id ?? 0)"
:disabled="!selectedSite"
icon="bi-check-circle"
:loading="submitting"
text="Send Compliance Mailer"
variant="success"
/>
<template v-if="session.organization?.lob_address_id">
<ButtonLoading
@click="emit('doRequestComplianceMailer', selectedSite?.id ?? 0)"
:disabled="!selectedSite"
icon="bi-check-circle"
:loading="submitting"
text="Send Compliance Mailer"
variant="success"
/>
</template>
<template v-else>
<p>Set Lob Address ID</p>
</template>
</template>
</template>
<script setup lang="ts">
import { Site } from "@/type/api";
import ButtonLoading from "@/components/common/ButtonLoading.vue";
import { useSessionStore } from "@/store/session";
import { Site } from "@/type/api";
interface Emits {
(e: "doRequestComplianceMailer", id: number): void;
@ -29,4 +35,5 @@ const emit = defineEmits<Emits>();
const props = withDefaults(defineProps<Props>(), {
submitting: false,
});
const session = useSessionStore();
</script>

View file

@ -739,6 +739,7 @@ export class Mailer {
export interface Organization {
id: number;
name: string;
lob_address_id: string;
service_area?: Bounds;
}
export interface UserNotificationCounts {