Skip to content

Commit 6a58068

Browse files
committed
organized components into folders for clarity
1 parent f64800d commit 6a58068

File tree

12 files changed

+38
-10
lines changed

12 files changed

+38
-10
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1887,4 +1887,32 @@ it('should delete note by id', () => {
18871887
18881888
[Code for this section](https://github.com/pairing4good/tdd-amplify-react/commit/00f9b6c36f94cbf19fe79a6107eccad3b3faa462)
18891889
1890-
</details>
1890+
</details>
1891+
1892+
<details>
1893+
<summary>Refactor Project Structure</summary>
1894+
1895+
## Refactor Project Structure
1896+
It's best to organize your code into a logical [folder structure](https://reactjs.org/docs/faq-structure.html) so that it's easier to understand and navigate.
1897+
1898+
- Move all of the components into a `note` folder in `src`
1899+
1900+
- note/
1901+
- App.js
1902+
- Footer.js
1903+
- Header.js
1904+
- NoteForm.js
1905+
- NoteList.js
1906+
1907+
- Move the `NoteRepository` component to a `common` folder in `src`
1908+
1909+
- common/
1910+
- NoteRepository.js
1911+
1912+
- Run all the tests
1913+
- Green
1914+
- Commit
1915+
1916+
[Code for this section]()
1917+
1918+
<details/>

src/NoteRepository.js renamed to src/common/NoteRepository.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { API } from 'aws-amplify';
2-
import { listNotes } from './graphql/queries';
3-
import { createNote as createNoteMutation, deleteNote as deleteNoteMutation} from './graphql/mutations';
2+
import { listNotes } from '../graphql/queries';
3+
import { createNote as createNoteMutation, deleteNote as deleteNoteMutation} from '../graphql/mutations';
44

55
export async function findAll(){
66
const apiData = await API.graphql({ query: listNotes });

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
33
import './index.css';
4-
import App from './App';
4+
import App from './note/App';
55
import reportWebVitals from './reportWebVitals';
66
import Amplify from 'aws-amplify';
77
import config from './aws-exports';

src/App.js renamed to src/note/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import './App.css';
1+
import '../App.css';
22
import NoteForm from './NoteForm';
33
import React, { useState, useEffect } from 'react';
44
import NoteList from './NoteList';
55
import Header from './Header';
6-
import { findAll, save, deleteById } from './NoteRepository';
6+
import { findAll, save, deleteById } from '../common/NoteRepository';
77
import { withAuthenticator } from '@aws-amplify/ui-react'
88
import Footer from './Footer';
99

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/test/Header.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { render, screen } from '@testing-library/react';
2-
import Header from '../Header';
2+
import Header from '../note/Header';
33

44
test('should display header', () => {
55
render(<Header />);

src/test/NoteForm.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { render, screen, fireEvent } from '@testing-library/react';
2-
import NoteForm from "../NoteForm";
2+
import NoteForm from "../note/NoteForm";
33

44
const createNoteCallback = jest.fn();
55
const setFormDataCallback = jest.fn();

0 commit comments

Comments
 (0)