Skip to content

Commit

Permalink
also use this on the landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
leafty committed Mar 21, 2024
1 parent 11a3306 commit 7f92bb1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,7 @@ function AskForComputeResources() {

const url = new URL(`mailto:${email.to}`);
if (email.subject) {
url.searchParams.set(
"subject",
"Request to access more compute resources in RenkuLab"
);
url.searchParams.set("subject", email.subject);
}
if (email.body) {
const name = (user?.data as { name: string })?.name || "<signature>";
Expand Down
57 changes: 44 additions & 13 deletions client/src/landing/GetSarted/GetStarted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
*/
import { skipToken } from "@reduxjs/toolkit/query";
import cx from "classnames";
import { useContext } from "react";

import { ExternalDocsLink, ExternalLink } from "../../components/ExternalLinks";
import { CommandCopy } from "../../components/commandCopy/CommandCopy";
import EntityCardSkeleton from "../../components/list/EntityCardSkeleton";
import ListCard from "../../components/list/ListCard";
import { useProjectMetadataQuery } from "../../features/project/projectKg.api";
import { Docs, RenkuContactEmail } from "../../utils/constants/Docs";
import AppContext from "../../utils/context/appContext";
import { DEFAULT_APP_PARAMS } from "../../utils/context/appParams.constants";
import { mapMetadataKgResultToEntity } from "../../utils/helpers/KgSearchFunctions";
import { AnonymousHomeConfig } from "../anonymousHome.types";

Expand All @@ -34,7 +37,6 @@ interface GetStartedProps extends AnonymousHomeConfig {
}
export default function GetStarted(props: GetStartedProps) {
const projectPath = props.homeCustomized.projectPath;
const contactEmail = RenkuContactEmail;
const { sectionRef } = props;
const projectMetadataQuery = useProjectMetadataQuery(
projectPath ? { projectPath } : skipToken
Expand Down Expand Up @@ -91,18 +93,7 @@ export default function GetStarted(props: GetStartedProps) {
resources for researchers and instructors. Contact us to learn
more.
</p>
<ExternalLink
className={cx(
styles.btnContactUs,
"align-self-start",
"align-self-lg-center"
)}
color="outline-rk-green"
role="button"
id="Contact Us"
url={`mailto:${contactEmail}`}
title="Contact us"
/>
<ContactUsLink />
</div>
<div>
<p>
Expand Down Expand Up @@ -140,3 +131,43 @@ export default function GetStarted(props: GetStartedProps) {
</div>
);
}

function ContactUsLink() {
const { params } = useContext(AppContext);
const SESSION_CLASS_EMAIL_US =
params?.SESSION_CLASS_EMAIL_US ??
DEFAULT_APP_PARAMS["SESSION_CLASS_EMAIL_US"];

const emailTo = SESSION_CLASS_EMAIL_US.enabled
? SESSION_CLASS_EMAIL_US.email.to
: RenkuContactEmail;
const url = new URL(`mailto:${emailTo}`);

if (SESSION_CLASS_EMAIL_US.enabled && SESSION_CLASS_EMAIL_US.email.subject) {
url.searchParams.set("subject", SESSION_CLASS_EMAIL_US.email.subject);
}
if (SESSION_CLASS_EMAIL_US.enabled && SESSION_CLASS_EMAIL_US.email.body) {
const renderedBody = SESSION_CLASS_EMAIL_US.email.body.replace(
/[{][{]full_name[}][}]/g,
"<signature>"
);
url.searchParams.set("body", renderedBody);
}
const urlStr = url.toString().replace(/[+]/g, "%20");

return (
<ExternalLink
className={cx(
styles.btnContactUs,
"align-self-start",
"align-self-lg-center"
)}
color="outline-rk-green"
role="button"
id="Contact Us"
url={urlStr}
>
Contact Us
</ExternalLink>
);
}

0 comments on commit 7f92bb1

Please sign in to comment.