Skip to content

Commit

Permalink
More work in progress on new points.
Browse files Browse the repository at this point in the history
  • Loading branch information
greinard committed Sep 8, 2023
1 parent df4d2a8 commit b90da82
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/components/container/NewPoints/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from './NewPoints';
export { default, NewPointsProps, NewPointsEntry } from './NewPoints';
2 changes: 1 addition & 1 deletion src/components/container/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ export { default as ProviderSearch } from "./ProviderSearch"
export { default as RelativeActivityToday } from "./RelativeActivityToday"
export { default as RestingHeartRateCalendar } from "./RestingHeartRateCalendar"
export { default as SurveyTaskList } from "./SurveyTaskList"
export { default as NewPoints } from "./NewPoints"
export { default as NewPoints, NewPointsProps, NewPointsEntry } from "./NewPoints"
2 changes: 1 addition & 1 deletion src/components/view/NewPointsView/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from './NewPointsView';
export { default, NewPointsViewProps } from './NewPointsView';
3 changes: 2 additions & 1 deletion src/components/view/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export { default as GarminView } from "./GarminView"
export { default as HomeView } from "./HomeView"
export { default as HealthAndWellnessView } from "./HealthAndWellnessView"
export { default as NotificationsView } from "./NotificationsView"
export { default as SurveyTasksView } from "./SurveyTasksView"
export { default as SurveyTasksView } from "./SurveyTasksView"
export { default as NewPointsView, NewPointsViewProps } from "./NewPointsView"
18 changes: 14 additions & 4 deletions src/helpers/new-points.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { NewPointsProps } from "../components/container/NewPoints/NewPoints";
import { NewPointsProps } from "../components";
import MyDataHelps from "@careevolution/mydatahelps-js";

export function showNewPoints(props: NewPointsProps, url?: string): void {
type ColorScheme = 'auto' | 'light' | 'dark';

export function showNewPoints(props: NewPointsProps, colorScheme?: ColorScheme, primaryColor?: string, url?: string): void {
let newPointsUrl = url || 'https://viewlibrary.careevolutionapps.dev/newpoints';
let newPointsQueryString = new URLSearchParams({data: window.btoa(JSON.stringify(props))}).toString();
MyDataHelps.openApplication(newPointsUrl + '?' + newPointsQueryString, {modal: true});
let newPointsViewParameters: { data: string, colorScheme?: ColorScheme, primaryColor?: string } = {
data: window.btoa(JSON.stringify(props))
};
if (colorScheme) {
newPointsViewParameters.colorScheme = colorScheme;
}
if (primaryColor) {
newPointsViewParameters.primaryColor = primaryColor;
}
MyDataHelps.openApplication(newPointsUrl + '?' + new URLSearchParams(newPointsViewParameters).toString(), {modal: true});
}

export function decodeNewPointsProps(encodedProps: string): NewPointsProps {
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export * from './hooks';
export * from './helpers/query-daily-data';
export * from './helpers/language';
export { default as getDayKey } from './helpers/get-day-key';
export * from './helpers/get-interval-start';
export * from './helpers/get-interval-start';
export * from './helpers/new-points';

0 comments on commit b90da82

Please sign in to comment.