diff --git a/src/client.ts b/src/client.ts
new file mode 100644
index 0000000..fe11508
--- /dev/null
+++ b/src/client.ts
@@ -0,0 +1,8 @@
+
+//To Do for this file:
+
+//1. make all the data exist in localStorage
+
+//1.1 that would be comments, number of comments, chord progression, files, title, and description
+
+//2. type it as asynch even though it's not yet, so it'll be easy to refactor to a backend that isn't localStorage
From 371de77381f2f733e53e51cebe518d3c77e33405 Mon Sep 17 00:00:00 2001
From: Alec Rollison <88508028+aelishRollo@users.noreply.github.com>
Date: Wed, 8 May 2024 10:42:22 -0400
Subject: [PATCH 53/58] Make comments persistant using localStorage
---
src/App.tsx | 3 +--
src/Comments.tsx | 14 +++++++++++++-
src/CreateComment.tsx | 16 ++++++++++++++--
src/client.ts | 2 ++
src/types.ts | 1 +
5 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/src/App.tsx b/src/App.tsx
index 9dd058b..e33fe37 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -8,7 +8,6 @@ import { Comments } from './Comments';
import { CreateComment } from './CreateComment';
import { SectionTitle } from './SectionTitle';
import { useState } from 'react';
-import { foo } from './client';
@@ -30,7 +29,7 @@ const App:React.FC = ({sectionData, chordProgression, comments, files}
-
+
);
diff --git a/src/Comments.tsx b/src/Comments.tsx
index 20154cc..a306557 100644
--- a/src/Comments.tsx
+++ b/src/Comments.tsx
@@ -2,9 +2,21 @@ import * as types from './types';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faFaceSmile } from '@fortawesome/free-solid-svg-icons';
import {comments as initialComments} from './testData'
+import { useEffect} from 'react';
-export const Comments: React.FC = ({ comments = initialComments }) => {
+export const Comments: React.FC = ({ comments = initialComments, setComments }) => {
+
+ useEffect(() => {
+ // Attempt to load comments from localStorage
+ const storedCommentsJSON = localStorage.getItem('comments');
+ const storedComments = storedCommentsJSON ? JSON.parse(storedCommentsJSON) : null;
+
+ // Check if there are stored comments, otherwise use initial comments
+ setComments(storedComments || initialComments);
+ }, []); // Empty dependency array ensures this runs once on mount
+
+
return (
{comments.length} Comments
diff --git a/src/CreateComment.tsx b/src/CreateComment.tsx
index 468cd20..49947f9 100644
--- a/src/CreateComment.tsx
+++ b/src/CreateComment.tsx
@@ -17,9 +17,21 @@ export const CreateComment: React.FC = ({ comments, setComme
const handleAddComment = () => {
const newComment = { name, commentText };
- const result = [...comments, newComment];
- setComments(result);
+
+ // Fetch existing comments from localStorage
+ const storedComments = localStorage.getItem('comments');
+ const existingComments = storedComments ? JSON.parse(storedComments) : [];
+
+ // Add the new comment to the array
+ const updatedComments = [...existingComments, newComment];
+
+ // Save the updated array back to localStorage
+ localStorage.setItem('comments', JSON.stringify(updatedComments));
+
+ // Update the local state to reflect the new list of comments
+ setComments(updatedComments);
}
+
return (
diff --git a/src/client.ts b/src/client.ts
index fe11508..18ba1b0 100644
--- a/src/client.ts
+++ b/src/client.ts
@@ -6,3 +6,5 @@
//1.1 that would be comments, number of comments, chord progression, files, title, and description
//2. type it as asynch even though it's not yet, so it'll be easy to refactor to a backend that isn't localStorage
+
+export default {}
diff --git a/src/types.ts b/src/types.ts
index 0386c73..9be5636 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -25,4 +25,5 @@ export type Comment = {
export type commentsProps = {
comments: Comment[]
+ setComments: (comments: Comment[]) => void;
}
From 2b25ef69b21ecd3cf6b6fb3873ce1d78f55bb4c3 Mon Sep 17 00:00:00 2001
From: Alec Rollison <88508028+aelishRollo@users.noreply.github.com>
Date: Wed, 8 May 2024 10:47:08 -0400
Subject: [PATCH 54/58] Rename testData.tsx to sampleData.tsx
---
src/App.test.tsx | 2 +-
src/Comments.tsx | 2 +-
src/index.tsx | 2 +-
src/{testData.ts => sampleData.ts} | 13 +++++--------
4 files changed, 8 insertions(+), 11 deletions(-)
rename src/{testData.ts => sampleData.ts} (70%)
diff --git a/src/App.test.tsx b/src/App.test.tsx
index aa9b389..af186ec 100644
--- a/src/App.test.tsx
+++ b/src/App.test.tsx
@@ -1,5 +1,5 @@
import { render, screen } from '@testing-library/react';
-import * as testData from './testData'
+import * as testData from './sampleData'
import App from './App';
test('renders learn react link', () => {
diff --git a/src/Comments.tsx b/src/Comments.tsx
index a306557..218f51a 100644
--- a/src/Comments.tsx
+++ b/src/Comments.tsx
@@ -1,7 +1,7 @@
import * as types from './types';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faFaceSmile } from '@fortawesome/free-solid-svg-icons';
-import {comments as initialComments} from './testData'
+import {comments as initialComments} from './sampleData'
import { useEffect} from 'react';
diff --git a/src/index.tsx b/src/index.tsx
index 466f9aa..14bf9ac 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
-import * as testData from './testData'
+import * as testData from './sampleData'
import App from './App';
import reportWebVitals from './reportWebVitals';
diff --git a/src/testData.ts b/src/sampleData.ts
similarity index 70%
rename from src/testData.ts
rename to src/sampleData.ts
index 0673458..e3b1db8 100644
--- a/src/testData.ts
+++ b/src/sampleData.ts
@@ -35,15 +35,12 @@ export const files: Types.File[] = [
export const comments: Types.Comment[] = [
{
- name: 'Jerry',
- commentText: 'My name is Schmoopie and I love this song. It reminds me of my grandpa'
+ name: 'Sample User',
+ commentText: 'Hey! This is a comment'
},
{
- name: 'Lerry',
- commentText: 'jokes on you! Im deaf.'
- },
- {
- name: 'Jerry',
- commentText: 'Notice the tinnitus ringing in your ears, let the hiss from your damaged hearing remind you of peaceful ocean waves...'
+ name: 'Sample User',
+ commentText: 'Hey! This is a comment'
},
+
]
From 8efdec6cc765586ded82b3daec2dbee2793f4b77 Mon Sep 17 00:00:00 2001
From: Alec Rollison <88508028+aelishRollo@users.noreply.github.com>
Date: Thu, 9 May 2024 16:24:16 -0400
Subject: [PATCH 55/58] Move comments data to localStorage
---
src/sampleData.ts | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/sampleData.ts b/src/sampleData.ts
index e3b1db8..1a438b8 100644
--- a/src/sampleData.ts
+++ b/src/sampleData.ts
@@ -42,5 +42,4 @@ export const comments: Types.Comment[] = [
name: 'Sample User',
commentText: 'Hey! This is a comment'
},
-
]
From 524408ffbc3231bcf3736f80f9205a6b498b0409 Mon Sep 17 00:00:00 2001
From: Michael Kochell <6913320+mickmister@users.noreply.github.com>
Date: Sat, 11 May 2024 22:39:50 -0400
Subject: [PATCH 56/58] Create ci workflows for build and type checking (#7)
* create ci workflows for build and type checking
* ignore empty dep array in useEffect
* add linting
---
.github/workflows/ci.yml | 52 ++++++++++++++++++++++++++++++++++++++++
.gitignore | 2 ++
.gitpod.yml | 3 +++
package.json | 5 +++-
src/Comments.tsx | 5 ++--
src/client.ts | 10 --------
6 files changed, 64 insertions(+), 13 deletions(-)
create mode 100644 .github/workflows/ci.yml
create mode 100644 .gitpod.yml
delete mode 100644 src/client.ts
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..8b8f453
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,52 @@
+name: CI
+
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+ branches:
+ - '**'
+ workflow_dispatch:
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Install Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: 21
+ cache: 'npm'
+ - name: Install modules
+ run: npm i
+ - name: Build app
+ run: npm run build
+ types:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Install Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: 21
+ cache: 'npm'
+ - name: Install modules
+ run: npm i
+ - name: Check Types
+ run: npm run check-types
+
+ lint:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Install Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: 21
+ cache: 'npm'
+ - name: Install modules
+ run: npm i
+ - name: Run eslint
+ run: npm run lint
diff --git a/.gitignore b/.gitignore
index 4d29575..84d9f63 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
+
+_ignore
diff --git a/.gitpod.yml b/.gitpod.yml
new file mode 100644
index 0000000..c4b48c3
--- /dev/null
+++ b/.gitpod.yml
@@ -0,0 +1,3 @@
+tasks:
+ - init: npm install && npm run build
+ command: npm run start
diff --git a/package.json b/package.json
index b6d5992..6b7bebc 100644
--- a/package.json
+++ b/package.json
@@ -25,7 +25,10 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
- "eject": "react-scripts eject"
+ "eject": "react-scripts eject",
+ "lint": "eslint src/**/*.ts*",
+ "fix": "npm run lint -- --fix",
+ "check-types": "tsc --noEmit"
},
"eslintConfig": {
"extends": [
diff --git a/src/Comments.tsx b/src/Comments.tsx
index 218f51a..1823f5a 100644
--- a/src/Comments.tsx
+++ b/src/Comments.tsx
@@ -14,8 +14,9 @@ export const Comments: React.FC = ({ comments = initialComm
// Check if there are stored comments, otherwise use initial comments
setComments(storedComments || initialComments);
- }, []); // Empty dependency array ensures this runs once on mount
-
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
return (
diff --git a/src/client.ts b/src/client.ts
deleted file mode 100644
index 18ba1b0..0000000
--- a/src/client.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-
-//To Do for this file:
-
-//1. make all the data exist in localStorage
-
-//1.1 that would be comments, number of comments, chord progression, files, title, and description
-
-//2. type it as asynch even though it's not yet, so it'll be easy to refactor to a backend that isn't localStorage
-
-export default {}
From 571c1b0296025c75b1c88100049699773a07f209 Mon Sep 17 00:00:00 2001
From: Alec Rollison <88508028+aelishRollo@users.noreply.github.com>
Date: Fri, 24 May 2024 16:18:48 -0400
Subject: [PATCH 57/58] Update README.md
---
README.md | 41 +++++++----------------------------------
1 file changed, 7 insertions(+), 34 deletions(-)
diff --git a/README.md b/README.md
index b87cb00..9cddb47 100644
--- a/README.md
+++ b/README.md
@@ -1,46 +1,19 @@
-# Getting Started with Create React App
+## Section-View: a new tool for musical composition
-This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
-## Available Scripts
-In the project directory, you can run:
+### Section view is a collaborative pre-DAW music application
-### `npm start`
+## Tech Used: ![JAVASCRIPT BADGE](https://img.shields.io/static/v1?label=|&message=JAVASCRIPT&color=3c7f5d&style=plastic&logo=javascript) ![React Badge](https://img.shields.io/static/v1?label=|&message=REACT&color=61DAFB&style=plastic&logo=react)![TypeScript Badge](https://img.shields.io/static/v1?label=|&message=TypeScript&color=3178C6&style=plastic&logo=typescript)
-Runs the app in the development mode.\
-Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
-The page will reload if you make edits.\
-You will also see any lint errors in the console.
-### `npm test`
-Launches the test runner in the interactive watch mode.\
-See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
-### `npm run build`
+## Optimizations
-Builds the app for production to the `build` folder.\
-It correctly bundles React in production mode and optimizes the build for the best performance.
+This project is constantly improving and growing. We're working on extending the scope of the project as you read this
-The build is minified and the filenames include the hashes.\
-Your app is ready to be deployed!
+## Lessons Learned:
-See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
-
-### `npm run eject`
-
-**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
-
-If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
-
-Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
-
-You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
-
-## Learn More
-
-You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
-
-To learn React, check out the [React documentation](https://reactjs.org/).
+Learned quite a bit about managing complexity and writing scalable and maintainable code
From bc5af78a6c40f74dd2e0fea114686de637c8afd4 Mon Sep 17 00:00:00 2001
From: Michael Kochell <6913320+mickmister@users.noreply.github.com>
Date: Sat, 1 Jun 2024 15:14:27 -0400
Subject: [PATCH 58/58] Refactor to use local storage (#8)
* initial take on refactoring to store and client
* connect section title to store
* make the app use localStorage
* remote IStore interface to simplify. fix workflow test command
* use typed in username for comments
* add import for index.css
---
.eslintrc.json | 10 ++
.github/workflows/ci.yml | 14 ++
package.json | 10 +-
src/App.test.tsx | 211 ++++++++++++++++++++++--
src/App.tsx | 79 ++++++---
src/ChordProgression.tsx | 2 +-
src/Comments.tsx | 55 +++---
src/CreateComment.tsx | 84 ++++------
src/Files.tsx | 41 +++--
src/SectionPage.tsx | 35 ++++
src/SectionTitle.tsx | 109 +++++++-----
src/actions/useActions.ts | 44 +++++
src/client/IClient.ts | 8 +
src/client/LocalStorageClient.ts | 59 +++++++
src/hooks/useClient.tsx | 21 +++
src/hooks/useGlobalStore.tsx | 87 ++++++++++
src/hooks/useMount.ts | 9 +
src/index.tsx | 37 +++--
src/logo.svg | 1 -
src/sampleData.ts | 45 -----
src/store/LocalStorageStore.ts | 207 +++++++++++++++++++++++
src/store/MockLocalStorageDependency.ts | 24 +++
src/types.ts | 58 ++++---
src/utils.ts | 13 ++
{src => tests}/setupTests.ts | 0
25 files changed, 1002 insertions(+), 261 deletions(-)
create mode 100644 .eslintrc.json
create mode 100644 src/SectionPage.tsx
create mode 100644 src/actions/useActions.ts
create mode 100644 src/client/IClient.ts
create mode 100644 src/client/LocalStorageClient.ts
create mode 100644 src/hooks/useClient.tsx
create mode 100644 src/hooks/useGlobalStore.tsx
create mode 100644 src/hooks/useMount.ts
delete mode 100644 src/logo.svg
delete mode 100644 src/sampleData.ts
create mode 100644 src/store/LocalStorageStore.ts
create mode 100644 src/store/MockLocalStorageDependency.ts
create mode 100644 src/utils.ts
rename {src => tests}/setupTests.ts (100%)
diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 0000000..21ae569
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,10 @@
+{
+ "extends": [
+ "react-app",
+ "react-app/jest"
+ ],
+ "rules": {
+ "testing-library/no-container": "off",
+ "testing-library/no-node-access": "off"
+ }
+ }
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 8b8f453..db1b606 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -50,3 +50,17 @@ jobs:
run: npm i
- name: Run eslint
run: npm run lint
+
+ test:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Install Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: 21
+ cache: 'npm'
+ - name: Install modules
+ run: npm i
+ - name: Run tests
+ run: npm run test:ci
diff --git a/package.json b/package.json
index 6b7bebc..c2058f8 100644
--- a/package.json
+++ b/package.json
@@ -25,16 +25,12 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
+ "test:ci": "react-scripts test --watchAll=false",
"eject": "react-scripts eject",
"lint": "eslint src/**/*.ts*",
"fix": "npm run lint -- --fix",
- "check-types": "tsc --noEmit"
- },
- "eslintConfig": {
- "extends": [
- "react-app",
- "react-app/jest"
- ]
+ "check-types": "tsc --noEmit",
+ "ci": "npm run lint && npm run check-types && npm run test:ci && npm run build"
},
"browserslist": {
"production": [
diff --git a/src/App.test.tsx b/src/App.test.tsx
index af186ec..8e27742 100644
--- a/src/App.test.tsx
+++ b/src/App.test.tsx
@@ -1,16 +1,201 @@
-import { render, screen } from '@testing-library/react';
-import * as testData from './sampleData'
+import {render, screen, waitFor} from '@testing-library/react';
import App from './App';
+import {IClient} from './client/IClient';
+import {ProjectData, CommentData, SectionData, EntityType, FileData} from './types';
+import {LocalStorageStore, StoreData} from './store/LocalStorageStore';
+import {MockLocalStorageDependency} from './store/MockLocalStorageDependency';
+import {LocalStorageClient} from './client/LocalStorageClient';
-test('renders learn react link', () => {
- render(
-
- );
- const linkElement = screen.getByText(/learn react/i);
- expect(linkElement).toBeInTheDocument();
+// import * as testData from './sampleData'
+
+window.alert = () => {};
+
+const makeTestStore = (): StoreData => {
+ const initialProjects: ProjectData[] = [
+ {
+ id: 'project-1',
+ },
+ {
+ id: 'project-2',
+ },
+ ];
+
+ const initialSections: SectionData[] = [
+ {
+ id: 'section-1',
+ projectId: 'project-1',
+ chordProgression: ['C', 'Dm', 'F', 'G'],
+ description: 'This is the intro',
+ title: 'Intro',
+ numRevisions: 3,
+ }
+ ];
+
+ const initialFiles: FileData[] = [
+ {
+ id: 'file-1',
+ projectId: 'project-1',
+ entityId: 'section-1',
+ entityType: EntityType.SECTION,
+ title: 'Bass.mp3',
+ },
+ {
+ id: 'file-2',
+ projectId: 'project-1',
+ entityId: 'section-1',
+ entityType: EntityType.SECTION,
+ title: 'Chunky Monkey.mp3',
+ },
+ ];
+
+ const initialComments: CommentData[] = [
+ {
+ id: 'comment-1',
+ projectId: 'project-1',
+ message: 'Hey what\'s up',
+ entityType: EntityType.SECTION,
+ entityId: 'section-1',
+ username: 'username-1',
+ },
+ {
+ id: 'comment-2',
+ projectId: 'project-1',
+ message: 'Yeah',
+ entityType: EntityType.FILE,
+ entityId: 'file-1',
+ username: 'username-1',
+ },
+ {
+ id: 'comment-3',
+ projectId: 'project-1',
+ message: 'Yeah 3',
+ entityType: EntityType.FILE,
+ entityId: 'file-1',
+ username: 'username-1',
+ },
+ ];
+
+ return {
+ projects: initialProjects,
+ sections: initialSections,
+ files: initialFiles,
+ comments: initialComments,
+ };
+};
+
+describe('App', () => {
+ let client: IClient;
+
+ beforeEach(() => {
+ const initialStore = makeTestStore();
+
+ const localStorageDependency = new MockLocalStorageDependency(initialStore);
+ const store = new LocalStorageStore(localStorageDependency);
+ client = new LocalStorageClient(store);
+ });
+
+ describe('initializing', () => {
+ it('should show "Loading"', async () => {
+ // this method is made blocking for this specific test
+ client.fetchFullDataForProject = (() => new Promise(r => setTimeout(r)));
+
+ render(
+
+ );
+
+ expect(screen.getByText(/Loading/)).toBeDefined();
+ });
+
+ it('should show client error', async () => {
+ client.fetchFullDataForProject = jest.fn().mockResolvedValue(new Error('Some error'));
+
+ render(
+
+ );
+
+ await waitFor(() => {
+ expect(screen.queryByText(/Loading/)).toBeNull();
+ });
+
+ expect(screen.getByText(/Some error/)).toBeDefined();
+ });
+ });
+
+ describe('initialized', () => {
+ it('should show the section title and description', async () => {
+ render(
+
+ );
+
+ await waitFor(() => {
+ expect(screen.queryByText(/Loading/)).toBeNull();
+ });
+
+ expect(screen.getByText(/Intro/)).toBeDefined();
+ expect(screen.getByText(/This is the intro/)).toBeDefined();
+ });
+
+ it('should show the chord progression', async () => {
+ const {container} = render(
+
+ );
+
+ await waitFor(() => {
+ expect(screen.queryByText(/Loading/)).toBeNull();
+ });
+
+ expect(container.querySelector('.chords')?.textContent).toEqual('CDmFG');
+ });
+
+ it('should show files attached to the section', async () => {
+ const {container} = render(
+
+ );
+
+ await waitFor(() => {
+ expect(screen.queryByText(/Loading/)).toBeNull();
+ });
+
+ expect(container.querySelector('.files #file-1')?.textContent).toContain('Bass.mp3');
+ expect(container.querySelector('.files #file-1')?.textContent).toContain('2 Comments');
+ });
+
+ it('should show the comments on the section', async () => {
+ const {container} = render(
+
+ );
+
+ await waitFor(() => {
+ expect(screen.queryByText(/Loading/)).toBeNull();
+ });
+
+ expect(container.querySelector('.comments')?.textContent).toContain('1 Comment');
+ expect(container.querySelector('.comments #comment-1')?.textContent).toContain('username-1');
+ expect(container.querySelector('.comments #comment-1')?.textContent).toContain('Hey what\'s up');
+ });
+ });
});
diff --git a/src/App.tsx b/src/App.tsx
index e33fe37..df11b80 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,38 +1,69 @@
+import {useState} from 'react';
+
import './App.css';
import './css_reset.css'
+import './index.css'
import './section_view.css';
import * as types from './types';
-import { Files } from './Files';
-import { ChordProgression } from './ChordProgression';
-import { Comments } from './Comments';
-import { CreateComment } from './CreateComment';
-import { SectionTitle } from './SectionTitle';
-import { useState } from 'react';
+import {GlobalStoreProvider} from './hooks/useGlobalStore';
+import SectionPage from './SectionPage';
+import {IClient} from './client/IClient';
+import {ClientProvider} from './hooks/useClient';
+import {useMount} from './hooks/useMount';
+type AppProps = {
+ projectId: string;
+ sectionId: string;
+ client: IClient;
+}
+const App: React.FC = ({projectId, sectionId, client}) => {
+ const [initialProjectData, setInitialProjectData] = useState(null);
+ const [error, setError] = useState('');
-type AppProps = {
- sectionData: types.SectionData,
- chordProgression: types.ChordProgression,
- files: types.File[],
- comments: types.Comment[]
-}
+ useMount(async () => {
+ const projectDataOrError = await client.fetchFullDataForProject(projectId);
+
+ if (projectDataOrError instanceof Error) {
+ alert(projectDataOrError.message);
+ setError(projectDataOrError.message);
+ return;
+ }
+
+ setInitialProjectData(projectDataOrError);
+ });
+
+ if (error) {
+ return (
+