Bridge integration
This commit is contained in:
parent
42a5e09c94
commit
162390008b
56 changed files with 776 additions and 591 deletions
113
apps/link/app/_actions/tickets.ts
Normal file
113
apps/link/app/_actions/tickets.ts
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
"use server";
|
||||
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { createTicketMutation } from "app/_graphql/createTicketMutation";
|
||||
import { updateTicketMutation } from "app/_graphql/updateTicketMutation";
|
||||
import { updateTagsMutation } from "app/_graphql/updateTagsMutation";
|
||||
// import { executeMutation } from "app/_lib/graphql";
|
||||
// import { AddAssetMutation } from "../_graphql/AddAssetMutation";
|
||||
|
||||
export const createTicketAction = async (
|
||||
currentState: any,
|
||||
formData: FormData,
|
||||
) => {
|
||||
/*
|
||||
|
||||
const createTicket = async () => {
|
||||
await fetcher({
|
||||
document: createTicketMutation,
|
||||
variables: {
|
||||
input: {
|
||||
ticket,
|
||||
},
|
||||
},
|
||||
});
|
||||
closeDialog();
|
||||
setBody("");
|
||||
};
|
||||
|
||||
*/
|
||||
try {
|
||||
const ticket = {
|
||||
title: formData.get("title"),
|
||||
};
|
||||
|
||||
const result = await executeMutation({
|
||||
project,
|
||||
mutation: AddAssetMutation,
|
||||
variables: {
|
||||
input: asset,
|
||||
},
|
||||
});
|
||||
|
||||
revalidatePath(`/${project}/assets`);
|
||||
|
||||
return {
|
||||
...currentState,
|
||||
values: { ...asset, ...result.addAsset, project },
|
||||
success: true,
|
||||
};
|
||||
} catch (e: any) {
|
||||
return { success: false, message: e?.message ?? "Unknown error" };
|
||||
}
|
||||
};
|
||||
|
||||
export const updateTicketAction = async (
|
||||
currentState: any,
|
||||
formData: FormData,
|
||||
) => {
|
||||
try {
|
||||
const { id, project } = currentState.values;
|
||||
const updatedTicket = {
|
||||
title: formData.get("title"),
|
||||
};
|
||||
await executeMutation({
|
||||
project,
|
||||
mutation: UpdateAssetMutation,
|
||||
variables: {
|
||||
id,
|
||||
input: updatedAsset,
|
||||
},
|
||||
});
|
||||
|
||||
revalidatePath(`/${project}/assets/${id}`);
|
||||
|
||||
return {
|
||||
...currentState,
|
||||
values: { ...currentState.values, ...updatedAsset, id, project },
|
||||
success: true,
|
||||
};
|
||||
} catch (e: any) {
|
||||
return { success: false, message: e?.message ?? "Unknown error" };
|
||||
}
|
||||
};
|
||||
|
||||
export const updateTicketTagsAction = async (
|
||||
currentState: any,
|
||||
formData: FormData,
|
||||
) => {
|
||||
try {
|
||||
const { id, project } = currentState.values;
|
||||
const updatedTicket = {
|
||||
title: formData.get("title"),
|
||||
};
|
||||
await executeMutation({
|
||||
project,
|
||||
mutation: UpdateAssetMutation,
|
||||
variables: {
|
||||
id,
|
||||
input: updatedAsset,
|
||||
},
|
||||
});
|
||||
|
||||
revalidatePath(`/${project}/assets/${id}`);
|
||||
|
||||
return {
|
||||
...currentState,
|
||||
values: { ...currentState.values, ...updatedAsset, id, project },
|
||||
success: true,
|
||||
};
|
||||
} catch (e: any) {
|
||||
return { success: false, message: e?.message ?? "Unknown error" };
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue