//
//  PwFindCompleteViewController.m
//  OneCable
//
//  Created by nComz on 2017. 3. 31..
//  Copyright © 2017년 ntels. All rights reserved.
//

#import "PwFindCompleteViewController.h"
#import "RequestHandler.h"

@interface PwFindCompleteViewController ()

@end

@implementation PwFindCompleteViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self initUI];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}

- (void)initUI {
    
    [self.navigationController.navigationBar setHidden:YES];
    self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    
    [self.btnReReceive setBackgroundImage:[UIImage imageNamed:@"img_btn_common_active"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
    
    [self.btnReReceive setBackgroundImage:[UIImage imageNamed:@"img_btn_common_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
    
    [self.btnReReceive setBackgroundImage:[UIImage imageNamed:@"img_btn_common_disable"] forState:UIControlStateDisabled capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
    
    _lblUserName.text = [NSString stringWithFormat:@"%@%@",_findPwModel.nickname, @"님이 등록하신 휴대폰번호로\n임시 비밀번호가 전송되었습니다."];
    
    [_lblStep setColor:kUITextColor03 text:[NSString stringWithFormat:@"%@", @"/ 3"]];
}

- (IBAction)btnReReceiveTouched:(id)sender {
    
    [self requestTempPassword] ;
}


- (IBAction)btnLoginTouched:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}


//임시비밀번호 재전송 - 비밀번호 발급이랑 동일한 api 사용(cus_id 없음)
- (void)requestTempPassword {

    NSString *path = [NSString stringWithFormat:API_POST_PW_FIND, _memberId];
    NSDictionary *parameter = @{@"phone" : _phone,
                                @"quiz_id" : _quiz_id,
                                @"answer" : _answer};
    
    [[RequestHandler handler] sendAsyncPostRequestAPIPath:path parameters:parameter modelClass:[FindIdPwModel class] completion:^(id responseObject) {
        
        [[JDFacade facade] alert:@"임시 비밀번호를 재발송하였습니다."];
        
    } failure:^(id errorObject) {
       
        JDErrorModel *error = (JDErrorModel *)errorObject;
        [[JDFacade facade] alert:error.errorMessage];
        
        
    }];
    
}
@end
