<?php

use App\Models\Point;
$segmentSections = [
	[
		'heading' => 'Key Messages',
		'points' => [
			[
				'key' => 'any_mask_better_than_no_mask',
				'text' => 'Masking is a critical public health tool for preventing spread of COVID-19, and it is important to remember that any mask is better than no mask.',
				'type' => 'checkbox'
			],
			[
				'key' => 'masks_effective_at_reducing_virus',
				'text' => 'Masks and respirators are effective at reducing transmission of SARS-CoV-2, the virus that causes COVID-19, when worn consistently and correctly.',
				'type' => 'checkbox'
			],
			[
				'key' => 'wear_the_best_mask_you_can',
				'text' => "The key is: what will you wear that's most protective, but also wear consistently.",
				'type' => 'checkbox'
			],
			[
				'key' => 'more_protective_may_be_uncomfortable',
				'text' => 'Some masks and respirators offer higher levels of protection than others, and some may be harder to tolerate or wear consistently than others.',
				'type' => 'checkbox'
			],
			[
				'key' => 'importance_with_risk_and_age',
				'text' => 'This becomes more important if you are over 65 or have any medical conditions like HBP or DM that increase risk of COVID severity.',
				'type' => 'checkbox'
			],
			[
				'key' => 'what_are_you_currently_wearing',
				'text' => 'What are you currently wearing / how often / how often replaced?',
				'type' => 'textarea'
			],
			[
				'key' => 'what_is_the_best_mask_you_will_wear_consistently',
				'text' => 'What is the most protective mask that you will wear consistently?',
				'type' => 'text'
			]
		]
	],
	[
		'heading' => 'Follow-Up',
		'points' => [
			[
				'key' => 'n95_recommended',
				'text' => 'N95 recommended.',
				'type' => 'checkbox'
			],
			[
				'key' => 'ensure_tight_fit',
				'text' => 'Check for gaps by cupping your hands around the outside edges of the mask.',
				'type' => 'checkbox'
			],
			[
				'key' => 'check_airflow',
				'text' => 'Make sure no air is flowing from the area near your eyes or from the sides of the mask.',
				'type' => 'checkbox'
			],
			[
				'key' => 'warm_air_check',
				'text' => 'If the mask has a good fit, you will feel warm air come through the front of the mask and may be able to see the mask material move in and out with each breath.',
				'type' => 'checkbox'
			],
			[
				'key' => 'send_n95',
				'text' => 'Send N95 samples if appropriate.',
				'type' => 'readonly'
			]
		]
	]
];

$category = 'MASKS_AND_RESPIRATORS';
$endPoint = 'upsertNoteSingleton';

$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();


$contentData = [];

foreach($segmentSections as $segmentSection){
	foreach($segmentSection['points'] as $sectionPoint){
		if($sectionPoint['type'] == 'text'){
			$contentData[$sectionPoint['key']] = '';
		}elseif($sectionPoint['type'] == 'textarea'){
			$contentData[$sectionPoint['key']] = '';
		}elseif($sectionPoint['type'] == 'checkbox'){
			$contentData[$sectionPoint['key']] = null;
		}else{
			$contentData[$sectionPoint['key']] = '';
		}
	}
}


if (!!@$point->data) {
    $contentData = json_decode($point->data, true);
}
?>


<div class="events-none form-read-mode">
    @foreach($segmentSections as $section)
    <div class="mb-2">
        <h6><b>{{ $section['heading'] }}</b></h6>
        <ul>
            @foreach($section['points'] as $point)
            @if($point['type'] == 'text')
            @if(@$contentData[$point['key']])
            <li>{{ $point['text'] }}</li>
            @endif

            @elseif($point['type'] == 'textarea')
            @if(@$contentData[$point['key']])
            <li>
                <label>{{ $point['text'] }}:</label>
                <span><?= nl2br($contentData[$point['key']]) ?></span>
            </li>
            @endif
            @elseif($point['type'] == 'checkbox')
            @if(@$contentData[$point['key']])
            <li>{{ $point['text'] }}</li>
            @endif
            @else
            <div class="mb-2">
                <li>{{ $point['text'] }}</li>
            </div>
            @endif
            @endforeach
        </ul>
    </div>
    <hr class="my-3">
    @endforeach


</div>