Skip to content

Commit 7262c00

Browse files
committed
Fixed drip email creation
1 parent 7c7728b commit 7262c00

4 files changed

Lines changed: 37 additions & 2 deletions

File tree

apps/web/app/(with-contexts)/dashboard/(sidebar)/product/[id]/content/section/[section]/page.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import {
2222
} from "@/components/ui/tooltip";
2323
import { HelpCircle } from "lucide-react";
2424
import Link from "next/link";
25+
import { AlertCircle } from "lucide-react";
26+
import { Alert, AlertDescription } from "@/components/ui/alert";
2527
import {
2628
COURSE_CONTENT_HEADER,
2729
EDIT_SECTION_HEADER,
@@ -60,6 +62,7 @@ export default function SectionPage({
6062
const [date, setDate] = useState<number>();
6163
const [emailContent, setEmailContent] = useState<EmailContent | null>(null);
6264
const [emailSubject, setEmailSubject] = useState("");
65+
const [emailId, setEmailId] = useState("");
6366
const address = useContext(AddressContext);
6467
const { product } = useProduct(productId, address);
6568
const [loading, setLoading] = useState(false);
@@ -102,6 +105,7 @@ export default function SectionPage({
102105
setDate(group.drip?.dateInUTC);
103106
}
104107
setNotifyUsers(!!group.drip?.email);
108+
setEmailId(group.drip?.email?.emailId || "");
105109
setEmailContent(
106110
group.drip?.email?.content ||
107111
({
@@ -217,6 +221,7 @@ export default function SectionPage({
217221
meta
218222
},
219223
subject
224+
emailId
220225
}
221226
}
222227
}
@@ -256,6 +261,11 @@ export default function SectionPage({
256261
// router.replace(
257262
// `/dashboard/product/${productId}/content`,
258263
// );
264+
setEmailId(
265+
response.course.groups.find(
266+
(group) => group.id === sectionId,
267+
)?.drip?.email?.emailId || "",
268+
);
259269
toast({
260270
title: TOAST_TITLE_SUCCESS,
261271
description: TOAST_DESCRIPTION_CHANGES_SAVED,
@@ -518,9 +528,24 @@ export default function SectionPage({
518528
}
519529
/>
520530
</div>
531+
{!emailId && (
532+
<Alert>
533+
<AlertCircle className="h-4 w-4" />
534+
<AlertDescription>
535+
Please save the
536+
changes first to
537+
enable email
538+
editing
539+
</AlertDescription>
540+
</Alert>
541+
)}
521542
<EmailViewer
522543
content={emailContent}
523-
emailEditorLink={`/dashboard/mail/drip/${productId}/${sectionId}?redirectTo=/dashboard/product/${productId}/content/section/${sectionId}`}
544+
emailEditorLink={
545+
emailId
546+
? `/dashboard/mail/drip/${productId}/${sectionId}?redirectTo=/dashboard/product/${productId}/content/section/${sectionId}`
547+
: undefined
548+
}
524549
/>
525550
</div>
526551
)

apps/web/app/(with-contexts)/dashboard/(sidebar)/product/[id]/content/section/new/page.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,16 @@ export default function SectionPage() {
8282
delayInMillis,
8383
dateInUTC,
8484
email {
85-
content,
85+
content {
86+
content {
87+
blockType,
88+
settings
89+
},
90+
style,
91+
meta
92+
},
8693
subject
94+
emailId
8795
}
8896
}
8997
}

apps/web/graphql/courses/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const dripEmail = new GraphQLObjectType({
7777
type: new GraphQLNonNull(sequenceTypes.sequenceEmailContent),
7878
},
7979
subject: { type: new GraphQLNonNull(GraphQLString) },
80+
emailId: { type: new GraphQLNonNull(GraphQLString) },
8081
},
8182
});
8283

apps/web/hooks/use-product.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export default function useProduct(
6363
meta
6464
},
6565
subject
66+
emailId
6667
}
6768
}
6869
},

0 commit comments

Comments
 (0)