forked from b00tc4mp/isdi-parttime-202309
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create simple resource component; create simple resources page with b…
…utton that makes you navigate to new resource form b00tc4mp#482
- Loading branch information
Showing
8 changed files
with
73 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
staff/judy-grayland/project/app/src/logic/retrieveResources.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { errors } from '../../../shared' | ||
import { SystemError } from '../../../shared/errors' | ||
|
||
function retrieveResources() { | ||
const req = { | ||
method: 'GET', | ||
} | ||
|
||
return fetch(`${import.meta.env.VITE_API_URL}/resources`, req) | ||
.catch((error) => { | ||
throw new SystemError(error.message) | ||
}) | ||
.then((res) => { | ||
if (!res.ok) { | ||
return res | ||
.json() | ||
.catch((error) => { | ||
throw new SystemError(error.message) | ||
}) | ||
.then((body) => { | ||
throw new errors[body.error](body.message) | ||
}) | ||
} | ||
|
||
return res.json() | ||
}) | ||
} | ||
|
||
export default retrieveResources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function Resource() { | ||
return ( | ||
<article className="resource"> | ||
<h2>Resource title</h2> | ||
|
||
<p>Description</p> | ||
</article> | ||
) | ||
} | ||
|
||
export default Resource |
21 changes: 21 additions & 0 deletions
21
staff/judy-grayland/project/app/src/pages/ResourcesList.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { useNavigate } from 'react-router-dom' | ||
|
||
import { Button } from '../components' | ||
import Resource from './Resource' | ||
|
||
function ResourcesList() { | ||
const navigate = useNavigate() | ||
|
||
function handleNewResourceClick() { | ||
navigate('/resources/new') | ||
} | ||
return ( | ||
<> | ||
<h2>Resources</h2> | ||
<Resource></Resource> | ||
<Button onClick={handleNewResourceClick}>Crear nuevo recurso</Button> | ||
</> | ||
) | ||
} | ||
|
||
export default ResourcesList |