{% extends 'base.html.twig' %}

{% block title %}Community Resources
{% endblock %}

{% block body %}
	{% set today = date("now", company_timezone) %}
	{{ block('nav', 'internal/libs/nav.html.twig') }}

	<main class="main-content position-relative max-height-vh-100 h-100 border-radius-lg ">
		{{ block('topnav', 'internal/libs/top-nav.html.twig') }}

		<div class="container-fluid py-2">
			<div class="row">
				<div class="col-12">
					<div class="card my-4">
						<div class="card-header p-0 position-relative mt-n4 mx-3 z-index-2">
							<div class="d-flex justify-content-between bg-gradient-dark shadow-dark border-radius-lg pt-4 pb-3 ps-3 p-2">
								<div>
									<h6 class="text-white text-capitalize ps-3">Free/Low-cost Community Resources</h6>
								</div>
								<div>
									<button type='button' class='btn btn-block btn-light mb-3' onclick="window.open('{{ path('app_community_resource_map') }}', '_self')">Map</button>
									<button type="button" class="btn btn-block btn-light mb-3" onclick="window.open('{{ path('app_community_resource_add') }}', '_self')">Add Resource</button>
								</div>
							</div>
						</div>
						<div class="card-body px-0 pb-2">
							<div>
								Filters:
								<select onchange='filterResourceByCounty()' id='countyList'>
									<option value=''></option>

									{% for c in enum('App\\Enums\\County').cases() %}
										<option value='{{ c.value }}'>{{ c.value }}</option>
									{% endfor %}
								</select>
							</div>
							<div class="table-responsive p-0">
								<table class="table align-items-center mb-0">
									<thead>
										<tr>
											<th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Name</th>
											<th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7 ps-2">Address</th>
											<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Contact Info</th>
											<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Hours</th>
											<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Lat/Lon</th>
											<th class="text-secondary opacity-7"></th>
										</tr>
									</thead>
									<tbody id='resource-list'>
										{% for r in resources %}
											<tr>
												<td>{{ r.name }}
													{% if r.url %}
														<br/>{{ r.urlString|raw }}
													{% endif %}
												</td>
												<td>{{ r.getFormattedAddress()|raw }}</td>
												<td>{{ r.getContactCard()|raw }}</td>
												<td>{{ r.getHours() }}</td>
												<td>{{ r.lat|number_format(6) }}/{{ r.lon|number_format(6) }}</td>
												<td class='align-right'>
													<a href='{{ path('app_community_resource_edit', {id: r.id}) }}' class='text-secondary' title='Edit Resource'>
														<i class="material-symbols-rounded opacity-5">edit</i>
													</a>
													<a href='{{ path('app_community_resource_download', {id: r.id}) }}' class='text-secondary' title='Download vCard'>
														<i class="material-symbols-rounded opacity-5">import_contacts</i>
													</a>
												</td>
											</tr>
										{% endfor %}
									</tbody>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</main>
{% endblock %}
