Skip to content

Commit

Permalink
Merge pull request #169 from cabcookie:improve-person-mention
Browse files Browse the repository at this point in the history
Einfaches Kopieren von CRM Projekten
  • Loading branch information
cabcookie authored Aug 7, 2024
2 parents b42a351 + 5250561 commit 20e090c
Show file tree
Hide file tree
Showing 27 changed files with 42 additions and 8 deletions.
38 changes: 36 additions & 2 deletions components/crm/CrmData.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,50 @@
import { ClipboardCopy } from "lucide-react";
import { FC } from "react";
import CrmLink from "./CrmLink";
import { toast } from "../ui/use-toast";
import CrmLink, { makeCrmLink } from "./CrmLink";
import LabelData from "./label-data";

type CrmDataProps = {
crmId?: string;
label?: string;
};

const CrmData: FC<CrmDataProps> = ({ crmId }) =>
const copyNameAndLink = (id: string, label: string) => async () => {
try {
const url = makeCrmLink("Opportunity", id);
const htmlContent = `<a href="${url}">${label}</a>`;
const slackFormattedLink = `<${url}|${label}>`;
const blobHTML = new Blob([htmlContent], { type: "text/html" });
const blobPlainText = new Blob([slackFormattedLink], {
type: "text/plain",
});
const clipboardItem = new ClipboardItem({
"text/html": blobHTML,
"text/plain": blobPlainText,
});
await navigator.clipboard.write([clipboardItem]);
toast({ title: "CRM link copied to clipboard" });
} catch (error) {
toast({
title: "Copying CRM link to clipboard failed",
variant: "destructive",
description: JSON.stringify(error),
});
console.error("Copying CRM link to clipboard failed", error);
}
};

const CrmData: FC<CrmDataProps> = ({ crmId, label }) =>
crmId && (
<div className="flex flex-row gap-2 items-center">
<LabelData label="SFDC ID" data={crmId} />
<CrmLink id={crmId} category="Opportunity" />
{label && (
<ClipboardCopy
className="w-4 h-4 text-muted-foreground hover:text-primary"
onClick={copyNameAndLink(crmId, label)}
/>
)}
</div>
);

Expand Down
2 changes: 1 addition & 1 deletion components/crm/changed-project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const ChangedCrmProject: FC<ChangedCrmProjectProps> = ({
importedValue={imported.createdDate}
originalValue={crmProject.createdDate}
/>
<CrmData crmId={imported.crmId} />
<CrmData crmId={imported.crmId} label={imported.name} />
</div>
<Button disabled={!crmProject} onClick={handleUpdateLocalData}>
{!crmProject && <Loader2 className="w-4 h-4 animate-spin" />}
Expand Down
2 changes: 1 addition & 1 deletion components/crm/missing-projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const MissingCrmProjects: FC<MissingCrmProjectsProps> = ({ crmProjects }) => {
<LabelData label="Next step" data={crm.nextStep} />
<LabelData label="Partner" data={crm.partnerName} />
<LabelData label="Owner" data={crm.opportunityOwner} />
<CrmData crmId={crm.crmId} />
<CrmData crmId={crm.crmId} label={crm.name} />
<div className="flex flex-row gap-2">
<Button onClick={handleClosing(crm.id, "Closed Lost")}>
Set “Closed Lost”
Expand Down
2 changes: 1 addition & 1 deletion components/crm/new-projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const NewCrmProjects: FC<NewCrmProjectsProps> = ({ crmProjects }) => {
<LabelData label="Next step" data={crm.nextStep} />
<LabelData label="Partner" data={crm.partnerName} />
<LabelData label="Owner" data={crm.opportunityOwner} />
<CrmData crmId={crm.crmId} />
<CrmData crmId={crm.crmId} label={crm.name} />
<LabelData
label="Created Date"
data={format(crm.createdDate, "PP")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const CrmProjectDetails: FC<CrmProjectDetailsProps> = ({
<NextStep crmProject={crmProject} />
<LabelData label="Partner" data={crmProject.partnerName} />
<LabelData label="Owner" data={crmProject.opportunityOwner} />
<CrmData crmId={crmProject.crmId} />
<CrmData crmId={crmProject.crmId} label={crmProject.name} />
<LabelData
label="Created Date"
data={format(crmProject.createdDate, "PP")}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions docs/releases/next.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# CRM Projekte in Wartestellung ausblenden (Version :VERSION)
# Einfaches Kopieren von CRM Projekten (Version :VERSION)

- CRM Projekte die ausschließlich mit Projekten verknüpft sind, die im Moment stummgeschaltet sind (On Hold), werden ausgeblendet. Es sei denn der Filter „Include projects on hold“ ist aktiviert.
- Jedes CRM Projekt hat beim Link zum Projekt (SFDC ID) auch eine Schaltfläche, um den Titel der Opportunity und dessen Salesforce Link in die Zwischenablage zu kopieren.

0 comments on commit 20e090c

Please sign in to comment.