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

AP-79 | Fix storybook #178

Merged
merged 3 commits into from
Jul 19, 2021
Merged
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
18 changes: 14 additions & 4 deletions ui/react-components/stories/AppSpecialityFilter.stories.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import React from "react";
import AppSpecialityFilter from "../components/AppSpecialityFilter/AppSpecialityFilter";

export default { title: "AppointmentListSidePanelTree" };

export default { title: "AppSpecilaityFilter" };
import { withReactIntl } from "./util";
const nodes = [
{
value: "Physiotherapy OPD",
label: "Physiotherapy OPD",
children: [
{ value: "1 session [30 min]", label: "1 session [30 min]" },
{ value: "POP [30 min]", label: "POP [30 min]" },
],
},
];
const InternationalizedAppSpecialityFilter = withReactIntl(AppSpecialityFilter);
export const basic = () => (
<AppSpecialityFilter></AppSpecialityFilter>
<InternationalizedAppSpecialityFilter nodes={nodes} />
);
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from "react";
import Search from "../components/AppointmentListSidePanelSearch/AppointmentListSidePanelSearch";
import { withReactIntl } from "./util";

export default { title: "AppointmentListSidePanelSearch" };

export const basic = () => <Search></Search>;
const InternaltionalizedSearch = withReactIntl(Search);
export const basic = () => <InternaltionalizedSearch />;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from "react";
import React from "react";
import AppointmentListSidePanelWrapper from "../components/AppointmentListSidePanelWrapper/AppointmentListSidePanelWrapper";
import { IntlProvider, injectIntl } from "react-intl";
import { withReactIntl } from "./util";

const serviceList = [
{
Expand Down Expand Up @@ -1132,15 +1132,10 @@ const serviceList = [

export default { title: "AppointmentListSidePanelWrapper" };

const withReactIntl = (AppointmentListSidePanelWrapper) => {
const InternationalizedDropDown = withReactIntl(
AppointmentListSidePanelWrapper
);

return (props) => {
return <IntlProvider locale='en' messages={{ 'DROPDOWN_NO_OPTIONS_MESSAGE': 'no option' }}>
<AppointmentListSidePanelWrapper {...props} serviceData={serviceList} />
</IntlProvider>
}
}

const InternationalizedDropDown = withReactIntl(AppointmentListSidePanelWrapper);

export const SearchTree = () => <InternationalizedDropDown />;
export const SearchTree = () => (
<InternationalizedDropDown serviceData={serviceList} />
);
24 changes: 8 additions & 16 deletions ui/react-components/stories/AppointmentStatus.stories.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import React, {useState} from 'react';
import AppointmentStatus from '../components/AppointmentStatus/AppointmentStatus.jsx';
import {IntlProvider} from "react-intl";
import React from "react";
import AppointmentStatus from "../components/AppointmentStatus/AppointmentStatus.jsx";
import { withReactIntl } from "./util";

export default { title: 'Appointment Status' };
export default { title: "Appointment Status" };

const withReactIntl = (AppointmentStatus) => {
return (props) =>{
return <IntlProvider locale='en' messages={{'Appointment_Status': 'no status selected'}}>
<AppointmentStatus {...props}/>
</IntlProvider>
}
}

const InternationalizedAppointmentStatus=withReactIntl(AppointmentStatus)


export const basic = () => (<InternationalizedAppointmentStatus />);
const InternationalizedAppointmentStatus = withReactIntl(AppointmentStatus, {
Appointment_Status: "no status selected",
});

export const basic = () => <InternationalizedAppointmentStatus />;
47 changes: 24 additions & 23 deletions ui/react-components/stories/Dropdown.stories.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
import React from 'react';
import Dropdown from '../components/Dropdown/Dropdown';
import {IntlProvider} from "react-intl";
import React from "react";
import Dropdown from "../components/Dropdown/Dropdown";
import { withReactIntl } from "./util";

export default { title: 'Dropdown' };
export default { title: "Dropdown" };

const colourOptions = [
{value: 'ocean', label: 'Ocean'},
{value: 'blue', label: 'Blue'},
{value: 'orange', label: 'Orange'},
{value: 'yellow', label: 'Yellow'},
{value: 'green', label: 'Green'},
{value: 'forest', label: 'Forest'},
{value: 'slate', label: 'Slate'},
{value: 'silver', label: 'Silver'}
{ value: "ocean", label: "Ocean" },
{ value: "blue", label: "Blue" },
{ value: "orange", label: "Orange" },
{ value: "yellow", label: "Yellow" },
{ value: "green", label: "Green" },
{ value: "forest", label: "Forest" },
{ value: "slate", label: "Slate" },
{ value: "silver", label: "Silver" },
];

const withReactIntl = (DropDown) => {
return (props) =>{
return <IntlProvider locale='en' messages={{'DROPDOWN_NO_OPTIONS_MESSAGE': 'no option'}}>
<Dropdown {...props}/>
</IntlProvider>
}
}
const InternationalizedDropDown = withReactIntl(Dropdown, {
DROPDOWN_NO_OPTIONS_MESSAGE: "no option",
});

const InternationalizedDropDown = withReactIntl(Dropdown);
export const withPlaceholder = () => (
<InternationalizedDropDown placeholder="Sample placeholder"></InternationalizedDropDown>
);

export const withPlaceholder = () => <InternationalizedDropDown placeholder="Sample placeholder"></InternationalizedDropDown>;

export const withOptions = () => <InternationalizedDropDown placeholder="Select color" options={colourOptions}></InternationalizedDropDown>;
export const withOptions = () => (
<InternationalizedDropDown
placeholder="Select color"
options={colourOptions}
></InternationalizedDropDown>
);
24 changes: 8 additions & 16 deletions ui/react-components/stories/FilterWrapper.stories.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import React from 'react';
import React from "react";
// import LocationSearch from '../components/Location/LocationSearch';
import {IntlProvider} from "react-intl";
import FilterWrapper from '../components/AppointmentFilterWrapper/FilterWrapper';
import FilterWrapper from "../components/AppointmentFilterWrapper/FilterWrapper";
import { withReactIntl } from "./util";


export default { title: 'Filter Search Wrapper' };
export default { title: "Filter Search Wrapper" };
// const locationSearch=<LocationSearch value="Enter Location" />

const withReactIntl = (FilterWrapper) => {
return (props) =>{
return <IntlProvider locale='en' messages={{'Filter': 'Filter Wrapper for Appointments'}}>
<FilterWrapper {...props}/>
</IntlProvider>
}
}

const InternationalizedLocation=withReactIntl(FilterWrapper)

export const basic = () => (<InternationalizedLocation/>);
const InternationalizedLocation = withReactIntl(FilterWrapper, {
Filter: "Filter Wrapper for Appointments",
});

export const basic = () => <InternationalizedLocation />;
26 changes: 12 additions & 14 deletions ui/react-components/stories/GridSummary.stories.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import React from 'react';
import GridSummary from '../components/GridSummary/GridSummary';
import {IntlProvider} from "react-intl";
import dummyData from '../components/GridSummary/AppointSummary.json';
export default { title: 'GridSummary' };
import React from "react";
import GridSummary from "../components/GridSummary/GridSummary";
import dummyData from "../components/GridSummary/AppointSummary.json";
import { withReactIntl } from "./util";


const withReactIntl = (GridSummary) => {
return (props) =>{
return <IntlProvider locale='en' messages={{'DROPDOWN_NO_OPTIONS_MESSAGE': 'no option'}}>
<GridSummary {...props}/>
</IntlProvider>
}
}
export default { title: "GridSummary" };

const InternationalizedGridSummary = withReactIntl(GridSummary);

export const withPlaceholder = () => <InternationalizedGridSummary gridData={dummyData} weekStartDate="2020-04-06" onClick={(date)=>alert(date)}/>
export const withPlaceholder = () => (
<InternationalizedGridSummary
gridData={dummyData}
weekStartDate="2020-04-06"
onClick={(date) => alert(date)}
/>
);
24 changes: 8 additions & 16 deletions ui/react-components/stories/LocationSearch.stories.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import React, {useState} from 'react';
import LocationSearch from '../components/Location/LocationSearch';
import {IntlProvider} from "react-intl";
import React from "react";
import LocationSearch from "../components/Location/LocationSearch";
import { withReactIntl } from "./util";


export default { title: 'Location Search' };
export default { title: "Location Search" };
// const locationSearch=<LocationSearch value="Enter Location" />

const withReactIntl = (LocationSearch) => {
return (props) =>{
return <IntlProvider locale='en' messages={{'Location': 'no Location selected'}}>
<LocationSearch {...props}/>
</IntlProvider>
}
}

const InternationalizedLocation=withReactIntl(LocationSearch)

export const basic = () => (<InternationalizedLocation/>);
const InternationalizedLocation = withReactIntl(LocationSearch, {
Location: "no Location selected",
});

export const basic = () => <InternationalizedLocation />;
24 changes: 8 additions & 16 deletions ui/react-components/stories/ProviderSearch.stories.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import React from 'react'
import {IntlProvider} from "react-intl";
import ProviderSearch from '../components/Provider/ProviderSearch';
import React from "react";
import { withReactIntl } from "./util";
import ProviderSearch from "../components/Provider/ProviderSearch";

export default { title: "Provider Search" };

export default { title: 'Provider Search' };

const withReactIntl = (ProviderSearch) => {
return (props) =>{
return <IntlProvider locale='en' messages={{'Provider': 'no Provider selected'}}>
<ProviderSearch {...props}/>
</IntlProvider>
}
}

const InternationalizedProviderSearch=withReactIntl(ProviderSearch)

export const basic = () => (<InternationalizedProviderSearch/>);
const InternationalizedProviderSearch = withReactIntl(ProviderSearch, {
Provider: "no Provider selected",
});

export const basic = () => <InternationalizedProviderSearch />;
2 changes: 1 addition & 1 deletion ui/react-components/stories/Tags.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const colourOptions = [
{ value: "green", label: "Green" },
{ value: "forest", label: "Forest" },
{ value: "slate", label: "Slate" },
{ value: "silver", label: "Silver" }
{ value: "silver", label: "Silver" },
];

export default { title: "Tag" };
Expand Down
12 changes: 12 additions & 0 deletions ui/react-components/stories/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { IntlProvider } from "react-intl";
import React from "react";

export const withReactIntl = (Component, messages = {}) => {
return (props) => {
return (
<IntlProvider locale="en" messages={messages}>
<Component {...props} />
</IntlProvider>
);
};
};