//
//  RDSRoomSetVC.m
//  Temperature
//
//  Created by RD on 2023/2/2.
//

#import "RDSRoomSetVC.h"

@interface RDSRoomSetVC ()
@property (weak, nonatomic) IBOutlet UILabel *nameLab;

@end

@implementation RDSRoomSetVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.title = @"房间设置";
    self.nameLab.text = _roomModel.name;
}

// 修改房间名称
- (IBAction)onRenameClick:(id)sender {
    RDS_WEAKSELF(weakSelf)
    [self rds_alertInputTitle:@"设置房间名" msg:nil placeholder:_roomModel.name doneAction:^(NSString *name) {
        [weakSelf setRoomName:name];
    }];
}

// 呼吸灯
- (IBAction)onLightClick:(id)sender {
    
}

// 检查更新
- (IBAction)onUpdate:(id)sender {
    
    [RDSHudShower showCenterToast:@"暂无更新"];
}


- (void)setRoomName:(NSString *)name{
    RDS_WEAKSELF(weakSelf)
    [RDSDemoApiHelper rds_updateRoomName:name record_id:_roomModel.record_id home_id:_roomModel.home_id success:^(id responseObject) {
        
        if ([responseObject[@"code"] intValue] != 0) {
            [RDSHudShower showBottomToast:responseObject[@"message"]];
        }else{
            weakSelf.nameLab.text = name;
        }
        
    } failure:^(NSError *error) {
        [RDSHudShower showBottomToast:@"连接服务器失败"];
    }];
}

@end
