Skip to content

Commit

Permalink
Sort notifications by scheduledAt and createdAt ...
Browse files Browse the repository at this point in the history
Hide action menu when click cancel notification
  • Loading branch information
WalissonPires committed Mar 17, 2024
1 parent 4560d07 commit a29c8ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/components/NotificationCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ export default function NotificationCard({ notification, showContact, onCancelCl
const allowCancel = !canceledAt && !sendedAt;
const hasActions = allowCancel;

const handleCancel = () => {

setVisible(false);
onCancelClick?.();
};

return (
<div className="flex flex-row justify-between px-4 py-6 hover:bg-slate-50">
<div className="flex flex-col flex-1">
Expand All @@ -36,7 +42,7 @@ export default function NotificationCard({ notification, showContact, onCancelCl
<DropdownMenu
visible={visible}
toggle={<DropdownMenuToggle onClick={() => setVisible(!visible)}><EllipsisVerticalIcon className="h-5 w-5"/></DropdownMenuToggle>}>
{allowCancel && <DropdownMenuItem onClick={onCancelClick}>
{allowCancel && <DropdownMenuItem onClick={handleCancel}>
<span><XMarkIcon className="h-5 w-5 inline-block" /> Cancelar envio</span>
</DropdownMenuItem>}
{!hasActions && <DropdownMenuItem>Nenhum ação</DropdownMenuItem>}
Expand Down
6 changes: 4 additions & 2 deletions src/domains/notifications/use-cases/get-notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ export class GetNotifications implements UseCase<GetNotificationsInput, PagedRes
}
}
},
orderBy: {
orderBy: [{
scheduledAt: 'desc'
}
}, {
createdAt: 'asc'
}]
});

const mapper = new NotificationMapper();
Expand Down

0 comments on commit a29c8ac

Please sign in to comment.