diff --git a/frontend/src/components/Communications.vue b/frontend/src/components/Communications.vue index 00113d42..911db2b9 100644 --- a/frontend/src/components/Communications.vue +++ b/frontend/src/components/Communications.vue @@ -346,6 +346,7 @@ import { ThreadChannel, ThreadKind } from "@/dto/threads"; import type { ParticipationCommunications, ThreadWithEntry, + CreateThread, } from "@/dto/threads"; import type { Speaker } from "@/dto/speakers"; import type { Company } from "@/dto/companies"; @@ -446,10 +447,16 @@ const editText = ref(""); const updatePostMutation = useUpdatePostMutation(); const deleteThreadMutation = useDeleteThreadMutation(); -updatePostMutation.entityType.value = props.entityType; -updatePostMutation.entityId.value = props.entity.id; -deleteThreadMutation.entityType.value = props.entityType; -deleteThreadMutation.entityId.value = props.entity.id; +watch( + () => [props.entityType, props.entity.id] as const, + ([type, id]) => { + updatePostMutation.entityType.value = type; + updatePostMutation.entityId.value = id; + deleteThreadMutation.entityType.value = type; + deleteThreadMutation.entityId.value = id; + }, + { immediate: true }, +); const scrollToBottom = () => { nextTick(() => { @@ -595,11 +602,18 @@ const saveEdit = async () => { const text = editText.value.trim(); if (!id || !text) return; + updatePostMutation.entityType.value = props.entityType; + updatePostMutation.entityId.value = props.entity.id; updatePostMutation.postId.value = id; updatePostMutation.text.value = text; try { - await updatePostMutation.mutateAsync(); + await updatePostMutation.mutateAsync({ + entityType: props.entityType, + entityId: props.entity.id, + postId: id, + text, + }); cancelEdit(); scrollToBottom(); } catch (e) { @@ -614,10 +628,16 @@ const requestDelete = async (thread: ThreadWithEntry) => { ); if (!ok) return; + deleteThreadMutation.entityType.value = props.entityType; + deleteThreadMutation.entityId.value = props.entity.id; deleteThreadMutation.threadId.value = thread.id; try { - await deleteThreadMutation.mutateAsync(); + await deleteThreadMutation.mutateAsync({ + entityType: props.entityType, + entityId: props.entity.id, + threadId: thread.id, + }); } catch (e) { console.error("Delete failed:", e); } @@ -659,15 +679,31 @@ const sendMessage = async () => { if (!newMessage.value.trim() || !props.postThreadMutation) return; try { - // Set the thread data for the mutation - // eslint-disable-next-line vue/no-mutating-props - props.postThreadMutation.threadData.value = { + const threadData: CreateThread = { text: newMessage.value, kind: messageKind.value, channel: messageChannel.value, }; - await props.postThreadMutation.mutateAsync(); + if (props.entityType === "company") { + await ( + props.postThreadMutation as ReturnType< + typeof usePostCompanyThreadMutation + > + ).mutateAsync({ + companyId: props.entity.id, + threadData, + }); + } else { + await ( + props.postThreadMutation as ReturnType< + typeof usePostSpeakerThreadMutation + > + ).mutateAsync({ + speakerId: props.entity.id, + threadData, + }); + } newMessage.value = ""; selectedTemplate.value = undefined; diff --git a/frontend/src/components/ParticipationStatusBadge.vue b/frontend/src/components/ParticipationStatusBadge.vue index 516fc300..0bdff730 100644 --- a/frontend/src/components/ParticipationStatusBadge.vue +++ b/frontend/src/components/ParticipationStatusBadge.vue @@ -86,10 +86,16 @@ const selectStatus = async (status: ParticipationStatus) => { if (props.entityType === "company") { companyStatusMutation.companyId.value = props.entityId; - await companyStatusMutation.mutateAsync(status); + await companyStatusMutation.mutateAsync({ + companyId: props.entityId, + status, + }); } else { speakerStatusMutation.speakerId.value = props.entityId; - await speakerStatusMutation.mutateAsync(status); + await speakerStatusMutation.mutateAsync({ + speakerId: props.entityId, + status, + }); } emit("update:status", status); diff --git a/frontend/src/components/ParticipationsCard.vue b/frontend/src/components/ParticipationsCard.vue index e9fefb20..222abd38 100644 --- a/frontend/src/components/ParticipationsCard.vue +++ b/frontend/src/components/ParticipationsCard.vue @@ -154,7 +154,7 @@ import { } from "@/dto"; import { useQuery } from "@pinia/colada"; -import { computed } from "vue"; +import { computed, watch } from "vue"; import Image from "./Image.vue"; import EmptyStateCard from "./ui/EmptyStateCard.vue"; @@ -183,6 +183,15 @@ const createCompanyParticipationMutation = const createSpeakerParticipationMutation = useCreateSpeakerParticipationMutation(); +watch( + () => props.entityId, + (id) => { + createCompanyParticipationMutation.companyId.value = id; + createSpeakerParticipationMutation.speakerId.value = id; + }, + { immediate: true }, +); + const isCreatingParticipation = computed( () => createCompanyParticipationMutation.isLoading.value || @@ -261,14 +270,20 @@ const createParticipation = async () => { try { if (props.entityType === "company") { - createCompanyParticipationMutation.companyId.value = props.entityId; - createCompanyParticipationMutation.data.value = { + const data = { partner: false, }; - await createCompanyParticipationMutation.mutate(); + createCompanyParticipationMutation.companyId.value = props.entityId; + createCompanyParticipationMutation.data.value = data; + await createCompanyParticipationMutation.mutateAsync({ + companyId: props.entityId, + data, + }); } else if (props.entityType === "speaker") { createSpeakerParticipationMutation.speakerId.value = props.entityId; - await createSpeakerParticipationMutation.mutate(); + await createSpeakerParticipationMutation.mutateAsync({ + speakerId: props.entityId, + }); } } catch (error) { console.error("Failed to create participation:", error); diff --git a/frontend/src/components/cards/CompanyWorkflowCard.vue b/frontend/src/components/cards/CompanyWorkflowCard.vue index 199f4cf9..e238f355 100644 --- a/frontend/src/components/cards/CompanyWorkflowCard.vue +++ b/frontend/src/components/cards/CompanyWorkflowCard.vue @@ -92,7 +92,10 @@ const updateCompanyStatus = async ( companyParticipationStepMutation.step.value = step; isUpdatingStatus.value = true; try { - await companyParticipationStepMutation.mutateAsync(); + await companyParticipationStepMutation.mutateAsync({ + companyId: company.id, + step, + }); } finally { isUpdatingStatus.value = false; } diff --git a/frontend/src/components/cards/SpeakerWorkflowCard.vue b/frontend/src/components/cards/SpeakerWorkflowCard.vue index 9fc4c499..3a0e4e4b 100644 --- a/frontend/src/components/cards/SpeakerWorkflowCard.vue +++ b/frontend/src/components/cards/SpeakerWorkflowCard.vue @@ -33,7 +33,10 @@ const updateSpeakerStatus = async ( speakerParticipationStepMutation.step.value = step; isUpdatingStatus.value = true; try { - await speakerParticipationStepMutation.mutateAsync(); + await speakerParticipationStepMutation.mutateAsync({ + speakerId: speaker.id, + step, + }); } finally { isUpdatingStatus.value = false; } diff --git a/frontend/src/components/companies/CompanyCommunications.vue b/frontend/src/components/companies/CompanyCommunications.vue index 6cfad9bb..617aabfa 100644 --- a/frontend/src/components/companies/CompanyCommunications.vue +++ b/frontend/src/components/companies/CompanyCommunications.vue @@ -18,7 +18,7 @@ import { useEventStore } from "@/stores/event"; import { usePostCompanyThreadMutation } from "@/mutations/companies"; import Communications from "../Communications.vue"; import { companyTemplates, createEmailVariable } from "@/lib/templates"; -import { computed } from "vue"; +import { computed, watch } from "vue"; const props = defineProps<{ company: CompanyWithParticipation; @@ -28,7 +28,13 @@ const eventStore = useEventStore(); // Setup mutation for posting threads const postThreadMutation = usePostCompanyThreadMutation(); -postThreadMutation.companyId.value = props.company.id; +watch( + () => props.company.id, + (id) => { + postThreadMutation.companyId.value = id; + }, + { immediate: true }, +); const templates = computed(() => companyTemplates.map((it) => ({ diff --git a/frontend/src/components/companies/EditableCompanyParticipation.vue b/frontend/src/components/companies/EditableCompanyParticipation.vue index ab9a0f7f..372f531f 100644 --- a/frontend/src/components/companies/EditableCompanyParticipation.vue +++ b/frontend/src/components/companies/EditableCompanyParticipation.vue @@ -268,7 +268,15 @@ const selectedPackageId = ref( const packageName = ref(null); const isPackageUpdating = ref(false); const packageMutation = useCompanyParticipationPackageMutation(); -packageMutation.companyId.value = props.companyId; + +watch( + () => props.companyId, + (newId) => { + packageMutation.companyId.value = newId; + updateMutation.companyId.value = newId; + }, + { immediate: true }, +); const { toast } = useToast(); @@ -356,8 +364,12 @@ const onPackageChange = async () => { : ""; try { isPackageUpdating.value = true; + packageMutation.companyId.value = props.companyId; packageMutation.packageId.value = selectedPackageId.value; - await packageMutation.mutate(); + await packageMutation.mutateAsync({ + companyId: props.companyId, + packageId: selectedPackageId.value, + }); try { await pkgQuery.refetch(); packageName.value = packageData.value?.name || null; @@ -406,7 +418,10 @@ const saveChanges = async () => { updateMutation.companyId.value = props.companyId; updateMutation.data.value = dataToSend; - updateMutation.mutate(); + await updateMutation.mutateAsync({ + companyId: props.companyId, + data: dataToSend, + }); isEditing.value = false; } catch (error) { diff --git a/frontend/src/components/speakers/EditableSpeakerParticipation.vue b/frontend/src/components/speakers/EditableSpeakerParticipation.vue index ce59c05e..50be4305 100644 --- a/frontend/src/components/speakers/EditableSpeakerParticipation.vue +++ b/frontend/src/components/speakers/EditableSpeakerParticipation.vue @@ -154,7 +154,7 @@