
import 'package:cims_apps/application/assets/path_assets.dart';
import 'package:cims_apps/application/theme/color_palette.dart';
import 'package:flutter/material.dart';

class RiskProfileQuestion {
  String img;
  int selectedScore;
  String question;
  List<Answer> answers;

  RiskProfileQuestion(this.img, this.question, this.selectedScore, this.answers);
}

class RiskProfileResult {
  String type;
  String img;
  String desc;
  Color color;
  List<dynamic> suitableProduct;

  RiskProfileResult(this.type, this.img, this.color, this.desc, this.suitableProduct);
}

class Answer {
  int score;
  String title;

  Answer(this.score, this.title);
}

class RiskProfileViewModel extends ChangeNotifier {
  List<int> listScore = [0,0,0,0,0];
  RiskProfileResult typeResult = RiskProfileResult('', '', Colors.transparent, '', []);

  List<RiskProfileQuestion> listRiskProfileQuestion = [
    RiskProfileQuestion(
        PathAssets.imgGrowing, 'How long is your planned investment horizon?', 0,
        [
          Answer(2, '<1 year'),
          Answer(4, '1-3 year'),
          Answer(6, '3-5 year'),
          Answer(8, '>5 year')
        ]
    ),
    RiskProfileQuestion(
        PathAssets.imgLeader, 'Investment objectives of mutualfund investors?', 0,
        [
          Answer(2, 'Security of Investment Funds'),
          Answer(4, 'Investment Income and Security'),
          Answer(6, 'Revenue and growth over the long term'),
          Answer(8, 'Growth')
        ]
    ),
    RiskProfileQuestion(
        PathAssets.imgBusinessFailure, 'How much can I afford to lose on my investment (Risk level you can afford)?', 0,
        [
          Answer(2, '0%'),
          Answer(4, '<25%'),
          Answer(6, '26-50%'),
          Answer(8, '>50%')
        ]
    ),
    RiskProfileQuestion(
        PathAssets.imgMoneyIncome, 'I am willing to use .... % of my income for investment (financial circumstances of the financier)?', 0,
        [
          Answer(2, '0%'),
          Answer(4, '<25%'),
          Answer(6, '26-50%'),
          Answer(8, '>50%')
        ]
    ),
    RiskProfileQuestion(
        PathAssets.imgDataAnalysis, 'Mutual Fund Investment Knowledge Level?', 0,
        [
          Answer(2, 'Low'),
          Answer(4, 'Medium'),
          Answer(6, 'High'),
        ]
    )
  ];

  List<RiskProfileResult> listRiskProfileResult = [
    RiskProfileResult(
        'Conservative',
        PathAssets.imgCat,
        ColorPalette.green500,
        'Investors with a conservative risk profile are risk-averse or do not want to experience large losses. Therefore, mutual fund products that are suitable for conservative investors are products that have low risk and stable returns.',
        [
          {'desc': 'Money Market Mutual Fund', 'icon': PathAssets.iconStrongBox},
          {'desc': 'Fixed Income Mutual Fund', 'icon': PathAssets.iconMoneyReceive},
          {'desc': 'Balanced Mutual Fund', 'icon': PathAssets.iconBalance},
        ]
    ),
    RiskProfileResult(
        'Moderate',
        PathAssets.imgDeer,
        ColorPalette.orange500,
        'Investors with a moderate risk profile are investors who are ready to accept moderate risk to get higher returns than conservative mutual fund products. Therefore, mutual fund products that are suitable for moderate investors are products that have moderate risk and higher returns than conservative mutual fund products.',
        [
          {'desc': 'Fixed Income Mutual Fund', 'icon': PathAssets.iconMoneyReceive},
          {'desc': 'Balanced Mutual Fund', 'icon': PathAssets.iconBalance},
        ]
    ),
    RiskProfileResult(
        'Aggressive',
        PathAssets.imgLion,
        ColorPalette.purple500,
        'Investors with an aggressive risk profile are investors who are ready to accept high risks to get high returns. Therefore, mutual fund products that are suitable for aggressive investors are products that have high risk and high returns.',
        [
          {'desc': 'Equity Mutual Fund', 'icon': PathAssets.iconCoins},
          {'desc': 'Aggressive Balanced Fund', 'icon': PathAssets.iconBalance},
        ]
    )
  ];

  void selectedAnswer(int index, int score) {
    listScore[index] = score;
    listRiskProfileQuestion[index].selectedScore = score;
    notifyListeners();
  }

  void setTypeResult(int totalScore) {
    if(totalScore <= 25){
      typeResult = listRiskProfileResult[0];
    }else if(totalScore <= 50){
      typeResult = listRiskProfileResult[1];
    }else{
      typeResult = listRiskProfileResult[2];
    }
    notifyListeners();
  }
}