<div class="container mx-auto p-4">
  <div class="bg-white rounded-lg shadow-md p-6">
    <h1 class="text-2xl font-bold mb-4">My Listings</h1>

    <!-- Desktop view -->
    <div class="hidden md:block">
      <table class="w-full bg-white shadow-md rounded-lg overflow-hidden">
        <thead class="bg-gray-100">
          <tr>
            <th class="py-2 px-4 text-left">Title</th>
            <th class="py-2 px-4 text-left">Category</th>
            <th class="py-2 px-4 text-left">Located in</th>
            <th class="py-2 px-4 text-left">Actions</th>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let listing of myListings" class="border-b">
            <td class="py-2 px-4">{{ listing.title }}</td>
            <td class="py-2 px-4">{{ listing.listingsCategory === 'commercialProperty' ? 'Commercial Property' : 'Business' }}</td>
            <td class="py-2 px-4">{{ listing.location.state }}</td>
            <td class="py-2 px-4">
              @if(listing.listingsCategory==='business'){
              <button class="bg-green-500 text-white p-2 rounded-full mr-2" [routerLink]="['/editBusinessListing', listing.id]">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                  <path d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" />
                </svg>
              </button>
              } @if(listing.listingsCategory==='commercialProperty'){
              <button class="bg-green-500 text-white p-2 rounded-full mr-2" [routerLink]="['/editCommercialPropertyListing', listing.id]">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                  <path d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" />
                </svg>
              </button>
              }
              <button class="bg-orange-500 text-white p-2 rounded-full" (click)="confirm(listing)">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                  <path
                    fill-rule="evenodd"
                    d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z"
                    clip-rule="evenodd"
                  />
                </svg>
              </button>
            </td>
          </tr>
        </tbody>
      </table>
    </div>

    <!-- Mobile view -->
    <div class="md:hidden">
      <div *ngFor="let listing of myListings" class="bg-white shadow-md rounded-lg p-4 mb-4">
        <h2 class="text-xl font-semibold mb-2">{{ listing.title }}</h2>
        <p class="text-gray-600 mb-2">Category: {{ listing.listingsCategory === 'commercialProperty' ? 'Commercial Property' : 'Business' }}</p>
        <p class="text-gray-600 mb-4">Located in: {{ listing.location.city }} - {{ listing.location.state }}</p>
        <div class="flex justify-end">
          <button class="bg-green-500 text-white p-2 rounded-full mr-2">
            <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
              <path d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" />
            </svg>
          </button>
          <button class="bg-orange-500 text-white p-2 rounded-full">
            <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
              <path
                fill-rule="evenodd"
                d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z"
                clip-rule="evenodd"
              />
            </svg>
          </button>
        </div>
      </div>
    </div>

    <div class="flex items-center justify-between mt-4">
      <p class="text-sm text-gray-600">Showing 1 to 2 of 2 entries</p>
      <div class="flex items-center">
        <button class="px-2 py-1 border rounded-l-md bg-gray-100">&lt;&lt;</button>
        <button class="px-2 py-1 border-t border-b bg-gray-100">&lt;</button>
        <button class="px-2 py-1 border bg-blue-500 text-white">1</button>
        <button class="px-2 py-1 border-t border-b bg-gray-100">&gt;</button>
        <button class="px-2 py-1 border rounded-r-md bg-gray-100">&gt;&gt;</button>
        <select class="ml-2 border rounded-md px-2 py-1">
          <option>10</option>
        </select>
      </div>
    </div>
  </div>
</div>
<app-confirmation></app-confirmation>
<!-- <div class="surface-ground px-4 py-8 md:px-6 lg:px-8 h-full">
  <div class="p-fluid flex flex-column lg:flex-row">
    <menu-account></menu-account>
    <p-toast></p-toast>
    <p-confirmPopup></p-confirmPopup>
    <div class="surface-card p-5 shadow-2 border-round flex-auto">
      <div class="text-900 font-semibold text-lg mt-3">My Listings</div>
      <p-divider></p-divider>
      <p-table
        [value]="myListings"
        [tableStyle]="{ 'min-width': '50rem' }"
        dataKey="id"
        [paginator]="true"
        [rows]="10"
        [rowsPerPageOptions]="[10, 20, 50]"
        [showCurrentPageReport]="true"
        currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries"
      >
        <ng-template pTemplate="header">
          <tr>
            <th class="wide-column">Title</th>
            <th>Category</th>
            <th>Located in</th>
            <th></th>
          </tr>
        </ng-template>
        <ng-template pTemplate="body" let-listing>
          <tr>
            <td class="wide-column line-height-3">{{ listing.title }}</td>
            <td>{{ selectOptions.getListingsCategory(listing.listingsCategory) }}</td>
            <td>{{ selectOptions.getState(listing.state) }}</td>
            <td>
              @if(listing.listingsCategory==='business'){
              <button pButton pRipple icon="pi pi-pencil" class="p-button-rounded p-button-success mr-2" [routerLink]="['/editBusinessListing', listing.id]"></button>
              } @if(listing.listingsCategory==='commercialProperty'){
              <button pButton pRipple icon="pi pi-pencil" class="p-button-rounded p-button-success mr-2" [routerLink]="['/editCommercialPropertyListing', listing.id]"></button>
              }
              <button pButton pRipple icon="pi pi-trash" class="p-button-rounded p-button-warning" (click)="confirm($event, listing)"></button>
            </td>
          </tr>
        </ng-template>
      </p-table>
    </div>
  </div>
</div> -->
