fix: allow assigning cards to any member in a user's workspace

This commit is contained in:
Henry
2025-02-03 22:27:28 +00:00
parent eba5d9335c
commit 3ba600bc41
6 changed files with 49 additions and 16 deletions

View File

@@ -126,7 +126,6 @@ const getActivityIcon = (
fromIndex?: number | null,
toIndex?: number | null,
): React.ReactNode | null => {
console.log({ fromIndex, toIndex });
if (type === "card.updated.list" && fromIndex != null && toIndex != null) {
return fromIndex > toIndex ? (
<HiOutlineArrowLeft />

View File

@@ -4,6 +4,7 @@ import { HiMiniPlus } from "react-icons/hi2";
import Badge from "~/components/Badge";
import CheckboxDropdown from "~/components/CheckboxDropdown";
import { useModal } from "~/providers/modal";
import { usePopup } from "~/providers/popup";
import { api } from "~/utils/api";
interface LabelSelectorProps {
@@ -14,6 +15,7 @@ interface LabelSelectorProps {
selected: boolean;
leftIcon: React.ReactNode;
}[];
refetchCard: () => Promise<void>;
handleSelectLabel: (labelPublicId: string) => void;
isLoading: boolean;
}
@@ -21,18 +23,25 @@ interface LabelSelectorProps {
export default function LabelSelector({
cardPublicId,
labels,
refetchCard,
handleSelectLabel,
isLoading,
}: LabelSelectorProps) {
const { openModal } = useModal();
const utils = api.useUtils();
const refetchCard = () => utils.card.byId.refetch({ cardPublicId });
const { showPopup } = usePopup();
const addOrRemoveLabel = api.card.addOrRemoveLabel.useMutation({
onSuccess: async () => {
await refetchCard();
},
onError: async () => {
await refetchCard();
showPopup({
header: "Unable to update labels",
message: "Please try again later, or contact customer support.",
icon: "error",
});
},
});
const selectedLabels = labels.filter((label) => label.selected);

View File

@@ -1,6 +1,7 @@
import { Menu } from "@headlessui/react";
import CheckboxDropdown from "~/components/CheckboxDropdown";
import { usePopup } from "~/providers/popup";
import { api } from "~/utils/api";
interface ListSelectorProps {
@@ -10,6 +11,7 @@ interface ListSelectorProps {
value: string;
selected: boolean;
}[];
refetchCard: () => Promise<void>;
handleChangeList: (newListPublicId: string, newListName: string) => void;
isLoading: boolean;
}
@@ -18,16 +20,23 @@ export default function ListSelector({
cardPublicId,
lists,
handleChangeList,
refetchCard,
isLoading,
}: ListSelectorProps) {
const utils = api.useUtils();
const refetchCard = () => utils.card.byId.refetch({ cardPublicId });
const { showPopup } = usePopup();
const updateCardList = api.card.reorder.useMutation({
onSuccess: async () => {
await refetchCard();
},
onError: async () => {
await refetchCard();
showPopup({
header: "Unable to update list",
message: "Please try again later, or contact customer support.",
icon: "error",
});
},
});
const selectedList = lists.find((list) => list.selected);

View File

@@ -18,6 +18,7 @@ interface MemberSelectorProps {
imageUrl: string | undefined;
}[];
handleSelectMember: (memberPublicId: string) => void;
refetchCard: () => Promise<void>;
isLoading: boolean;
}
@@ -25,14 +26,12 @@ export default function MemberSelector({
cardPublicId,
members,
handleSelectMember,
refetchCard,
isLoading,
}: MemberSelectorProps) {
const router = useRouter();
const { openModal } = useModal();
const { showPopup } = usePopup();
const utils = api.useUtils();
const refetchCard = () => utils.card.byId.refetch({ cardPublicId });
const addOrRemoveMember = api.card.addOrRemoveMember.useMutation({
onSuccess: async () => {