Fixes issues with workflows that have more than one action (#6670)
* fix untitled workflow name when no action exists * fix wrong data loaded one first laod when step was added Co-authored-by: CarinaWolli <wollencarina@gmail.com>
This commit is contained in:
1 parent
8640eb9f52
commit
3c761f4451
3 files changed
+10
-8
No files matched your search
@@ -94,12 +94,14 @@ export default function WorkflowListPage({ workflows }: Props) {
|
||||
)}>
|
||||
{workflow.name
|
||||
? workflow.name
|
||||
: "Untitled (" +
|
||||
: workflow.steps[0]
|
||||
? "Untitled (" +
|
||||
`${t(`${workflow.steps[0].action.toLowerCase()}_action`)}`
|
||||
.charAt(0)
|
||||
.toUpperCase() +
|
||||
`${t(`${workflow.steps[0].action.toLowerCase()}_action`)}`.slice(1) +
|
||||
")"}
|
||||
")"
|
||||
: "Untitled"}
|
||||
</div>
|
||||
<ul className="mt-2 flex flex-wrap space-x-1 sm:flex-nowrap ">
|
||||
<li className="mb-1 flex items-center whitespace-nowrap rounded-sm bg-gray-100 px-1 py-px text-xs text-gray-800 dark:bg-gray-900 dark:text-white">
|
||||
|
||||
@@ -100,7 +100,7 @@ function WorkflowPage() {
|
||||
data: workflow,
|
||||
isError,
|
||||
error,
|
||||
isLoading,
|
||||
dataUpdatedAt,
|
||||
} = trpc.viewer.workflows.get.useQuery(
|
||||
{ id: +workflowId },
|
||||
{
|
||||
@@ -111,7 +111,7 @@ function WorkflowPage() {
|
||||
const { data: verifiedNumbers } = trpc.viewer.workflows.getVerifiedNumbers.useQuery();
|
||||
|
||||
useEffect(() => {
|
||||
if (workflow && !isLoading) {
|
||||
if (workflow && (workflow.steps.length === 0 || workflow.steps[0].stepNumber === 1)) {
|
||||
setSelectedEventTypes(
|
||||
workflow.activeOn.map((active) => ({
|
||||
value: String(active.eventType.id),
|
||||
@@ -155,7 +155,7 @@ function WorkflowPage() {
|
||||
form.setValue("activeOn", activeOn || []);
|
||||
setIsAllDataLoaded(true);
|
||||
}
|
||||
}, [isLoading]);
|
||||
}, [dataUpdatedAt]);
|
||||
|
||||
const updateMutation = trpc.viewer.workflows.update.useMutation({
|
||||
onSuccess: async ({ workflow }) => {
|
||||
|
||||
@@ -713,14 +713,14 @@ export const workflowsRouter = router({
|
||||
});
|
||||
addedSteps.forEach(async (step) => {
|
||||
if (step) {
|
||||
const newStep = step;
|
||||
const { senderName, ...newStep } = step;
|
||||
newStep.sender = getSender({
|
||||
action: newStep.action,
|
||||
sender: newStep.sender || null,
|
||||
senderName: newStep.senderName,
|
||||
senderName: senderName,
|
||||
});
|
||||
const createdStep = await ctx.prisma.workflowStep.create({
|
||||
data: { ...step, numberVerificationPending: false },
|
||||
data: { ...newStep, numberVerificationPending: false },
|
||||
});
|
||||
if (
|
||||
(trigger === WorkflowTriggerEvents.BEFORE_EVENT ||
|
||||
|
||||
Reference in new issue
Block a user