//
//  PLJobsView.swift
//  IOS_study
//
//  Created by CC-star on 2025/6/12.
//

import SwiftUI

struct PLJobsView: View {
   @Environment(PLJobViewModel.self) var vm
   @State var naviPath = NavigationPath()
   var body: some View {
      NavigationStack(path: $naviPath) {
         List{
            ForEach(vm.jobs) {job in
               Button {
                  vm.job = job
                  naviPath.append(Navi1.PLJobsToPLJob)
               } label: {
                  PLJobCellView(job: job)
               }.buttonStyle(.borderless)
            }.listRowStyle()
         }.listStyle()
            .navigationDestination(for: Navi1.self) { navi in
               switch navi {
               case .PLJobsToPLJob : PLJobView(naviPath: $naviPath)
               case .PLJobToEdit : PostPLJobIView(isEditing: true,naviPath: $naviPath)
               }
            }
      }
   }
}

#Preview {
   PLJobsView()
}
