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

Dyn-7190: videos from backend #25

Merged
merged 3 commits into from
Jul 3, 2024
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dynamods/dynamo-home",
"version": "1.0.15",
"version": "1.0.16",
"description": "Dynamo Home",
"author": "Autodesk Inc.",
"main": "index.js",
Expand Down
21 changes: 18 additions & 3 deletions src/components/Learning/PageLearning.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ import { GuideGridItem } from "./GuideGridItem.jsx";
import { FormattedMessage } from 'react-intl';

export function LearningPage(){
// Set a placeholder for the guides which will be used differently during dev and prod
// Set a placeholder for the guides, and videos which will be used differently during dev and prod
let initialGuides = [];
let initialVideos = [];

// If we are under development, we will load the graphs from the local asset folder
if (process.env.NODE_ENV === 'development') {
initialGuides = require('../../assets/learning.js').guides;
initialVideos = require('../../assets/learning.js').videos;
}

const [guides, setGuides] = useState(initialGuides);
const [videos, setVideos] = useState(initialVideos);

// A method exposed to the backend used to set the interactive guides data coming from Dynamo
const receiveInteractiveGuidesDataFromDotNet = (jsonData) => {
Expand All @@ -24,21 +27,33 @@ export function LearningPage(){
const data = jsonData;
setGuides(data);
} catch (error) {
console.error('Error processing data:', error);
console.error('Error processing guides data:', error);
}
};

// A method exposed to the backend used to set the training video data coming from Dynamo
const receiveTrainingVideoDataFromDotNet = (jsonData) => {
try {
// jsonData is already an object, so no need to parse it
const data = jsonData;
setVideos(data);
} catch (error) {
console.error('Error processing videos data:', error);
}
};

useEffect(() => {
// If we are under production, we will override the graphs with the actual data sent from Dynamo
if (process.env.NODE_ENV !== 'development') {
window.receiveInteractiveGuidesDataFromDotNet = receiveInteractiveGuidesDataFromDotNet;
window.receiveTrainingVideoDataFromDotNet = receiveTrainingVideoDataFromDotNet;
}


// Cleanup function (optional)
return () => {
if (process.env.NODE_ENV !== 'development') {
delete window.receiveInteractiveGuidesDataFromDotNet;
delete window.receiveTrainingVideoDataFromDotNet;
}
};
}, []);
Expand Down
Loading