package com.adealink.weparty.joinus.data

import android.os.Parcelable
import com.adealink.weparty.util.parseDate
import com.adealink.weparty.module.widget.form.data.StepField
import com.google.gson.annotations.GsonNullable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize

enum class JoinUsStep(val step: String) {
    UNDER_REVIEW("under_review"), //等待审核
    STEP_1("step_1"), //步骤1
    STEP_2("step_2"), //步骤2
    STEP_3("step_3"), //步骤3
}

@Parcelize
data class JoinUsData(
    @SerializedName("underReview") val underReview: Boolean, //是否有申请正在审核中

    @SerializedName("step1Complete") val step1Complete: Boolean,//步骤1是否完成
    @GsonNullable
    @SerializedName("setp1") val step1: JoinStep1? = null,//步骤1

    @SerializedName("step2Complete") val step2Complete: Boolean,//步骤2是否完成
    @GsonNullable
    @SerializedName("setp2") val step2: JoinStep2? = null,//步骤2

    @SerializedName("step3Complete") val step3Complete: Boolean,//步骤3是否完成
    @GsonNullable
    @SerializedName("setp3") val step3: JoinStep3? = null,//步骤3
) : Parcelable {
    fun getCurrentStep(): JoinUsStep? {
        return when {
            underReview -> {
                JoinUsStep.UNDER_REVIEW
            }

            !step1Complete && !step2Complete && !step3Complete -> {
                null
            }

            !step1Complete -> {
                JoinUsStep.STEP_1
            }

            step1Complete && !step2Complete -> {
                JoinUsStep.STEP_2
            }

            step1Complete && step2Complete && !step3Complete -> {
                JoinUsStep.STEP_3
            }

            else -> {
                null
            }
        }
    }
}


@Parcelize
data class JoinStep1(
    @SerializedName("mobileNum") val mobile: String, //手机号
    @SerializedName("mobileCode") val regionCode: String, //手机区号
) : Parcelable


data class SendPhoneVerifyReq(
    @SerializedName("code") val code: String,
    @SerializedName("num") val num: String,
)


data class BindPhoneReq(
    @SerializedName("mobile") val mobile: MobileData,
    @SerializedName("code") val verifyCode: String,
)

data class MobileData(
    @SerializedName("code") val code: String,
    @SerializedName("num") val num: String,
)

@Parcelize
data class JoinStep2(
    @GsonNullable
    @SerializedName("avatar") val avatar: String?, //头像
    @GsonNullable
    @SerializedName("nickname") val nickname: String?, //昵称
    @GsonNullable
    @SerializedName("gender") val gender: Int?, //昵称
    @GsonNullable
    @SerializedName("birthday") val birthday: String?, //	生日：格式yyyy-MM-dd
    @GsonNullable
    @SerializedName("languageCodes") val languageCodes: List<String>?, //语言-从通用常量配置获取
    @GsonNullable
    @SerializedName("intro") val intro: String?, //简介
) : Parcelable {
    fun getBirthdayTs(): Long? {
        return parseDate(birthday)?.time
    }
}


data class ImproveUserInfoReq(
    @SerializedName("avatar") val avatar: String?, //头像
    @SerializedName("nickname") val nickname: String?, //昵称
    @SerializedName("gender") val gender: Int?, //昵称
    @SerializedName("birthday") val birthday: String?, //	生日：格式yyyy-MM-dd
    @SerializedName("languageCodes") val languageCodes: List<String>?, //语言-从通用常量配置获取
    @SerializedName("intro") val intro: String?, //简介
)

@Parcelize
data class JoinStep3(
    @SerializedName("bizCategoryCode") val categoryCode: String, //品类
    @SerializedName("fields") val fields: List<StepField<*>>, //申请步骤
) : Parcelable

