Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 46 additions & 10 deletions frontend/src/components/Communications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/components/ParticipationStatusBadge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 20 additions & 5 deletions frontend/src/components/ParticipationsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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 ||
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/cards/CompanyWorkflowCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/cards/SpeakerWorkflowCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/components/companies/CompanyCommunications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) => ({
Expand Down
21 changes: 18 additions & 3 deletions frontend/src/components/companies/EditableCompanyParticipation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,15 @@ const selectedPackageId = ref<string>(
const packageName = ref<string | null>(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();

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
16 changes: 13 additions & 3 deletions frontend/src/components/speakers/EditableSpeakerParticipation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
</template>

<script setup lang="ts">
import { computed, ref, reactive } from "vue";
import { computed, ref, reactive, watch } from "vue";
import { useQuery } from "@pinia/colada";
import { getAllEvents } from "@/api/events";
import { getAllMembers } from "@/api/members";
Expand Down Expand Up @@ -218,7 +218,13 @@ const { data: membersData } = useQuery({

const updateMutation = useSpeakerParticipationMutation();

updateMutation.speakerId.value = props.speakerId;
watch(
() => props.speakerId,
(newId) => {
updateMutation.speakerId.value = newId;
},
{ immediate: true },
);

const startEditing = () => {
isEditing.value = true;
Expand All @@ -240,7 +246,11 @@ const saveChanges = async () => {
isSaving.value = true;

try {
updateMutation.mutate(editForm);
updateMutation.speakerId.value = props.speakerId;
await updateMutation.mutateAsync({
speakerId: props.speakerId,
data: editForm,
});
isEditing.value = false;
} catch (error) {
console.error("Failed to update speaker participation:", error);
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/components/speakers/SpeakerCommunications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { useEventStore } from "@/stores/event";
import { usePostSpeakerThreadMutation } from "@/mutations/speakers";
import Communications from "../Communications.vue";
import { speakerTemplates, createEmailVariable } from "@/lib/templates";
import { computed } from "vue";
import { computed, watch } from "vue";
import { useAuthStore } from "@/stores/auth";

const props = defineProps<{
Expand All @@ -30,7 +30,13 @@ const authStore = useAuthStore();

// Setup mutation for posting threads (currently disabled for speakers)
const postThreadMutation = usePostSpeakerThreadMutation();
postThreadMutation.speakerId.value = props.speaker.id;
watch(
() => props.speaker.id,
(id) => {
postThreadMutation.speakerId.value = id;
},
{ immediate: true },
);

const templates = computed(() =>
speakerTemplates.map((it) => ({
Expand Down
26 changes: 21 additions & 5 deletions frontend/src/components/tasks/TaskConfirmation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ const packageOptions = computed(() => {

// Package mutation (companies only)
const packageMutation = useCompanyParticipationPackageMutation();
packageMutation.companyId.value = props.entityId;

const selectedPackageId = ref<string>(
isCompanyParticipation(props.participation) && props.participation?.package
Expand Down Expand Up @@ -278,18 +277,31 @@ const isDateUpdating = ref(false);

// Participation mutation for updating confirmed date (companies only)
const companyParticipationMutation = useCompanyParticipationMutation();
companyParticipationMutation.companyId.value = props.entityId;

watch(
() => props.entityId,
(id) => {
packageMutation.companyId.value = id;
companyParticipationMutation.companyId.value = id;
},
{ immediate: true },
);

const onConfirmedDateChange = async (newValue: Date | null) => {
if (!newValue) return;
try {
isDateUpdating.value = true;
const isoDate = newValue.toISOString();
companyParticipationMutation.data.value = {
const data = {
...props.participation,
confirmed: isoDate,
};
await companyParticipationMutation.mutateAsync();
companyParticipationMutation.companyId.value = props.entityId;
companyParticipationMutation.data.value = data;
await companyParticipationMutation.mutateAsync({
companyId: props.entityId,
data,
});
toast.success({ title: "Confirmation date updated" });
} catch (err) {
console.error("Failed to update confirmation date:", err);
Expand All @@ -304,8 +316,12 @@ const onPackageChange = async (newValue: unknown) => {
if (!v) return;
try {
isPackageUpdating.value = true;
packageMutation.companyId.value = props.entityId;
packageMutation.packageId.value = v;
await packageMutation.mutateAsync();
await packageMutation.mutateAsync({
companyId: props.entityId,
packageId: v,
});
toast.success({ title: "Package updated" });
} catch (err) {
console.error("Failed to update package:", err);
Expand Down
Loading
Loading