@extends('portal.layout')
@section('title', 'Data Integrations — Report #'.str_pad($report->id, 5, '0', STR_PAD_LEFT))
@section('content')
@php
$score = $report->feasibility_score ?? 0;
$scoreColor = $score >= 70 ? 'var(--green)' : ($score >= 40 ? 'var(--yellow)' : 'var(--red)');
$integrationMeta = [
'land_record' => ['label' => 'Land Records', 'icon' => '', 'desc' => 'Bhulekh / Bhoomi / Dharani — 7/12 extract, ownership, encumbrances'],
'rera' => ['label' => 'RERA Projects', 'icon' => '', 'desc' => 'Nearby RERA-registered projects for price & density comparison'],
'valuation' => ['label' => 'Property Valuation', 'icon' => '', 'desc' => 'Circle rate / ready reckoner & estimated market value'],
'environmental' => ['label' => 'Environmental', 'icon' => '', 'desc' => 'CRZ, eco-sensitive zones, forest & wildlife clearances (MOEF / NCZMA)'],
'infrastructure' => ['label' => 'Infrastructure', 'icon' => '', 'desc' => 'Metro, highway, SEZ, smart city & airport projects nearby'],
'flood_risk' => ['label' => 'Flood & Weather Risk', 'icon' => '', 'desc' => 'NDMA flood zones, IMD rainfall, elevation & composite risk score'],
];
@endphp
@include('portal.partials.report-sidebar')
{{-- Header --}}
Real-Time Data Integrations
{{ $report->address ?? 'Plot' }} — {{ number_format($report->plot_area_sqm) }} sqm —
Score: {{ $score }}/100
{{-- Integration Cards --}}
@foreach($integrationMeta as $type => $meta)
{{-- Card Header --}}
{{ $meta['label'] }}
{{ $meta['desc'] }}
{{-- Status badge --}}
@php $s = $status[$type] ?? ['available' => false]; @endphp
{{ $s['available'] ? 'Fetched' : 'Pending' }}
{{-- Card Body — Data or Placeholder --}}
@if(isset($integrations[$type]) && $integrations[$type]->count())
@foreach($integrations[$type] as $item)
@if($item->summary && is_array($item->summary))
@foreach($item->summary as $k => $v)
{{ str_replace('_', ' ', $k) }}
@if(is_bool($v))
{!! $v ? 'Yes' : 'No' !!}
@elseif(is_numeric($v))
{{ number_format($v, is_float($v) ? 2 : 0) }}
@else
{{ $v }}
@endif
@endforeach
@else
Data available — expand for details
@endif
@endforeach
@else
No data yet. Click Fetch to query live sources.
@endif
{{-- Card Footer --}}
@if($s['available'] && ($s['updated_at'] ?? null))
Updated {{ \Carbon\Carbon::parse($s['updated_at'])->diffForHumans() }}
@else
@endif
@endforeach
{{-- Integration Summary Panel --}}
@if($integrations->count())
Integration Summary
@foreach($integrationMeta as $type => $meta)
@php $count = isset($integrations[$type]) ? $integrations[$type]->count() : 0; @endphp
{{ $count }}
{{ $meta['label'] }}
@endforeach
@endif
{{-- Toast notification --}}
@endsection