From ea748be27f8a486f2b25a8350d551c136d0ad90f Mon Sep 17 00:00:00 2001 From: Mathias Vagni Date: Tue, 17 Oct 2023 10:12:14 +0200 Subject: [PATCH] remove old unused code --- src/label.ts | 31 ---------------------------- src/thread.ts | 57 --------------------------------------------------- 2 files changed, 88 deletions(-) delete mode 100644 src/label.ts delete mode 100644 src/thread.ts diff --git a/src/label.ts b/src/label.ts deleted file mode 100644 index b754b12..0000000 --- a/src/label.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { FormType } from './contactForm'; - -export function getLabelId( - formType: FormType, - bugIsBlocking: boolean -): { labelTypeId: string; priority: number | null } { - if (!formType) { - throw new Error('form not set'); - } - const issueTypeIds = { - bug: process.env.NEXT_PUBLIC_PLAIN_LABEL_TYPE_ID_BUG || '', - demo: process.env.NEXT_PUBLIC_PLAIN_LABEL_TYPE_ID_DEMO || '', - feature: process.env.NEXT_PUBLIC_PLAIN_LABEL_TYPE_ID_FEATURE || '', - security: process.env.NEXT_PUBLIC_PLAIN_LABEL_TYPE_ID_SECURITY || '', - question: process.env.NEXT_PUBLIC_PLAIN_LABEL_TYPE_ID_QUESTION || '', - } as const; - - const issueTypeId = issueTypeIds[formType]; - - if (!issueTypeId) { - throw new Error(`No issue type id defined for form "${formType}"`); - } - - return { - labelTypeId: issueTypeId, - // In this example contact form if an issue is blocking the user than we want - // to make sure the created issue is urgent. Otherwise we're ok with the default - // which is set per issue type in the Plain settings. - priority: formType === 'bug' && bugIsBlocking ? 1 : null, - }; -} diff --git a/src/thread.ts b/src/thread.ts deleted file mode 100644 index d74c7e4..0000000 --- a/src/thread.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { CreateThreadInput, uiComponent } from '@team-plain/typescript-sdk'; -import UAParser from 'ua-parser-js'; - -export function componentsForBug(bugDescription: string): CreateThreadInput['components'] { - const parser = new UAParser(window.navigator.userAgent); - const browser = parser.getBrowser(); - - return [ - uiComponent.text({ text: bugDescription }), - uiComponent.spacer({ spacingSize: 'S' }), - uiComponent.text({ - text: `Reported on ${window.location.href} using ${browser.name} (${browser.version})`, - size: 'S', - color: 'MUTED', - }), - ]; -} - -export function componentsForFeatureRequest(featureRequest: string) { - return [uiComponent.text({ text: featureRequest })]; -} - -export function componentsForQuestion(question: string) { - return [uiComponent.text({ text: question })]; -} - -export function componentsForSecurityTreport(securityIssue: string) { - return [uiComponent.text({ text: securityIssue })]; -} - -export function componentsForDemoRequest( - demoMessage: string, - currentProvider: string, - expectedVolume: string -) { - return [ - ...(demoMessage - ? [uiComponent.text({ text: demoMessage }), uiComponent.spacer({ spacingSize: 'S' })] - : []), - uiComponent.row({ - mainContent: [uiComponent.text({ text: 'Current provider', color: 'MUTED' })], - asideContent: [ - uiComponent.text({ - text: currentProvider, - }), - ], - }), - uiComponent.row({ - mainContent: [uiComponent.text({ text: 'Expected volume', color: 'MUTED' })], - asideContent: [ - uiComponent.text({ - text: expectedVolume, - }), - ], - }), - ]; -}