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

Fabi0o solution #3

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

Fabi0o solution #3

wants to merge 2 commits into from

Conversation

Fabi0o
Copy link

@Fabi0o Fabi0o commented Jan 15, 2023

Solution for the task with backend and frontend

@@ -0,0 +1,26 @@
import { Viking } from "../types/viking";
import styles from "../styles/VikingCard.module.css";
const VikingCard = ({ viking }: { viking: Viking }) => {

Choose a reason for hiding this comment

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

Lack of whitespace in all places. The code is hard to read as there is too few "enters" used. It applies to all your code, not only this file :)

module.exports = nextConfig
};
module.exports = nextConfig;
module.exports = withYAML();

Choose a reason for hiding this comment

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

You replaced our custom next config with that function, so we lost it.

</div>
<div>
Fight with
{viking.canFightWithSword

Choose a reason for hiding this comment

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

Personally, I am not a huge fan of chaining ternary operators that way.

const jsonVikingList: Array<Viking> = vikingsJSON.map((vikingJSON) => {
const fullViking = {
fullName: vikingJSON.fullName,
presenceOfChildren: vikingJSON.hasSon ? true : false,

Choose a reason for hiding this comment

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

You don't have to return true or false from ternary operator, as the condition is already a boolean.

export const handleVikingList = (
vikingsJSON: Array<vikingDataJSON>,
vikingsYaml: Array<vikingDataYaml>
) => {

Choose a reason for hiding this comment

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

You could write return type here (: Viking[]) and then you could remove all those Array from inside the function and it would work. You don't have to use type assertion everywhere for every variable, Typescript is clever enough to infer that :)

</footer>
<div className={styles.head}>
<h1>Hello Ragnar!</h1>
<Link href={"http://localhost:3000/vikings"} className={styles.headLink}>

Choose a reason for hiding this comment

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

You don't have to use host here in the url.

import VikingCard from "../components/VikingCard";
import style from "../styles/Vikings.module.css";
const VikingsList = () => {
const vikingList: Array<Viking> = handleVikingList(vikingsJSON, vikingsYAML);

Choose a reason for hiding this comment

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

Type is not needed, as function return is already typed.

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