+ {activities?.map((activity, index) => {
+ const activityText = getActivityText({
+ type: activity.type,
+ toTitle: activity.toTitle,
+ fromList: activity.fromList?.name ?? null,
+ toList: activity.toList?.name ?? null,
+ memberName: activity.member?.user?.name ?? null,
+ isSelf: activity.member?.user?.id === activity.user?.id,
+ label: activity.label?.name ?? null,
+ });
+
+ if (!activityText) return null;
+
+ return (
+
+
+
+ {index !== activities.length - 1 && (
+
+ )}
+
+
+ {`${activity.user?.name} `}
+
+ {activityText}
+
+ ยท
+
+ {formatDistanceToNow(new Date(activity.createdAt), {
+ addSuffix: true,
+ })}
+
+
+
+ );
+ })}
+
+ );
+};
+
+export default ActivityList;
diff --git a/src/views/card/index.tsx b/src/views/card/index.tsx
index 3de0495e..e396e3a9 100644
--- a/src/views/card/index.tsx
+++ b/src/views/card/index.tsx
@@ -4,6 +4,7 @@ import { useForm } from "react-hook-form";
import ContentEditable from "react-contenteditable";
import { IoChevronForwardSharp } from "react-icons/io5";
+import ActivityList from "./components/ActivityList";
import Dropdown from "./components/Dropdown";
import { DeleteCardConfirmation } from "./components/DeleteCardConfirmation";
import { DeleteLabelConfirmation } from "./components/DeleteLabelConfirmation";
@@ -15,6 +16,7 @@ import { NewWorkspaceForm } from "~/components/NewWorkspaceForm";
import Modal from "~/components/modal";
import { useModal } from "~/providers/modal";
+import { usePopup } from "~/providers/popup";
import { api } from "~/utils/api";
@@ -26,7 +28,9 @@ interface FormValues {
export default function CardPage() {
const params = useParams();
+ const utils = api.useUtils();
const { modalContentType, entityId } = useModal();
+ const { showPopup } = usePopup();
const cardId = Array.isArray(params?.cardId)
? params.cardId[0]
@@ -39,6 +43,7 @@ export default function CardPage() {
const board = data?.list?.board;
const boardId = board?.publicId;
const labels = board?.labels;
+ const activities = data?.activities;
const workspaceMembers = board?.workspace?.members;
const selectedLabels = data?.labels;
const selectedMembers = data?.members;
@@ -75,7 +80,17 @@ export default function CardPage() {
};
}) ?? [];
- const updateCard = api.card.update.useMutation();
+ const updateCard = api.card.update.useMutation({
+ onSuccess: async () => {
+ await utils.card.byId.refetch();
+ },
+ onError: () => {
+ showPopup({
+ header: "Unable to update card",
+ message: "Please try again later, or contact customer support.",
+ });
+ },
+ });
const { register, handleSubmit, setValue, watch } = useForm