Skip to content

Commit

Permalink
PR-CHANGES 3
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdip-b committed Mar 10, 2024
1 parent 1eb548f commit 4370c10
Show file tree
Hide file tree
Showing 6 changed files with 719 additions and 2,957 deletions.
7 changes: 7 additions & 0 deletions app/modules/invite/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,23 @@ export const assetCustodyAssignedEmailText = ({
assetName,
assignerName,
assetId,
templateUrl,
}: {
assetName: string;
assignerName: string;
assetId: string;
templateUrl?: string;
}) => `Howdy,
${assignerName} has assigned you as custodian for ${assetName}.
Please click the link below to view the asset:
${SERVER_URL}/assets/${assetId}
${
templateUrl &&
`To view the signing template, please click the link: ${templateUrl}`
}
Thanks,
The Shelf Team
`;
Expand Down
76 changes: 51 additions & 25 deletions app/routes/_layout+/assets.$assetId.give-custody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,34 +240,60 @@ export const action = async ({
}

// If the template was specified, and signature was required
if (addTemplateEnabled && templateObj!.signatureRequired) {
/** We create the note */
await createNote({
content: `**${user.firstName?.trim()} ${user.lastName?.trim()}** has given **${custodianName?.trim()}** custody over **${asset.title?.trim()}**. **${custodianName?.trim()}** needs to sign the **${templateObj!.name?.trim()}** template before receiving custody.`,
type: "UPDATE",
userId: userId,
assetId: asset.id,
});
if (addTemplateEnabled && templateObj) {
if (templateObj.signatureRequired) {
await createNote({
content: `**${user.firstName?.trim()} ${user.lastName?.trim()}** has given **${custodianName?.trim()}** custody over **${asset.title?.trim()}**. **${custodianName?.trim()}** needs to sign the **${templateObj!.name?.trim()}** template before receiving custody.`,
type: "UPDATE",
userId: userId,
assetId: asset.id,
});

sendNotification({
title: `‘${asset.title}’ would go in custody of ${custodianName}`,
message:
"This asset will stay available until the custodian signs the PDF template. After that, the asset will be unavailable until custody is manually released.",
icon: { name: "success", variant: "success" },
senderId: userId,
});
sendNotification({
title: `‘${asset.title}’ would go in custody of ${custodianName}`,
message:
"This asset will stay available until the custodian signs the PDF template. After that, the asset will be unavailable until custody is manually released.",
icon: { name: "success", variant: "success" },
senderId: userId,
});

sendEmail({
to: custodianEmail,
subject: `You have been assigned custody over ${asset.title}.`,
text: assetCustodyAssignedWithTemplateEmailText({
assetName: asset.title,
assignerName: user.firstName + " " + user.lastName,
sendEmail({
to: custodianEmail,
subject: `You have been assigned custody over ${asset.title}.`,
text: assetCustodyAssignedWithTemplateEmailText({
assetName: asset.title,
assignerName: user.firstName + " " + user.lastName,
assetId: asset.id,
templateId: templateObj!.id,
assigneeId: custodianUserId,
}),
});
} else {
await createNote({
content: `**${user.firstName} ${user.lastName}** has given **${custodianName}** custody over **${asset.title}**`,
type: "UPDATE",
userId: userId,
assetId: asset.id,
templateId: templateObj!.id,
assigneeId: custodianUserId,
}),
});
});

sendNotification({
title: `‘${asset.title}’ is now in custody of ${custodianName}`,
message:
"Remember, this asset will be unavailable until custody is manually released.",
icon: { name: "success", variant: "success" },
senderId: userId,
});

sendEmail({
to: custodianEmail,
subject: `You have been assigned custody over ${asset.title}`,
text: assetCustodyAssignedEmailText({
assetName: asset.title,
assignerName: user.firstName + " " + user.lastName,
assetId: asset.id,
}),
});
}
} else {
// If the template was not specified
await createNote({
Expand Down
32 changes: 32 additions & 0 deletions app/routes/_sign+/_layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { LinksFunction } from "@remix-run/node";
import { Outlet } from "@remix-run/react";
import { ErrorBoundryComponent } from "~/components/errors";
import { useCrisp } from "~/components/marketing/crisp";
import styles from "~/styles/layout/index.css";

export const links: LinksFunction = () => [{ rel: "stylesheet", href: styles }];

export default function App() {
useCrisp();

return (
<div className="flex h-full min-h-screen flex-col ">
<main className="relative flex h-full w-full">
<div className="flex h-full w-full flex-col items-center justify-center md:p-20">
<div className="h-full w-full rounded-xl bg-white shadow-xl">
<Outlet />
</div>
</div>
<img
src="/images/bg-overlay1.png"
alt="bg-overlay"
className="absolute right-0 top-0 -z-10 h-full w-full object-cover"
/>
</main>
</div>
);
}

export const ErrorBoundary = () => (
<ErrorBoundryComponent title="Sorry, page you are looking for doesn't exist" />
);
3 changes: 2 additions & 1 deletion app/routes/_sign+/sign.$templateId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export const loader = async ({ context, request }: LoaderFunctionArgs) => {
throw new ShelfStackError({
message: "Unauthorized",
status: 401,
title: "Unauthorized",
title:
"You are not authorized to view this page and sign this template. Please make sure you are logged in with the correct account.",
});
}

Expand Down
Loading

0 comments on commit 4370c10

Please sign in to comment.