Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed May 10, 2021
1 parent dd9a8c5 commit deb4fbc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
25 changes: 24 additions & 1 deletion src/components/manage/Blocks/SiteTableau/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,33 @@ import getSchema from './schema';
import View from './View';

const Edit = (props) => {
const { provider_data = null } = props;
const { provider_data = null, data = {} } = props;
const provider_keys = Object.keys(provider_data || {});
const [schema, setSchema] = React.useState(getSchema(config, provider_keys));

/**
Provider name: Site flags
Provider path: /data-connectors/site-flags
SELECT *
FROM (
SELECT *, CONVERT(varchar(4), euregReportingYear) AS siteReportingYear
FROM [IED].[latest].[Browse5_Header] as B5H
LEFT JOIN [IED].[latest].[site_flags] as SF
ON B5H.[siteInspireId] = SF.[Site Inspire ID]
) as B5H
*/

React.useEffect(() => {
if (!data.provider_url) {
props.onChangeBlock(props.block, {
...props.data,
provider_url:
config.blocks.blocksConfig.site_tableau_block.defaultProviderUrl,
});
}
/* eslint-disable-next-line */
}, []);

React.useEffect(() => {
setSchema(getSchema(config, provider_keys));
/* eslint-disable-next-line */
Expand Down
6 changes: 5 additions & 1 deletion src/components/manage/Blocks/SiteTableau/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ const View = (props) => {
(breakpoint) => breakpoint.device === device,
)[0]?.url;
const url = breakpointUrl || data.url;
const disabled = disabledKey ? !provider_data?.[disabledKey]?.[0] : false;
const disabled = disabledKey
? !provider_data?.[disabledKey]?.[
provider_data?.siteReportingYear?.indexOf(query.siteReportingYear)
]
: false;

React.useEffect(() => {
setMounted(true);
Expand Down
1 change: 1 addition & 0 deletions src/components/manage/Blocks/SiteTableau/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default (config) => {
tablet: [981, 768],
mobile: [767, 0],
},
defaultProviderUrl: '/data-connectors/site-flags',
};
return config;
};

0 comments on commit deb4fbc

Please sign in to comment.