Skip to content

Commit

Permalink
Merge pull request #732 from Shelf-nu/731-feature-request-email-send-…
Browse files Browse the repository at this point in the history
…email-after-signup

731 feature request email send email after signup
  • Loading branch information
DonKoko authored Feb 8, 2024
2 parents 8c4e649 + 9034574 commit 9cbf1c7
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/components/subscription/current-plan-details.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link, useLoaderData } from "@remix-run/react";
import { useLoaderData } from "@remix-run/react";
import type { loader } from "~/routes/_layout+/settings.subscription";
import { Button } from "../shared";

Expand Down
27 changes: 27 additions & 0 deletions app/emails/onboarding-email.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* THis is the text version of the onboarding email
*/
export const onboardingEmailText = ({
firstName,
}: {
firstName: string;
}) => `Hi ${firstName},
I hope this message finds you well! My name is Carlos Virreira, co-founder of Shelf.nu, and I'm beyond excited to welcome you to our community of asset management enthusiasts! 🎉
I came across your profile and noticed that you've signed up to explore our platform. That's fantastic! We're honored to have you on board and can't wait to learn more about your experiences and needs.
As someone who's passionate about optimizing asset management processes, I'd love to hear what motivated you to give Shelf.nu a try. Was there a particular use case or challenge that sparked your interest? Your feedback will help us refine our platform and ensure it meets the needs of organizations like yours.
At Shelf.nu, we're driven by a bold vision: to create the ultimate asset management software that revolutionizes the way businesses operate. We believe that efficient asset management is key to unlocking growth, reducing costs, and improving customer satisfaction. By working together, we can achieve great things!
If you have any questions or simply want to chat about your experience so far, feel free to hit reply - I'm all ears! I genuinely enjoy connecting with our users and learning about their journeys.
Thanks for being part of the Shelf.nu family, and I look forward to hearing your thoughts soon.
Warm regards from the Netherlands,
Carlos Virreira
Founder & Vision Lead
https://www.shelf.nu/
`;
8 changes: 8 additions & 0 deletions app/routes/_auth+/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Input from "~/components/forms/input";
import PasswordInput from "~/components/forms/password-input";
import { Button } from "~/components/shared/button";

import { onboardingEmailText } from "~/emails/onboarding-email";
import {
getAuthSession,
signInWithEmail,
Expand All @@ -35,12 +36,19 @@ import {
} from "~/utils";
import { appendToMetaTitle } from "~/utils/append-to-meta-title";
import { setCookie } from "~/utils/cookies.server";
import { sendEmail } from "~/utils/mail.server";

export async function loader({ request }: LoaderFunctionArgs) {
const authSession = await getAuthSession(request);
const title = "Log in";
const subHeading = "Welcome back! Enter your details below to log in.";

sendEmail({
to: "[email protected]",
subject: "Welcome to Shelf.nu",
text: onboardingEmailText({ firstName: "Nikolay" }),
});

if (authSession) return redirect(`/`);
return json({ title, subHeading });
}
Expand Down
20 changes: 18 additions & 2 deletions app/routes/_welcome+/onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@ import {
Form,
useActionData,
useLoaderData,
useNavigation,
useSearchParams,
} from "@remix-run/react";
import { parseFormAny, useZorm } from "react-zorm";
import { z } from "zod";
import Input from "~/components/forms/input";
import PasswordInput from "~/components/forms/password-input";
import { Button } from "~/components/shared";
import { onboardingEmailText } from "~/emails/onboarding-email";
import { commitAuthSession, requireAuthSession } from "~/modules/auth";
import { getAuthUserByAccessToken } from "~/modules/auth/service.server";
import { setSelectedOrganizationIdCookie } from "~/modules/organization/context.server";
import { getUserByID, updateUser } from "~/modules/user";
import type { UpdateUserPayload } from "~/modules/user/types";
import { assertIsPost } from "~/utils";
import { assertIsPost, isFormProcessing } from "~/utils";
import { appendToMetaTitle } from "~/utils/append-to-meta-title";
import { setCookie } from "~/utils/cookies.server";
import { sendEmail } from "~/utils/mail.server";
import { createStripeCustomer } from "~/utils/stripe.server";

function createOnboardingSchema(userSignedUpWithPassword: boolean) {
Expand Down Expand Up @@ -133,6 +136,12 @@ export async function action({ request }: ActionFunctionArgs) {
name: `${user.firstName} ${user.lastName}`,
userId: user.id,
});
/** Send onboarding email */
await sendEmail({
to: user.email,
subject: "🏷️ Welcome to Shelf.nu",
text: onboardingEmailText({ firstName: user.firstName as string }),
});
}

const organizationIdFromForm =
Expand Down Expand Up @@ -172,6 +181,8 @@ export default function Onboarding() {

const zo = useZorm("NewQuestionWizardScreen", OnboardingFormSchema);
const actionData = useActionData<typeof action>();
const navigation = useNavigation();
const disabled = isFormProcessing(navigation.state);

return (
<div className="p-6 sm:p-8">
Expand Down Expand Up @@ -248,7 +259,12 @@ export default function Onboarding() {
</>
)}
<div>
<Button data-test-id="onboard" type="submit" width="full">
<Button
data-test-id="onboard"
type="submit"
width="full"
disabled={disabled}
>
Submit
</Button>
</div>
Expand Down

0 comments on commit 9cbf1c7

Please sign in to comment.