Populate ComplianceReportRequest on site review page
This commit is contained in:
parent
a6ca30fdb1
commit
efd6f59fca
6 changed files with 42 additions and 14 deletions
|
|
@ -15,7 +15,7 @@ import (
|
|||
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
|
||||
"github.com/aarondl/opt/omit"
|
||||
"github.com/aarondl/opt/omitnull"
|
||||
"github.com/rs/zerolog/log"
|
||||
//"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
func ComplianceRequestMailerCreate(ctx context.Context, user User, site_id int32) (int32, error) {
|
||||
|
|
@ -111,11 +111,13 @@ func ComplianceReportRequestByLeadID(ctx context.Context, lead_ids []int32) (map
|
|||
results[lead_id] = make([]*types.ComplianceReportRequest, 0)
|
||||
}
|
||||
for _, row := range rows {
|
||||
crrs, ok := results[row.LeadID.MustGet()]
|
||||
lead_id := row.LeadID.MustGet()
|
||||
crrs, ok := results[lead_id]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("impossible")
|
||||
}
|
||||
crrs = append(crrs, types.ComplianceReportRequestFromModel(row))
|
||||
results[lead_id] = crrs
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ func leadCreate(ctx context.Context, txn bob.Executor, user User, signal_id int3
|
|||
}
|
||||
return &lead.ID, nil
|
||||
}
|
||||
func leadsBySiteID(ctx context.Context, site_ids []int32) (map[int32][]types.Lead, error) {
|
||||
func leadsBySiteID(ctx context.Context, site_ids []int32) (map[int32][]*types.Lead, error) {
|
||||
rows, err := bob.All(ctx, db.PGInstance.BobDB, psql.Select(
|
||||
sm.Columns(
|
||||
models.Leads.Columns.ID.As("id"),
|
||||
|
|
@ -59,7 +59,7 @@ func leadsBySiteID(ctx context.Context, site_ids []int32) (map[int32][]types.Lea
|
|||
sm.Where(
|
||||
models.Leads.Columns.SiteID.EQ(psql.Any(site_ids)),
|
||||
),
|
||||
), scan.StructMapper[types.Lead]())
|
||||
), scan.StructMapper[*types.Lead]())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("query leads: %w", err)
|
||||
}
|
||||
|
|
@ -75,9 +75,9 @@ func leadsBySiteID(ctx context.Context, site_ids []int32) (map[int32][]types.Lea
|
|||
}
|
||||
row.ComplianceReportRequests = crrs
|
||||
}
|
||||
results := make(map[int32][]types.Lead, len(site_ids))
|
||||
results := make(map[int32][]*types.Lead, len(site_ids))
|
||||
for _, site_id := range site_ids {
|
||||
results[site_id] = make([]types.Lead, 0)
|
||||
results[site_id] = make([]*types.Lead, 0)
|
||||
}
|
||||
for _, row := range rows {
|
||||
leads, ok := results[row.SiteID]
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ type Site struct {
|
|||
Features []Feature `db:"-" json:"features"`
|
||||
FileID int32 `db:"file_id" json:"file_id"`
|
||||
ID int32 `db:"id" json:"id"`
|
||||
Leads []Lead `db:"-" json:"leads"`
|
||||
Leads []*Lead `db:"-" json:"leads"`
|
||||
Notes string `db:"notes" json:"notes"`
|
||||
OrganizationID int32 `db:"organization_id" json:"organization_id"`
|
||||
Owner Contact `db:"owner" json:"owner"`
|
||||
|
|
|
|||
|
|
@ -187,8 +187,8 @@
|
|||
:key="lead.id"
|
||||
class="border rounded p-2 mb-2 signal-item"
|
||||
>
|
||||
<div class="small fw-semibold">{{ lead.title }}</div>
|
||||
<div class="text-muted small">{{ lead.description }}</div>
|
||||
<div class="small fw-semibold">{{ lead.type }}</div>
|
||||
<div class="text-muted small">{{ lead.id }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,29 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Leads: {{ selectedSite?.leads.length ?? "none" }}</td>
|
||||
<td>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr v-for="(lead, index) in selectedSite?.leads">
|
||||
<td>{{ lead.type }}</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li
|
||||
v-for="(crr, index2) in lead.compliance_report_requests"
|
||||
>
|
||||
<a
|
||||
:href="mailerLink(crr)"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>Compliance Report Request {{ crr.public_id }}</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
@ -74,7 +96,7 @@ import MapLocator from "@/components/MapLocator.vue";
|
|||
import MapProxiedArcgisTile from "@/components/MapProxiedArcgisTile.vue";
|
||||
import { formatAddress } from "@/format";
|
||||
import { useSessionStore } from "@/store/session";
|
||||
import { Site } from "@/type/api";
|
||||
import { ComplianceReportRequest, Site } from "@/type/api";
|
||||
import { Camera } from "@/type/map";
|
||||
import type { Marker } from "@/types";
|
||||
|
||||
|
|
@ -91,6 +113,9 @@ const mapCamera = ref<Camera>(new Camera());
|
|||
const props = defineProps<Props>();
|
||||
const session = useSessionStore();
|
||||
|
||||
function mailerLink(crr: ComplianceReportRequest): string {
|
||||
return `/mailer/mode-3/${crr.public_id}/preview`;
|
||||
}
|
||||
watch(
|
||||
() => props.mapFlyoverCamera,
|
||||
(newMapFlyoverCamera: Camera) => {
|
||||
|
|
|
|||
|
|
@ -108,10 +108,9 @@ export interface Followup {
|
|||
id: number;
|
||||
title: string;
|
||||
}
|
||||
export interface Lead {
|
||||
description: string;
|
||||
export interface ComplianceReportRequest {
|
||||
id: number;
|
||||
title: string;
|
||||
public_id: string;
|
||||
}
|
||||
export class LogEntry {
|
||||
constructor(
|
||||
|
|
@ -534,8 +533,10 @@ export interface Feature {
|
|||
type: string;
|
||||
}
|
||||
export interface Lead {
|
||||
compliance_report_requests: ComplianceReportRequest[];
|
||||
id: number;
|
||||
site_id: number;
|
||||
type: string;
|
||||
}
|
||||
export interface Site {
|
||||
address: Address;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue