//
//  LSPanelistAchievementSummary+RCTNativeModel.m
//  ReactLightspeedSDK
//
//  Created by marc matta on 12/12/16.
//  Copyright © 2016 com.lightspeed. All rights reserved.
//

#import "LSPanelistAchievementSummary+RCTNativeModel.h"

#import "LSPanelistAchievement+RCTNativeModel.h"
#import <React/RCTUtils.h>

@implementation LSPanelistAchievementSummary (RCTNativeModel)
- (NSDictionary *)reactNativeRepresentation {
    NSMutableArray *achievements;
    for (LSPanelistAchievement *ach in self.achievements) {
        if (!achievements)
            achievements = [NSMutableArray array];
        
        [achievements addObject:[ach reactNativeRepresentation]];
    }
    
    NSMutableArray *redemptions;
    for (LSPanelistAchievement *ach in self.redemptions) {
        if (!redemptions)
            redemptions = [NSMutableArray array];
        
        [redemptions addObject:[ach reactNativeRepresentation]];
    }
    
    return @{
             @"achievements":RCTNullIfNil(achievements),
             @"redemptions":RCTNullIfNil(redemptions),
             @"totalPoints":@(RCTZeroIfNaN(self.totalPoints)),
             @"totalSweeps":@(RCTZeroIfNaN(self.totalSweeps))
             };
}

@end
