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

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

@implementation LSUserProfile (RCTNativeModel)

- (NSDictionary *)reactNativeRepresentation {
    NSMutableArray *achievements;
    for (LSAchievement *achievement in self.achievements) {
        if (!achievements)
            achievements = [NSMutableArray array];
        
        [achievements addObject:[achievement reactNativeRepresentation]];
    }

    return @{@"panelistId": @(RCTZeroIfNaN(self.panelistId)),
             @"panelistInfoId": @(RCTZeroIfNaN(self.panelistInfoId)),
             @"panelId": @(RCTZeroIfNaN(self.panelId)),
             @"email": RCTNullIfNil(self.email),
             @"firstName": RCTNullIfNil(self.firstName),
             @"lastName": RCTNullIfNil(self.lastName),
             @"birthdate": RCTNullIfNil(self.birthdate),
             @"gender": @(RCTZeroIfNaN(self.gender) == 0 ? 1 : self.gender),
             @"address1": RCTNullIfNil(self.address1),
             @"address2": RCTNullIfNil(self.address2),
             @"city": RCTNullIfNil(self.city),
             @"state": RCTNullIfNil(self.state),
             @"country": RCTNullIfNil(self.country),
             @"countryId": @(RCTZeroIfNaN(self.countryId)),
             @"languageId": @(RCTZeroIfNaN(self.languageId)),
             @"mobileAppJoinDate": RCTNullIfNil(self.mobileAppJoinDate),
             @"fbLinked": @(self.fbLinked),
             @"totalPoints": @(RCTZeroIfNaN(self.totalPoints)),
             @"sociallyRegistered": @(self.sociallyRegistered),
             @"hitOrMissUrl": RCTNullIfNil(self.hitOrMissUrl),
             @"hitOrMissAvailable": @(RCTZeroIfNaN(self.hitOrMissAvailable)),
             @"zipCode": RCTNullIfNil(self.zipCode),
             @"dailyQuiz": @(RCTZeroIfNaN(self.dailyQuiz)),
             @"achievements": RCTNullIfNil(achievements),
             @"mobileAppUserType": @(RCTZeroIfNaN(self.mobileAppUserType) == 0 ? LSMobileAppUserTypeDual : self.mobileAppUserType),
             @"socialRegistration": @(self.socialRegistration),
             @"languageIsoCode": RCTNullIfNil(self.languageIsoCode),
             @"countryIsoCode": RCTNullIfNil(self.countryIsoCode),
             @"isNewUser": RCTNullIfNil(self.isNewUser)
             };
}
@end
