Skip to content
Open
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
39,411 changes: 39,411 additions & 0 deletions arturito/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion arturito/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"start": "craco start",
"start": "craco --openssl-legacy-provider start",
"build": "craco build",
"test": "craco test",
"prettier": "prettier --write .",
Expand Down
1 change: 1 addition & 0 deletions arturito/prueba/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hola mundo cruel
1 change: 1 addition & 0 deletions arturito/pruebaJbrother/moyo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Desde la rama jbrother
2 changes: 1 addition & 1 deletion arturito/src/components/HomeSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Button = ({ text, href }: { text: string; href: string }) => (
const HomeSection = () => (
<div className="p-3 space-y-3">
<p className="text-lg">¡Elegí una sección!</p>
<Button text="Documentación" href="https://www.swapi.it/documentation" />
<Button text="Documentación" href="https://swapi.dev/documentation" />
</div>
);

Expand Down
4 changes: 2 additions & 2 deletions arturito/src/components/PlanetsSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ const Planets = () => {
if (!data) {
return <div className="px-2">Loading...</div>;
}

return (
<div>
<Table columns={columns} data={data.results.slice(0, 3)} /* :D */ />
<Table columns={columns} data={data.results} /* :D */ />
</div>
);
};
Expand Down
53 changes: 53 additions & 0 deletions arturito/src/components/StarshipsSection/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import useSWR from 'swr';

import { swGet } from '../../utils/fetcher';
import Table from '../Table';

const columns = [
{
title: 'Name',
dataIndex: 'name',
key: 'name',
},
{
title: 'Model',
dataIndex: 'model',
key: 'model',
},
{
title: 'Manufacturer',
dataIndex: 'manufacturer',
key: 'manufacturer',
},
{
title: 'Passengers',
dataIndex: 'passengers',
key: 'passengers',
render: (passengers: string) =>
parseInt(passengers)
? parseInt(passengers).toLocaleString('es-AR')
: passengers,
},
{
title: 'Films',
dataIndex: 'films',
key: 'films',
render: (films: string[]) => films.length,
},
];


const Starships = (props) => {
const { data, error } = useSWR('/starships', swGet);
if (error) {
return <div className="px-2">Oh oh!</div>;
}
if (!data) {
return <div className="px-2">Loading...</div>;
}
return (
<Table columns={columns} data={data.results} /* :D */ />
)
}

export default Starships;
15 changes: 2 additions & 13 deletions arturito/src/containers/Main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { paths } from '../paths';
import SectionSelector from '../../components/SectionSelector';
import Home from '../../components/HomeSection';
import Planets from '../../components/PlanetsSection';
import Starships from '../../components/StarshipsSection';

const MainContainer = () => {
const location = useLocation();
Expand All @@ -29,19 +30,7 @@ const MainContainer = () => {
</Route>

<Route path={paths.starships.href}>
<div className="p-3">
<p className="font-bold text-xl"># TODO</p>
<p>
Agregar tabla con las starships sacadas de la API. Mostrar para
cada starship: name, model, manufacturer, passengers, cantidad de
films. Codear en un componente aparte tal como {'<Planets>'}.
</p>
<p>
<a href="https://swapi.it/documentation#starships">
https://swapi.it/documentation#starships
</a>
</p>
</div>
<Starships />
</Route>

<Route path={paths.people.href}>
Expand Down
2 changes: 1 addition & 1 deletion arturito/src/utils/fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';

// Possible alternative: 'https://swapi.dev/api'
const baseURL = 'https://www.swapi.it/api';
const baseURL = 'https://swapi.dev/api';

export const swGet = (url: string) =>
axios.get(url, { baseURL }).then((res) => res.data);
Loading