import { _decorator, Component, Node } from "cc";
import BaseUI from "../../scripts/base/BaseUI";
import Utils from "../../scripts/utils/Utils";
import { FamilyMember } from "../../scripts/api/FamilyM";
const { ccclass, property } = _decorator;

@ccclass("FamilyMemberItem")
export class FamilyMemberItem extends BaseUI {
  init(pd: FamilyMember) {
    this.setText("lbl_user_name", pd.userName);
    let totalXp = pd.totalXp;
    if (totalXp < pd.dailyXp) {
      totalXp = pd.dailyXp;
    }
    let expStr = `today:${Utils.formatNumber(
      Number(pd.dailyXp),
      1
    )} total:${Utils.formatNumber(Number(totalXp), 1)}`;
    this.setText("lbl_exp", expStr);
  }
}
