Skip to content

Commit

Permalink
refactor: pr feedback - use entire result
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredrethman committed Oct 23, 2024
1 parent 46b0018 commit d95e89d
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/wizards/newspack/views/settings/additional-brands/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,12 @@ export default function AdditionalBrands() {
{
onSuccess( result ) {
setBrands( ( brandsList: Brand[] ) => {
// The result from the API call doesn't contain the logo details.
const newBrand = {
...brand,
id: result.id,
slug: result.slug,
};
// Is update
if ( 0 === brandId ) {
return [ newBrand, ...brandsList ];
return [ result, ...brandsList ];
}
return brandsList.map( b =>
brandId === b.id ? newBrand : b
brandId === b.id ? result : b
);
} );
history.push( TAB_PATH );
Expand Down

0 comments on commit d95e89d

Please sign in to comment.