//
//  SaleInputState.m
//  HDMall
//
//  Created by Javen on 2017/8/4.
//  Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//

#import "SaleInputState.h"

@implementation SaleInputState

- (instancetype)init {
    self = [super init];
    if (self) {
        self.dicData = @{ kSaleInputStateTypeIneffect : @{@"text" : @"待审核",
                                                          @"img" : @"img_state_list_daishenhe"},
                          kSaleInputStateTypeEffect : @{@"text" : @"已审核",
                                                        @"img" : @"img_state_list_yishenhe"} };
    }
    return self;
}

- (void)setCode:(NSString *)code {
    _code = code;
    self.text = [[self.dicData objectForKey:code] objectForKey:@"text"];
    self.img = [[self.dicData objectForKey:code] objectForKey:@"img"];
}

+ (SaleInputState *)stateWithText:(NSString *)text {
    SaleInputState *state = [SaleInputState new];
    for (NSString *key in state.dicData.allKeys) {
        NSDictionary *dic = [state.dicData objectForKey:key];
        if ([[dic objectForKey:@"text"] isEqualToString:text]) {
            state.code = key;
            break;
        }
    }
    return state;
}

+ (NSArray *)allStateCodes {
    SaleInputState *state = [SaleInputState new];
    return state.dicData.allKeys;
}
@end
