Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) O3-4060 : Enable or Disable tutorials for onboarding module #22

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/config-schema.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Type } from '@openmrs/esm-framework';

export const configSchema = {
showTutorial: {
enableTutorials: {
_type: Type.Boolean,
_default: false,
_description: 'Enable or Disable Onboarding Walkthrough',
_description: 'Enable or Disable Onboarding Walkthroughs',
},
tutorialData: {
_type: Type.Array,
Expand Down Expand Up @@ -614,7 +614,7 @@ export const configSchema = {
};

export type Config = {
showTutorial: boolean;
enableTutorials: boolean;
tutorialData: {
title: string;
description: string;
Expand Down
12 changes: 5 additions & 7 deletions src/tutorial/tutorial.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { showModal } from '@openmrs/esm-framework';
import { showModal, useConfig } from '@openmrs/esm-framework';
import { type Config } from '../config-schema';

const Tutorial = () => {
const { t } = useTranslation();

const config = useConfig() as Config;
const showTutorial = config?.enableTutorials;
const handleOpenModal = () => {
const dispose = showModal('tutorial-modal', {
onClose: () => dispose(),
size: 'sm',
});
};

return (
<>
<div onClick={handleOpenModal}>{t('tutorials', 'Tutorials')}</div>
</>
);
return showTutorial ? <div onClick={handleOpenModal}>{t('tutorials', 'Tutorials')}</div> : null;
};

export default Tutorial;
Loading