@extends('layouts.admin')
@php
// ponytail: prettify a snake/camel question key into a human label.
$label = fn ($k) => \Illuminate\Support\Str::of($k)->replace('_', ' ')->headline();
// ponytail: answer_value may be a JSON-encoded array (multi-select); render it readable.
$value = function ($v) {
$decoded = json_decode($v ?? '', true);
if (is_array($decoded)) {
return implode(', ', array_map(fn ($x) => is_scalar($x) ? $x : json_encode($x), $decoded));
}
return $v;
};
$name = fn ($r) => $r?->name ?: $r?->profile_name ?: $r?->recipient_mobile ?: 'Unknown contact';
$initials = fn ($n) => \Illuminate\Support\Str::of($n)->explode(' ')->take(2)->map(fn ($p) => \Illuminate\Support\Str::substr($p, 0, 1))->implode('') ?: '?';
@endphp
@section('style')
@parent
@endsection
@section('content')
{{-- ───────────────────────── LEVEL 1 — FLOWS ───────────────────────── --}}
@if($level === 'flows')
Interactive flow responses
Pick a flow to see who replied on {{ $channel->name ?? 'this channel' }}
@if($flows->isEmpty() && ($unlinkedCount ?? 0) < 1)
No responses yet
Once contacts submit a flow, it shows up here.
@else
@if($flows->isNotEmpty())
Flow
Status
Last response
@foreach($flows as $flow)
{{ $flow->name }}
{{ $flow->interactive_flows_count }} response{{ $flow->interactive_flows_count == 1 ? '' : 's' }}
{{ $flow->status }}
{{ $flow->interactive_flows_max_submitted_at ? \Illuminate\Support\Carbon::parse($flow->interactive_flows_max_submitted_at)->diffForHumans() : '—' }}
View
@endforeach
@endif
@if(($unlinkedCount ?? 0) > 0)
Unlinked responses
{{ $unlinkedCount }} response{{ $unlinkedCount == 1 ? '' : 's' }} not matched to a flow
View
@endif
@endif
{{-- ──────────────────────── LEVEL 2 — CUSTOMERS ─────────────────────── --}}
@elseif($level === 'customers')
{{ $flow->name }}
{{ $surveys->count() }} response{{ $surveys->count() == 1 ? '' : 's' }} — pick a contact to read their answers
@if($surveys->isNotEmpty())
Download Excel
@endif
@if($surveys->isEmpty())
No one has answered yet
Responses to this flow will appear here as contacts submit.
@else
Contact
Answers
Submitted
@foreach($surveys as $survey)
@php $cname = $name($survey->recipient); @endphp
{{ $initials($cname) }}
{{ $cname }}
{{ $survey->recipient->recipient_mobile ?? $survey->flow_token }}
{{ $survey->answers_count }} answered
{{ $survey->submitted_at ? $survey->submitted_at->format('M j, Y · g:ia') : $survey->created_at->format('M j, Y') }}
Read
@endforeach
@endif
{{-- ───────────────────────── LEVEL 3 — ANSWERS ──────────────────────── --}}
@else
@php
$cname = $name($survey->recipient);
$answers = $survey->answers;
@endphp
{{ $initials($cname) }}
{{ $cname }}
{{ $survey->recipient->recipient_mobile ?? '' }}
@if($survey->submitted_at) · submitted {{ $survey->submitted_at->format('M j, Y · g:ia') }} @endif
@if($answers->isEmpty())
No itemized answers
This submission was recorded without parsed question/answer pairs.
@else
{{ $survey->submitted_at ? $survey->submitted_at->format('l, M j') : 'Response' }}
@foreach($answers as $answer)
{{ $label($answer->question_key) }}
{{ $value($answer->answer_value) !== null && $value($answer->answer_value) !== '' ? $value($answer->answer_value) : '—' }}
@endforeach
@endif
@if(!empty($survey->response_json))
Raw response payload
{{ json_encode($survey->response_json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) }}
@endif
@endif
@endsection