-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TP-1200: experimental extension (#205)
* feat(extension): experimental extension * chore(css): some tweaks --------- Co-authored-by: Nick Hellemans <[email protected]>
- Loading branch information
Showing
11 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ yarn-error.log* | |
.pnpm-debug.log* | ||
|
||
# local env files | ||
.env | ||
.env*.local | ||
|
||
# vercel | ||
|
27 changes: 27 additions & 0 deletions
27
src/components/Extension/ExperimentalExtension/ExperimentalExtension.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
14 changes: 14 additions & 0 deletions
14
...ts/Extension/ExperimentalExtension/actions/RequestVideoVisit/RequestVideoVisit.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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%; | ||
} */ | ||
} |
38 changes: 38 additions & 0 deletions
38
...omponents/Extension/ExperimentalExtension/actions/RequestVideoVisit/RequestVideoVisit.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
28 changes: 28 additions & 0 deletions
28
.../Extension/ExperimentalExtension/actions/RequestVideoVisit/hooks/useRequestVideoVisit.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/components/Extension/ExperimentalExtension/actions/RequestVideoVisit/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { RequestVideoVisit } from './RequestVideoVisit' |
1 change: 1 addition & 0 deletions
1
src/components/Extension/ExperimentalExtension/actions/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { RequestVideoVisit } from './RequestVideoVisit' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { ExperimentalExtension } from './ExperimentalExtension' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters