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

fix ToDo sample to allow build on lesson level #1083

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ewitkon
Copy link
Contributor

@ewitkon ewitkon commented Jan 10, 2025

ToDo tutorial on version 2.0 fails to build when you complete only lesson 1 out of the 2-3 lessons. This is due to type mismatch with the mock objects.
When users are using VS code in platform and check in the code the CI will fail as it run npm run build, which is a poor experience.
This PR extract the dependency of most of the code from the Mock objects so you can implement each method at a time and code will still compile. This PR will go together with a forge pr to fix the suggested solutions to the lessons.

@ewitkon ewitkon requested a review from zeyadkhaled January 10, 2025 00:42
zeyadkhaled
zeyadkhaled previously approved these changes Jan 10, 2025
Copy link
Member

@zeyadkhaled zeyadkhaled left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just minor comments, but those apply to all templates

Comment on lines +23 to +34
const { data, isLoading, isValidating, error, mutate } = useSWR<IProject[]>(
"projects",
async () => {
// Try to implement this with the Ontology SDK!
const projectsList: IProject[] = (await Mocks.getProjects()).map((
project,
) => ({
...project,
}));
return projectsList;
},
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like its redundant and could be done like this?

Suggested change
const { data, isLoading, isValidating, error, mutate } = useSWR<IProject[]>(
"projects",
async () => {
// Try to implement this with the Ontology SDK!
const projectsList: IProject[] = (await Mocks.getProjects()).map((
project,
) => ({
...project,
}));
return projectsList;
},
);
const { data, isLoading, isValidating, error, mutate } = useSWR<IProject[]>(
"projects",
async () => {
// Try to implement this with the Ontology SDK!
const projectsList: IProject[] = await Mocks.getProjects();
return projectsList;
},
);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but I thought it would be good to keep the mapping code here as when you implement the lesson you need a similar thing to map from your OSDK object to IProject.

description: string;
}

export interface ITask {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should live in useProjectTasks

@policy-bot policy-bot bot dismissed zeyadkhaled’s stale review January 10, 2025 18:36

Invalidated by push of fd91669

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants