@infrab4a/connect-angular 4.9.3-beta.0 → 4.9.4-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1981,14 +1981,21 @@ class WishlistService {
1981
1981
  personType: personType ?? PersonTypes.NONE,
1982
1982
  personIsSubscriber: personIsSubscriber ?? false,
1983
1983
  };
1984
- // const hasWishlist = await this.wishlistRepository
1985
- // .find({
1986
- // filters: {
1987
- // personId,
1988
- // },
1989
- // })
1990
- // .then((res) => res.count)
1991
- // if (hasWishlist) throw 'Usuário já possui Wishlist'
1984
+ const hasWishlist = await this.wishlistRepository
1985
+ .find({
1986
+ filters: {
1987
+ personId,
1988
+ },
1989
+ options: {
1990
+ enableCount: false,
1991
+ },
1992
+ orderBy: {
1993
+ id: 'asc',
1994
+ },
1995
+ })
1996
+ .then((res) => res.data);
1997
+ if (hasWishlist.length)
1998
+ return hasWishlist.at(0);
1992
1999
  const newWishlist = await this.wishlistRepository.create(data);
1993
2000
  await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
1994
2001
  return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });