//
//  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" : @"StateIneffect"},
                          kSaleInputStateTypeEffect : @{@"text" : @"已生效",
                                                        @"img" : @"StateEffect"} };
    }
    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
