Skip to content

Commit

Permalink
feat: improve beeps list in app
Browse files Browse the repository at this point in the history
  • Loading branch information
bnussman committed Oct 20, 2024
1 parent 58bc598 commit ef8b0df
Showing 1 changed file with 34 additions and 12 deletions.
46 changes: 34 additions & 12 deletions app/components/Beep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Avatar } from "@/components/Avatar";
import { useUser } from "../utils/useUser";
import { Status } from "../utils/types";
import { openVenmo } from "@/utils/links";
import { RouterOutput } from "@/utils/trpc";
import { RouterOutput, trpc } from "@/utils/trpc";
import { printStars } from "./Stars";

interface Props {
Expand All @@ -27,6 +27,14 @@ export function Beep({ item }: Props) {
const otherUsersRating = item.ratings.find(
(r) => r.rater_id === otherUser.id,
);
const utils = trpc.useUtils();
const { mutateAsync: deleteRating } = trpc.rating.deleteRating.useMutation({
onSuccess() {
utils.beep.beeps.invalidate();
utils.rating.ratings.invalidate();
},
});

return (
<ContextMenu.Root>
<ContextMenu.Trigger action="press">
Expand Down Expand Up @@ -111,17 +119,31 @@ export function Beep({ item }: Props) {
</ContextMenu.ItemTitle>
</ContextMenu.Item>
)}
<ContextMenu.Item
key="rate"
onSelect={() =>
navigation.navigate("Rate", {
userId: otherUser.id,
beepId: item.id,
})
}
>
<ContextMenu.ItemTitle>Rate</ContextMenu.ItemTitle>
</ContextMenu.Item>
{myRating ? (
<ContextMenu.Item
key="delete-rating"
destructive
onSelect={() => {
if (myRating) {
deleteRating({ ratingId: myRating.id });
}
}}
>
<ContextMenu.ItemTitle>Delete Rating</ContextMenu.ItemTitle>
</ContextMenu.Item>
) : (
<ContextMenu.Item
key="rate"
onSelect={() =>
navigation.navigate("Rate", {
userId: otherUser.id,
beepId: item.id,
})
}
>
<ContextMenu.ItemTitle>Rate</ContextMenu.ItemTitle>
</ContextMenu.Item>
)}
<ContextMenu.Item
key="report"
onSelect={() =>
Expand Down

0 comments on commit ef8b0df

Please sign in to comment.