@using atakanozbancom.Models.classes
@model List<socialicon>

@{
    ViewBag.Title = "socialicons";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" />

<h2 class="text-white mt-3 mb-3">Social Icons</h2>
<p class="text-white-50">These appear as the icon row at the bottom of every public page.</p>
@if (TempData["ok"] != null)
{<div class="alert alert-success">@TempData["ok"]</div>}

<table class="table table-bordered mt-3">
    <tr class="bg-dark text-white">
        <th class="bg-dark text-white">Icon</th>
        <th class="bg-dark text-white">Class</th>
        <th class="bg-dark text-white">URL</th>
        <th class="bg-dark text-white">Order</th>
        <th class="bg-dark text-white">Edit</th>
        <th class="bg-dark text-white">Delete</th>
    </tr>
    @foreach (var x in Model)
    {
        <tr>
            <td class="bg-dark text-white fs-4"><i class="@x.icon"></i></td>
            <td class="bg-dark text-white">@x.icon</td>
            <td class="bg-dark text-white" style="word-break:break-all;">@x.url</td>
            <td class="bg-dark text-white">@x.sort_order</td>
            <td class="bg-dark text-white"><a href="/admin/socialiconget/@x.id" class="btn btn-primary">Edit</a></td>
            <td class="bg-dark text-white">
                @using (Html.BeginForm("socialicondelete", "admin", new { id = x.id }, FormMethod.Post, new { onsubmit = "return confirm('Delete this icon?');" }))
                {
                    @Html.AntiForgeryToken()
                    <button type="submit" class="btn btn-danger">Delete</button>
                }
            </td>
        </tr>
    }
    @if (!Model.Any())
    {
        <tr>
            <td class="bg-dark text-white-50" colspan="6">No social icons yet.</td>
        </tr>
    }
</table>
<a href="/admin/newsocialicon" class="btn btn-primary">Create New Icon</a>
