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

Form for creating courses #149

Closed
wants to merge 13 commits into from
Closed

Conversation

JibrilExe
Copy link
Contributor

@JibrilExe JibrilExe commented Mar 28, 2024

Fixes #157

@JibrilExe JibrilExe requested review from Vucis and AronBuzogany March 28, 2024 14:33
frontend/src/components/Courses/CourseForm.tsx Outdated Show resolved Hide resolved
frontend/src/components/Courses/CourseForm.tsx Outdated Show resolved Hide resolved
frontend/src/components/Courses/CourseForm.tsx Outdated Show resolved Hide resolved
frontend/src/components/Courses/CourseForm.tsx Outdated Show resolved Hide resolved
frontend/src/components/Courses/CourseForm.tsx Outdated Show resolved Hide resolved
@JibrilExe JibrilExe requested a review from AronBuzogany March 29, 2024 09:57
Copy link
Contributor

@AronBuzogany AronBuzogany left a comment

Choose a reason for hiding this comment

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

Add a label and use i18n there is also no issue linked to this PR

@JibrilExe JibrilExe requested a review from AronBuzogany March 31, 2024 12:27
Copy link
Contributor

@AronBuzogany AronBuzogany left a comment

Choose a reason for hiding this comment

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

Try to organize the i18n locals files to sort the entries by page for example

@JibrilExe JibrilExe requested a review from AronBuzogany March 31, 2024 14:24
Copy link
Contributor

@AronBuzogany AronBuzogany left a comment

Choose a reason for hiding this comment

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

Do we really need a whole page for this? I feel like this can be a component that can be used in an overview page of teachers. @Vucis what do you think?


const { t } = useTranslation('translation', { keyPrefix: 'courseForm' });

const apiHost = import.meta.env.VITE_API_HOST;
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this outside the function, everytime a state changes this will re-import the env variable. Alternatively you can wrap it in an effect with an empty dependency array

"courseName": "Course Name",
"submit": "Submit",
"emptyCourseName": "Course name should not be empty"
Copy link
Contributor

Choose a reason for hiding this comment

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

Add something like Message to the key, it's not obvious by the key what this stands for

}

const data = { name: courseName };
call_to_api(apiHost + '/courses', JSON.stringify(data), 'POST');
Copy link
Contributor

Choose a reason for hiding this comment

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

Use backtick notation instead of + string

* @param data - data to send
* @param method - POST, PATCH, GET or DELETE
*/
function call_to_api(path: string, data: string, method:string){
Copy link
Contributor

Choose a reason for hiding this comment

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

Javascript/TypeScript uses camelNotation

}

/**
* Helper function to send requests to the a</Button>pi
Copy link
Contributor

Choose a reason for hiding this comment

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

</Button> ?

<Button
type="submit"
style={{
position: 'absolute',
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does the position need to be absolute? This can mess up lots of things when changing screen resolution

})
.then(response => response.json())
.then(data => {
window.location.href = data.url; // navigate to data.url
Copy link
Contributor

Choose a reason for hiding this comment

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

Use appropriate functions for this, e.g. navigate

method: method,
headers: {
'Content-Type': 'application/json',
'Authorization': 'teacher1'
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't hardcode this

@Vucis
Copy link
Contributor

Vucis commented Mar 31, 2024

Yes, it might be better as a popup when a teacher clicks a button in their main course page, considering we only need the name of the course

@AronBuzogany AronBuzogany deleted the frontend/feature/courseform branch April 25, 2024 15:53
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.

form for creating new courses
3 participants