Skip to content

Commit

Permalink
TP-1200: experimental extension (#205)
Browse files Browse the repository at this point in the history
* feat(extension): experimental extension

* chore(css): some tweaks

---------

Co-authored-by: Nick Hellemans <[email protected]>
  • Loading branch information
nckhell and Nick Hellemans authored Mar 8, 2024
1 parent e1fae51 commit 83bc2cf
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ yarn-error.log*
.pnpm-debug.log*

# local env files
.env
.env*.local

# vercel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React, { FC } from 'react'
import { useTranslation } from 'next-i18next'

import { ErrorPage } from '../../ErrorPage'
import { RequestVideoVisit } from './actions'

import { ActionKey } from './types'
import type { ExtensionActivityRecord } from '../types'

interface ExperimentalExtensionProps {
activityDetails: ExtensionActivityRecord
}

export const ExperimentalExtension: FC<ExperimentalExtensionProps> = ({
activityDetails,
}) => {
const { t } = useTranslation()

switch (activityDetails.plugin_action_key) {
case ActionKey.REQUEST_VIDEO_VISIT:
return <RequestVideoVisit activityDetails={activityDetails} />
default:
return <ErrorPage title={t('activities.activity_not_supported')} />
}
}

ExperimentalExtension.displayName = 'ExperimentalExtension'
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.container {
display: flex;
align-items: center;
justify-content: center;
/* height: 100vh; */
width: 70%;
margin: 0 auto;
text-align: center;
gap: 12px;
/* @media (max-width: 768px) {
padding: 0 20px;
width: 100%;
} */
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React, { FC, useCallback } from 'react'
import classes from './RequestVideoVisit.module.css'

import type { ExtensionActivityRecord } from '../../../types'
import { useRequestVideoVisit } from './hooks/useRequestVideoVisit'
import { Button } from '@awell-health/ui-library'

interface RequestVideoVisitProps {
activityDetails: ExtensionActivityRecord
}

export const RequestVideoVisit: FC<RequestVideoVisitProps> = ({
activityDetails,
}) => {
const { activity_id } = activityDetails
const { onSubmit } = useRequestVideoVisit()

const onClick = useCallback(
(requestVideoVisit: boolean) => {
onSubmit({ activityId: activity_id, requestVideoVisit })
},
[activity_id, onSubmit]
)

return (
<div>
<div className={classes.container}>
<p>Whatever content we want here and full control over UI</p>
</div>
<div className={classes.container}>
<Button onClick={() => onClick(false)}>Continue</Button>
<Button onClick={() => onClick(true)}>Request video visit</Button>
</div>
</div>
)
}

RequestVideoVisit.displayName = 'RequestVideoVisit'
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useCallback } from 'react'
import { DataPoints, useCompleteExtensionActivity } from '../../../types'

export const useRequestVideoVisit = () => {
const { isSubmitting, onSubmit: _onSubmit } = useCompleteExtensionActivity()

const onSubmit = useCallback(
async ({
activityId,
requestVideoVisit,
}: {
activityId: string
requestVideoVisit: boolean
}) => {
const dataPoints: DataPoints = [
{ key: 'requestVideoVisit', value: String(requestVideoVisit) },
]

return _onSubmit(activityId, dataPoints)
},
[_onSubmit]
)

return {
isSubmitting,
onSubmit,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { RequestVideoVisit } from './RequestVideoVisit'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { RequestVideoVisit } from './RequestVideoVisit'
1 change: 1 addition & 0 deletions src/components/Extension/ExperimentalExtension/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ExperimentalExtension } from './ExperimentalExtension'
10 changes: 10 additions & 0 deletions src/components/Extension/ExperimentalExtension/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export {
type DataPoints,
useCompleteExtensionActivity,
} from '../../../hooks/useCompleteExtensionActivity'

export enum ActionKey {
REQUEST_VIDEO_VISIT = 'requestVideoVisit',
}

export type RequestVideoVisitActionFields = {}
5 changes: 5 additions & 0 deletions src/components/Extension/Extension.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { DropboxSignExtension } from './DropboxSignExtension'
import { CloudinaryExtension } from './CloudinaryExtension'
import { DocuSignExtension } from './DocuSignExtension'
import { CollectDataExtension } from './CollectDataExtension'
import { ExperimentalExtension } from './ExperimentalExtension'

interface ExtensionProps {
activity: Activity
Expand Down Expand Up @@ -48,6 +49,10 @@ export const Extension: FC<ExtensionProps> = ({ activity }) => {
return <DocuSignExtension activityDetails={extensionActivityDetails} />
case ExtensionKey.COLLECT_DATA:
return <CollectDataExtension activityDetails={extensionActivityDetails} />
case ExtensionKey.EXPERIMENTAL:
return (
<ExperimentalExtension activityDetails={extensionActivityDetails} />
)
default:
return <ErrorPage title={t('activities.activity_not_supported')} />
}
Expand Down
1 change: 1 addition & 0 deletions src/components/Extension/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export enum ExtensionKey {
CLOUDINARY = 'cloudinary',
DOCU_SIGN = 'docuSign',
COLLECT_DATA = 'collectData',
EXPERIMENTAL = 'experimental',
}

0 comments on commit 83bc2cf

Please sign in to comment.