//
//  SetEcaArea.swift
//  Sailassist
//
//  Created by 三浦薫巳 on 2023/11/28.
//

import Foundation
import SwiftUI

class SetEcaArea {
    @ObservedObject var ecaData = SharingData.eca
    var sessionTaskList = SessionTaskList()

    func start(eca : ReqTaskList) {
        print(debug: "called")
        var ecaTmp = eca
        if ecaTmp.status == serverFinishPass {
            ecaTmp.status = serverNoFinished   //SSVのアラート履歴にNo Finishedを記録するために変換
        }
        sessionTaskList.RequestPostTaskList(ecaTmp, completion: responsePostTaskList)
    }

    private func responsePostTaskList(result: Result<Data, APIError>) {
        print(debug: "called")
        switch result {
        case .success(let errorCode):
            print(debug: "success: \(errorCode)")
        case .failure(let errorCode):
            print(debug: "failure: \(errorCode)")
            break
        }
    }
}
