Merge pull request #43 from Pear-Trading/finn/OrgAccountUpdatefix
fixing account edit for org
This commit is contained in:
commit
5452dac826
1 changed files with 34 additions and 15 deletions
|
@ -33,6 +33,9 @@ has error_messages => sub {
|
|||
town => {
|
||||
required => { message => 'No town sent.', status => 400 },
|
||||
},
|
||||
sector => {
|
||||
required => { message => 'No sector sent.', status => 400 },
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -60,21 +63,12 @@ sub post_account {
|
|||
|
||||
if ( defined $user_result ) {
|
||||
my $email = $user_result->email;
|
||||
my $full_name;
|
||||
my $display_name;
|
||||
my $postcode;
|
||||
|
||||
#Needs elsif added for trader page for this similar relevant entry
|
||||
if ( $user_result->type eq 'customer' ) {
|
||||
$full_name = $user_result->entity->customer->full_name;
|
||||
$display_name = $user_result->entity->customer->display_name;
|
||||
$postcode = $user_result->entity->customer->postcode;
|
||||
} elsif ( $user_result->type eq 'organisation' ) {
|
||||
$display_name = $user_result->entity->organisation->name;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
my $full_name = $user_result->entity->customer->full_name;
|
||||
my $display_name = $user_result->entity->customer->display_name;
|
||||
my $postcode = $user_result->entity->customer->postcode;
|
||||
return $c->render( json => {
|
||||
success => Mojo::JSON->true,
|
||||
full_name => $full_name,
|
||||
|
@ -82,6 +76,31 @@ sub post_account {
|
|||
email => $email,
|
||||
postcode => $postcode,
|
||||
});
|
||||
} elsif ( $user_result->type eq 'organisation' ) {
|
||||
my $name = $user_result->entity->organisation->name;
|
||||
my $postcode = $user_result->entity->organisation->postcode;
|
||||
my $street_name = $user_result->entity->organisation->street_name;
|
||||
my $town = $user_result->entity->organisation->town;
|
||||
my $sector = $user_result->entity->organisation->sector;
|
||||
return $c->render( json => {
|
||||
success => Mojo::JSON->true,
|
||||
town => $town,
|
||||
name => $name,
|
||||
sector => $sector,
|
||||
street_name => $street_name,
|
||||
email => $email,
|
||||
postcode => $postcode,
|
||||
});
|
||||
} else {
|
||||
return $c->render(
|
||||
json => {
|
||||
success => Mojo::JSON->false,
|
||||
message => 'Invalid Server Error.',
|
||||
},
|
||||
status => 500
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
return $c->render(
|
||||
json => {
|
||||
|
|
Reference in a new issue