@@ -14,65 +14,36 @@ import {
1414 Textarea ,
1515 useToast ,
1616 VStack ,
17+ Text ,
18+ HStack ,
19+ Box ,
20+
1721} from "@chakra-ui/react" ;
1822
1923import { useBackendContext } from "../../contexts/hooks/useBackendContext" ;
24+ import { SuccessStoryForm } from "./SuccessStoryForm" ;
2025
21- export const SuccessStory = ( ) => {
22- type CaseManager = {
23- id : number ;
24- role : string ;
25- firstName : string ;
26- lastName : string ;
27- phone_number : string ;
28- email : string ;
29- } ;
30-
31- type Location = {
32- id : number ;
33- cm_id : number ; // Adjust the type for 'role' as per your actual data type (e.g., 'admin', 'user', etc.)
34- name : string ;
35- date : Date ;
36- caloptima_funded : boolean ;
37- } ;
26+ export type CaseManager = {
27+ id : number ;
28+ role : string ;
29+ firstName : string ;
30+ lastName : string ;
31+ phone_number : string ;
32+ email : string ;
33+ } ;
3834
39- const [ ClientStatus , setStatus ] = useState ( "1" ) ;
40- const [ locations , setLocations ] = useState ( [ ] ) ;
41- const [ caseManagers , setCaseManagers ] = useState ( [ ] ) ;
35+ export type Location = {
36+ id : number ;
37+ cm_id : number ; // Adjust the type for 'role' as per your actual data type (e.g., 'admin', 'user', etc.)
38+ name : string ;
39+ date : Date ;
40+ caloptima_funded : boolean ;
41+ } ;
4242
43+ export const SuccessStory = ( ) => {
4344 const { backend } = useBackendContext ( ) ;
4445 const toast = useToast ( ) ;
4546
46- useEffect ( ( ) => {
47- const getLocations = async ( ) => {
48- try {
49- const response = await backend . get ( "/locations" ) ;
50- setLocations ( response . data ) ;
51- } catch ( e ) {
52- toast ( {
53- title : "An error occurred" ,
54- description : `Locations were not fetched: ${ e . message } ` ,
55- status : "error" ,
56- } ) ;
57- }
58- } ;
59-
60- const getCaseManagers = async ( ) => {
61- try {
62- const response = await backend . get ( "/caseManagers" ) ;
63- setCaseManagers ( response . data ) ;
64- } catch ( e ) {
65- toast ( {
66- title : "An error occurred" ,
67- description : `Case Managers were not fetched: ${ e . message } ` ,
68- status : "error" ,
69- } ) ;
70- }
71- } ;
72- getLocations ( ) ;
73- getCaseManagers ( ) ;
74- } , [ backend , toast ] ) ;
75-
7647 const handleSubmit = async ( event : React . FormEvent < HTMLFormElement > ) => {
7748 event . preventDefault ( ) ;
7849 const form = event . currentTarget ;
@@ -94,154 +65,8 @@ export const SuccessStory = () => {
9465 } ) ;
9566 }
9667 } ;
97- return (
98- < VStack
99- spacing = { 8 }
100- sx = { { width : 300 , marginX : "auto" } }
101- >
102- < Heading > Success Story</ Heading >
10368
104- < form
105- style = { { width : "100%" } }
106- onSubmit = { handleSubmit }
107- >
108- < Stack spacing = { 2 } >
109- < FormControl isRequired >
110- < FormLabel > Client Name</ FormLabel >
111- < Input
112- name = "name"
113- placeholder = "First name"
114- />
115- </ FormControl >
116- < FormControl isRequired >
117- < FormLabel > Case Manager</ FormLabel >
118- < Select
119- name = "cm_id"
120- placeholder = "Select your case manager"
121- >
122- { caseManagers . map ( ( manager : CaseManager ) => (
123- < option
124- key = { manager . id }
125- value = { manager . id }
126- >
127- { manager . firstName } { manager . lastName }
128- </ option >
129- ) ) }
130- </ Select >
131- </ FormControl >
132- < FormControl isRequired >
133- < FormLabel > Site</ FormLabel >
134- < Select
135- name = "site"
136- placeholder = "Site"
137- >
138- { locations . map ( ( location : Location ) => (
139- < option
140- key = { location . id }
141- value = { location . id }
142- >
143- { location . name }
144- </ option >
145- ) ) }
146- </ Select >
147- </ FormControl >
148- < RadioGroup
149- onChange = { setStatus }
150- value = { ClientStatus }
151- >
152- < Stack direction = "row" >
153- < Radio value = "CurrentClient" > Current Client</ Radio >
154- < Radio value = "Graduate" > Graduate</ Radio >
155- </ Stack >
156- </ RadioGroup >
157- < FormControl isRequired >
158- < FormLabel > Entrance Date to CCH</ FormLabel >
159- < Input
160- name = "entrance_date"
161- type = "date"
162- />
163- </ FormControl >
164- < FormControl isRequired >
165- < FormLabel > Exit Date to CCH</ FormLabel >
166- < Input
167- name = "exit_date"
168- type = "date"
169- />
170- </ FormControl >
171- < FormControl isRequired >
172- < FormLabel >
173- Please tell us your situation before entering Colette’s Children’s
174- Home. Please give as many details as you are comfortable with
175- about your story, how long you were homeless, what led to
176- homelessness, etc. We want to help people understand what being
177- homeless is like.{ " " }
178- </ FormLabel >
179- < Textarea name = "previous_situation" />
180- </ FormControl >
181- < FormControl isRequired >
182- < FormLabel >
183- Tell us about your time in CCH and how CCH was part of the
184- solution to your situation and the impact it had on you and and/or
185- your children. What was most helpful, what you learned, etc.{ " " }
186- </ FormLabel >
187- < Textarea name = "cch_impact" />
188- </ FormControl >
189- < FormControl isRequired >
190- < FormLabel >
191- Tell us where you are now. If you are graduating where are you
192- moving, are you working, how are your children doing, etc. Tell us
193- a finish to your story.{ " " }
194- </ FormLabel >
195- < Textarea name = "where_now" />
196- </ FormControl >
197- < FormControl isRequired >
198- < FormLabel >
199- If you had the opportunity to tell one of our donors what it meant
200- to you to be at CCH or how important it is to provide our services
201- to other women, what would you say?
202- </ FormLabel >
203- < Textarea name = "tell_donors" />
204- </ FormControl >
205- < FormControl isRequired >
206- < FormLabel >
207- Please give a 1 to 2 sentence quote of what the CCH experience
208- meant to you?{ " " }
209- </ FormLabel >
210- < Textarea name = "quote" />
211- </ FormControl >
212- I consent to letting Colette’s Children’s Home se all or part of my
213- story in their marketing materials, such as website, newsletter,
214- brochures, videos, etc.
215- < FormControl isRequired >
216- < FormLabel > Consent </ FormLabel >
217- < Radio
218- type = "radio"
219- name = "consent"
220- value = "true"
221- >
222- Yes
223- </ Radio >
224- </ FormControl >
225- < FormControl isRequired >
226- < FormLabel > Client Signature:</ FormLabel >
227- < Input />
228- </ FormControl >
229- < FormControl isRequired >
230- < FormLabel > Date:</ FormLabel >
231- < Input
232- name = "date"
233- type = "date"
234- />
235- </ FormControl >
236- < Button
237- type = "submit"
238- size = { "lg" }
239- sx = { { width : "100%" } }
240- >
241- Submit
242- </ Button >
243- </ Stack >
244- </ form >
245- </ VStack >
69+ return (
70+ < SuccessStoryForm onSubmit = { handleSubmit } />
24671 ) ;
247- } ;
72+ } ;
0 commit comments