style: clean up code formatting and remove trailing whitespace
refactor: reorganize imports and fix type imports
This commit is contained in:
1 parent
d3704602fd
commit
47c04de6fe
232 files changed
+7140
-4798
No files matched your search
@@ -7,7 +7,10 @@ import { prisma } from "../app";
|
||||
/**
|
||||
* Verifica se um anúncio está favoritado por um usuário
|
||||
*/
|
||||
export async function isFavorite(userId: number, listingId: number): Promise<boolean> {
|
||||
export async function isFavorite(
|
||||
userId: number,
|
||||
listingId: number,
|
||||
): Promise<boolean> {
|
||||
const favorite = await prisma.userFavorite.findUnique({
|
||||
where: {
|
||||
user_id_ad_id: {
|
||||
@@ -23,7 +26,10 @@ export async function isFavorite(userId: number, listingId: number): Promise<boo
|
||||
/**
|
||||
* Favorita um anúncio
|
||||
*/
|
||||
export async function addFavorite(userId: number, listingId: number): Promise<void> {
|
||||
export async function addFavorite(
|
||||
userId: number,
|
||||
listingId: number,
|
||||
): Promise<void> {
|
||||
await prisma.userFavorite.upsert({
|
||||
where: {
|
||||
user_id_ad_id: {
|
||||
@@ -42,23 +48,31 @@ export async function addFavorite(userId: number, listingId: number): Promise<vo
|
||||
/**
|
||||
* Remove favorito de um anúncio
|
||||
*/
|
||||
export async function removeFavorite(userId: number, listingId: number): Promise<void> {
|
||||
await prisma.userFavorite.delete({
|
||||
where: {
|
||||
user_id_ad_id: {
|
||||
user_id: userId,
|
||||
ad_id: listingId,
|
||||
export async function removeFavorite(
|
||||
userId: number,
|
||||
listingId: number,
|
||||
): Promise<void> {
|
||||
await prisma.userFavorite
|
||||
.delete({
|
||||
where: {
|
||||
user_id_ad_id: {
|
||||
user_id: userId,
|
||||
ad_id: listingId,
|
||||
},
|
||||
},
|
||||
},
|
||||
}).catch(() => {
|
||||
// Ignorar erro se não existir (idempotente)
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
// Ignorar erro se não existir (idempotente)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle favorite (favorita se não estiver, desfavorita se estiver)
|
||||
*/
|
||||
export async function toggleFavorite(userId: number, listingId: number): Promise<boolean> {
|
||||
export async function toggleFavorite(
|
||||
userId: number,
|
||||
listingId: number,
|
||||
): Promise<boolean> {
|
||||
const isFavorited = await isFavorite(userId, listingId);
|
||||
|
||||
if (isFavorited) {
|
||||
@@ -69,4 +83,3 @@ export async function toggleFavorite(userId: number, listingId: number): Promise
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user