Skip to content

Commit 0257b01

Browse files
committed
chore: fix sonarcube errors
1 parent 113a4d0 commit 0257b01

4 files changed

Lines changed: 29 additions & 21 deletions

File tree

server/src/shared/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import type { User } from "@/modules/auth/auth.types.js";
22
import type { Product } from "@/modules/products/products.types.js";
3-
import type { MarketingProduct } from "@/modules/marketing/marketing.types.js";
3+
import type {
4+
MarketingProduct,
5+
Review,
6+
} from "@/modules/marketing/marketing.types.js";
47
import type { Cart } from "@/modules/carts/carts.types.js";
5-
import type { Review } from "@/modules/marketing/marketing.types.js";
68

79
export interface DatabaseSchema {
810
users: User[];

src/features/marketing/reviews/components/WriteReviewButton.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ const WriteReviewButton = ({ productId, initialRating }: IProps) => {
2222

2323
if (!isAuthenticated) return null;
2424

25-
const label = currentUserReview
26-
? currentUserReview.title || currentUserReview.comment
27-
? t("edit-review")
28-
: t("add-review-details")
29-
: t("write-review");
25+
const getLabel = () => {
26+
if (!currentUserReview) return t("write-review");
27+
if (currentUserReview.title || currentUserReview.comment)
28+
return t("edit-review");
29+
return t("add-review-details");
30+
};
31+
const label = getLabel();
3032

3133
return (
3234
<>

src/features/marketing/reviews/providers/use-create-review-mutation.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ export const useCreateReviewMutation = (productId: string) => {
1313

1414
const { mutateAsync, isPending } = useMutation({
1515
...createReviewMutationOptions,
16-
onSuccess: () => {
17-
void queryClient.invalidateQueries({
18-
queryKey: marketingQueryKeys.product(productId),
19-
});
20-
void queryClient.invalidateQueries({
21-
queryKey: marketingQueryKeys.reviews(productId),
22-
});
16+
onSuccess: async () => {
17+
await Promise.all([
18+
queryClient.invalidateQueries({
19+
queryKey: marketingQueryKeys.product(productId),
20+
}),
21+
queryClient.invalidateQueries({
22+
queryKey: marketingQueryKeys.reviews(productId),
23+
}),
24+
]);
2325
},
2426
});
2527

src/features/marketing/reviews/providers/use-update-review-mutation.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ export const useUpdateReviewMutation = (productId: string) => {
1111

1212
const { mutateAsync, isPending } = useMutation({
1313
...updateReviewMutationOptions,
14-
onSuccess: () => {
15-
void queryClient.invalidateQueries({
16-
queryKey: marketingQueryKeys.product(productId),
17-
});
18-
void queryClient.invalidateQueries({
19-
queryKey: marketingQueryKeys.reviews(productId),
20-
});
14+
onSuccess: async () => {
15+
await Promise.all([
16+
queryClient.invalidateQueries({
17+
queryKey: marketingQueryKeys.product(productId),
18+
}),
19+
queryClient.invalidateQueries({
20+
queryKey: marketingQueryKeys.reviews(productId),
21+
}),
22+
]);
2123
},
2224
});
2325

0 commit comments

Comments
 (0)