1- import React , { useState } from 'react' ;
2- import { useEffect } from 'react' ;
3- import Card from './Card.tsx' ;
4- import './index.css'
5- import './components/Card.css'
6- import './components/Card.tsx'
7- import './components/Card.jsx'
8- import './components/form.jsx'
9- import './components/index.json'
10- import './components/main.tsx'
11- import './components/App.css'
12- import './components/App.js'
13- import './components/App.jsx'
14- import './components/index.css'
15- import './components/index.js'
16- import './components/tests.ts'
17- import './components/index.html'
18- import './components/tests.tsx'
19- import './form.css' ;
20- import { Form } from './form'
21- import './App.css' ;
22- import './index.css' ;
23- import main from './main.jsx' ;
24- import Main from './main.tsx' ;
25-
26- fetch ( "https://happy-thoughts-ux7hkzgmwa-uc.a.run.app/thoughts" )
27- fetch ( "https://happy-thoughts-ux7hkzgmwa-uc.a.run.app/thoughts/THOUGHT_ID/like" )
28- const [ thoughts , setThoughts ] = useState < { message : string } [ ] > ( [ ] )
1+ import React , { useState } from "react" ;
2+ import { useEffect } from "react" ;
3+ import Card from "./Card.tsx" ;
4+ import "./index.css" ;
5+ import "./components/Card.css" ;
6+ import "./components/Card.tsx" ;
7+ import "./components/Card.js" ;
8+ import "./components/form.js" ;
9+ import "./components/index.json" ;
10+ import "./components/main.tsx" ;
11+ import "./components/App.css" ;
12+ import "./components/App.js" ;
13+ import "./components/App.js" ;
14+ import "./components/index.css" ;
15+ import "./components/index.js" ;
16+ import "./components/tests.ts" ;
17+ import "./components/index.html" ;
18+ import "./components/tests.tsx" ;
19+ import "./form.css" ;
20+ import { Form } from "./form.jsx" ;
21+ import "./App.css" ;
22+ import "./index.css" ;
23+ import main from "./main.js" ;
24+ import Main from "./main.tsx" ;
25+
26+ fetch ( "https://happy-thoughts-ux7hkzgmwa-uc.a.run.app/thoughts" ) ;
27+ fetch (
28+ "https://happy-thoughts-ux7hkzgmwa-uc.a.run.app/thoughts/THOUGHT_ID/like"
29+ ) ;
30+ const [ thoughts , setThoughts ] = useState < { message : string } [ ] > ( [ ] ) ;
2931const handleFormSubmit = ( event ) => {
30- event . preventDefault ( )
32+ event . preventDefault ( ) ;
3133 fetch ( "<https://technigo-thoughts.herokuapp.com/>" , {
3234 method : "POST" ,
3335 body : JSON . stringify ( {
@@ -37,10 +39,9 @@ const handleFormSubmit = (event) => {
3739 } )
3840 . then ( ( res ) => res . json ( ) )
3941 . then ( ( newThought ) => {
40- setThoughts ( ( previousThoughts ) => [ newThought , ...previousThoughts ] )
41- } )
42- }
43-
42+ setThoughts ( ( previousThoughts ) => [ newThought , ...previousThoughts ] ) ;
43+ } ) ;
44+ } ;
4445
4546// if creating a Review as an object
4647interface Review {
@@ -50,10 +51,10 @@ interface Review {
5051}
5152
5253const App = ( ) => {
53- const [ selectedCard , setSelectedCard ] = useState < string > ( '' ) ;
54+ const [ selectedCard , setSelectedCard ] = useState < string > ( "" ) ;
5455 const [ reviews , setReviews ] = useState < Review [ ] > ( [ ] ) ; // if implementing an array of reviews
55- const [ review , setReview ] = useState ( '' ) ; // if implementing one review only, as string.
56- const [ reviewText , setReviewText ] = useState ( '' ) ;
56+ const [ review , setReview ] = useState ( "" ) ; // if implementing one review only, as string.
57+ const [ reviewText , setReviewText ] = useState ( "" ) ;
5758
5859 const handleCardSelect = ( title : string ) => {
5960 setSelectedCard ( title ) ;
@@ -63,7 +64,7 @@ const App = () => {
6364 const handleReviewSubmit = ( e : React . FormEvent ) => {
6465 e . preventDefault ( ) ; // stop from doing its default re render here.
6566 setReview ( reviewText ) ;
66- setReviewText ( '' ) ;
67+ setReviewText ( "" ) ;
6768 } ;
6869
6970 return (
@@ -79,14 +80,15 @@ const App = () => {
7980 />
8081 </ div >
8182
82-
8383 < div className = "message-section" >
8484 < h2 > Write a message</ h2 >
8585 < form onSubmit = { handleReviewSubmit } className = "message-form" >
8686 < textarea
8787 value = { reviewText }
8888 onChange = { ( e ) => setReviewText ( e . target . value ) }
89- placeholder = { `Write a thought for ${ selectedCard || 'your thought' } ...` }
89+ placeholder = { `Write a thought for ${
90+ selectedCard || "your thought"
91+ } ...`}
9092 className = "review-input"
9193 disabled = { ! selectedCard } // not able to write anything if not selected a message.
9294 />
@@ -100,14 +102,10 @@ const App = () => {
100102 </ form >
101103
102104 < div className = "send-container" >
105+ < h3 > Recent message</ h3 >
106+ < p className = "message-text" > { review } </ p >
103107
104- < h3 > Recent message</ h3 >
105- < p className = "message-text" > { review } </ p >
106-
107-
108-
109-
110- { /* IF creating an array of message with richer info, this is how to loop through and display them
108+ { /* IF creating an array of message with richer info, this is how to loop through and display them
111109<h3>Recent Message</h3>
112110{message.map(message => (
113111<div key={message.id} className="message-card">
@@ -117,10 +115,8 @@ const App = () => {
117115 ))} */ }
118116 </ div >
119117 </ div >
120-
121-
122118 </ main >
123- )
124- }
119+ ) ;
120+ } ;
125121
126- export default App
122+ export default App ;
0 commit comments