diff --git a/platform/compliance.go b/platform/compliance.go index 619ec948..838d0a25 100644 --- a/platform/compliance.go +++ b/platform/compliance.go @@ -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 } diff --git a/platform/lead.go b/platform/lead.go index c3e245b1..0a846293 100644 --- a/platform/lead.go +++ b/platform/lead.go @@ -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] diff --git a/platform/types/site.go b/platform/types/site.go index 96b8329e..8ec819ce 100644 --- a/platform/types/site.go +++ b/platform/types/site.go @@ -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"` diff --git a/ts/components/PlanningColumnList.vue b/ts/components/PlanningColumnList.vue index 679306fb..be897e22 100644 --- a/ts/components/PlanningColumnList.vue +++ b/ts/components/PlanningColumnList.vue @@ -187,8 +187,8 @@ :key="lead.id" class="border rounded p-2 mb-2 signal-item" > -
{{ lead.title }}
-
{{ lead.description }}
+
{{ lead.type }}
+
{{ lead.id }}
diff --git a/ts/components/ReviewSiteColumnDetail.vue b/ts/components/ReviewSiteColumnDetail.vue index c9bda9fd..a70d53fd 100644 --- a/ts/components/ReviewSiteColumnDetail.vue +++ b/ts/components/ReviewSiteColumnDetail.vue @@ -46,7 +46,29 @@ - Leads: {{ selectedSite?.leads.length ?? "none" }} + + + + + + + + +
{{ lead.type }} + +
+ @@ -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(new Camera()); const props = defineProps(); const session = useSessionStore(); +function mailerLink(crr: ComplianceReportRequest): string { + return `/mailer/mode-3/${crr.public_id}/preview`; +} watch( () => props.mapFlyoverCamera, (newMapFlyoverCamera: Camera) => { diff --git a/ts/type/api.ts b/ts/type/api.ts index da11473f..4c5cff49 100644 --- a/ts/type/api.ts +++ b/ts/type/api.ts @@ -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;