From a76945284f2d3161864f5782db337cce9dc6f52e Mon Sep 17 00:00:00 2001 From: charlesjin123 Date: Wed, 13 Nov 2024 15:53:34 -0500 Subject: [PATCH 1/2] postData --- .../src/components/forms/ProgramOutcome.tsx | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/client/src/components/forms/ProgramOutcome.tsx b/client/src/components/forms/ProgramOutcome.tsx index 0269160f..52ec7cb7 100644 --- a/client/src/components/forms/ProgramOutcome.tsx +++ b/client/src/components/forms/ProgramOutcome.tsx @@ -22,6 +22,7 @@ import { MenuItem, InputLabel, } from '@mui/material'; +import { postData } from '../../util/api'; export default function ProgramOutcome() { enum YouthEnrollmentStructure { @@ -267,14 +268,17 @@ export default function ProgramOutcome() { }; const handleSubmit = async () => { if (validateInputs()) { - axios - .post('http://localhost:4000/api/program.outcomes/', formState) - .then((response) => { - console.log('successfully submitted!'); - }) - .catch((error) => { - console.log(error); - }); + try { + const response = await postData('program.outcomes/', formState); + console.log('Program outcome submitted successfully:', response); + // Handle success (e.g., show a success message, reset form, etc.) + } catch (error) { + console.error('Error submitting program outcome:', error); + // Handle error (e.g., show an error message) + } + } else { + console.error('Validation failed: Please fill out all required fields.'); + // Handle validation failure (e.g., show a validation error message) } }; return ( From e40efac84b837d5133c0a89c8a481a34c9c288e3 Mon Sep 17 00:00:00 2001 From: charlesjin123 Date: Sun, 17 Nov 2024 13:54:57 -0500 Subject: [PATCH 2/2] fixed program outcomes form submission + slightly changed program outcomes model --- .../src/components/forms/ProgramOutcome.tsx | 654 ++++++++++-------- server/src/models/program.outcomes.model.ts | 36 +- .../src/services/program.outcomes.service.ts | 7 +- 3 files changed, 389 insertions(+), 308 deletions(-) diff --git a/client/src/components/forms/ProgramOutcome.tsx b/client/src/components/forms/ProgramOutcome.tsx index 860f9ba1..32762b32 100644 --- a/client/src/components/forms/ProgramOutcome.tsx +++ b/client/src/components/forms/ProgramOutcome.tsx @@ -37,15 +37,15 @@ export default function ProgramOutcome() { responderName: string; responderTitle: string; programCostPerTrainee: number; - youthProgram: boolean; + programDesignedForYouthAndAdults: boolean; youthTrained?: number; youthProgramRetentionRate?: number; youthPositiveOutcomes?: number; youthWage?: number; - youthJobRetention3Months?: number; - youthJobRetention6Months?: number; - youthJobRetention12Months?: number; - youthJobRetention2Years?: number; + youthJobRetentionThreeMonths?: number; + youthJobRetentionSixMonths?: number; + youthJobRetentionTwelveMonths?: number; + youthJobRetentionTwentyFourMonths?: number; youthProgramWeeks?: number; youthProgramHours?: number; youthEnrollmentStructure?: YouthEnrollmentStructure; @@ -59,7 +59,7 @@ export default function ProgramOutcome() { | 'All weeks of program' | 'Early exit for employment allowed' | 'Other'; - measureYouthOutcomes?: ( + youthOutcomesMeasure?: ( | 'High School Graduation' | 'Return to School' | 'Family Reunification' @@ -67,95 +67,114 @@ export default function ProgramOutcome() { | 'Stable Housing' | 'Other' )[]; - adultProgram: boolean; + programsThatServeAdults: boolean; adultsTrained?: number; adultsGraduated?: number; - adultsPositiveOutcome?: number; - adultsJobPlacementGraduates?: number; - adultsWage?: number; - adultsJobRetention3Months?: number; - adultsJobRetention6Months?: number; - adultsWage6Months?: number; - adultsJobRetention12Months?: number; - adultsWage12Months?: number; - adultsJobRetention24Months?: number; - adultsWage24Months?: number; + adultPositiveOutcome?: number; + adultJobPlacement?: number; + adultWage?: number; + adultJobRetentionThreeMonths?: number; + adultJobRetentionSixMonths?: number; + adultWageAtSixMonths?: number; + adultJobRetentionTwelveMonths?: number; + adultWageAtTwelveMonths?: number; + adultJobRetentionTwentyFourMonths?: number; + adultWageTwentyFourMonths?: number; adultProgramWeeks?: number; adultProgramHours?: number; - adultsEnrollmentStructure?: 'Single Cohort' | 'Staggered'; - adultsCompensation?: 'Hourly' | 'Stipend' | 'None'; + adultEnrollmentStructure?: 'Single Cohort' | 'Staggered'; + adultCompensation?: 'Hourly' | 'Stipend' | 'None'; adultTrainedDefinition?: | 'The first day of program' | '2-4 day provisional period' | 'One week provisional period' | 'Two week provisional period' | 'Other'; - traineesAge?: number; - traineesPercentFemale?: number; - traineesPercentMale?: number; - traineesPercentNonBinary?: number; - traineesPercentTransgender?: number; - traineesPercentAmericanIndian?: number; - traineesPercentAsian?: number; - traineesPercentBlack?: number; - traineesPercentLatinx?: number; - traineesPercentNativeHawaiian?: number; - traineesPercentMultiRacial?: number; - traineesPercentWhite?: number; - traineesPercentOtherRace?: number; - traineesPercentRaceUnknown?: number; - barrierReturningCitizens?: number; + traineeAge?: number; + traineePercentFemale?: number; + traineePercentMale?: number; + traineePercentNonBinary?: number; + traineePercentTransgender?: number; + traineePercentAmericanIndian?: number; + traineePercentAsianOrAsianAmerican?: number; + traineePercentBlackOrAfricanAmerican?: number; + traineePercentLatinaLatinoLatinx?: number; + traineePercentNativeHawaiianPacificIslander?: number; + traineeMultiracial?: number; + traineeWhite?: number; + traineeOtherRace?: number; + traineeRaceUnknown?: number; + barrierReturningCitizensOrFormerlyIncarceratedPersons?: number; barrierPhysicalDisability?: number; - barrierIntellectualDisability?: number; + barrierIntellectualOrDevelopmentalDisability?: number; barrierUnhoused?: number; barrierMentalHealth?: number; barrierNewAmericans?: number; barrierInRecovery?: number; barrierVeteran?: number; - wrapAroundHousing?: 'Partner agency' | 'In-house' | 'Not provided'; - wrapAroundLifeSkills?: 'Partner agency' | 'In-house' | 'Not provided'; - wrapAroundCaseManagement?: 'Partner agency' | 'In-house' | 'Not provided'; - wrapAroundJobSearch?: 'Partner agency' | 'In-house' | 'Not provided'; - wrapAroundRecoveryTreatment?: - | 'Partner agency' - | 'In-house' - | 'Not provided'; - wrapAroundMentalHealthServices?: - | 'Partner agency' - | 'In-house' - | 'Not provided'; - wrapAroundHealthcare?: 'Partner agency' | 'In-house' | 'Not provided'; - wrapAroundChildcare?: 'Partner agency' | 'In-house' | 'Not provided'; - wrapAroundTransportation?: 'Partner agency' | 'In-house' | 'Not provided'; - otherWrapAroundServices?: string; - fundingPublic?: number; - fundingPrivate?: number; - fundingSocialEnterprise?: number; - snapET?: 'Yes' | 'No But' | 'No And'; - wioa?: 'Yes' | 'No But' | 'No And'; + wrapAroundServicesHousing?: + | 'You mostly facilitate access through partner agency' + | 'You mostly provide in-house' + | 'Your program does not provide or facilitate access'; + wrapAroundServicesLifeSkillsOrSocialEmotionalLearning?: + | 'You mostly facilitate access through partner agency' + | 'You mostly provide in-house' + | 'Your program does not provide or facilitate access'; + wrapAroundServicesCaseManagement?: + | 'You mostly facilitate access through partner agency' + | 'You mostly provide in-house' + | 'Your program does not provide or facilitate access'; + wrapAroundServicesJobSearchAndPlacement?: + | 'You mostly facilitate access through partner agency' + | 'You mostly provide in-house' + | 'Your program does not provide or facilitate access'; + wrapAroundServicesRecoveryTreatment?: + | 'You mostly facilitate access through partner agency' + | 'You mostly provide in-house' + | 'Your program does not provide or facilitate access'; + wrapAroundServicesMentalHealthServices?: + | 'You mostly facilitate access through partner agency' + | 'You mostly provide in-house' + | 'Your program does not provide or facilitate access'; + wrapAroundServicesHealthcareAllOther?: + | 'You mostly facilitate access through partner agency' + | 'You mostly provide in-house' + | 'Your program does not provide or facilitate access'; + wrapAroundServicesChildcare?: + | 'You mostly facilitate access through partner agency' + | 'You mostly provide in-house' + | 'Your program does not provide or facilitate access'; + wrapAroundServicesTransportation?: + | 'You mostly facilitate access through partner agency' + | 'You mostly provide in-house' + | 'Your program does not provide or facilitate access'; + otherPleaseSpecifyOtherWrapAroundServices?: string; + fundingPercentFromPublicFunding?: number; + fundingPercentFromPrivateFunding?: number; + fundingPercentFromSocialEnterpriseOrGeneratedRevenue?: number; + SNAPEAndT?: 'Yes' | 'No But' | 'No And'; + WIOA?: 'Yes' | 'No But' | 'No And'; curriculum?: 'All' | 'Part'; - programCertifications?: ( + programCertifications?: | 'ACF Quality/Approved Program' | 'DOL approved apprenticeship' | 'State Association apprenticeship' | 'Local or State Dept. of Education or Community College' - | 'Other' - )[]; + | 'Other'; otherProgramCertifications?: string; - participantCertifications?: ( + participantCertifications?: | 'Basic Food Safety' | 'Advanced Food Safety' | 'Credit toward Comm College' | 'ACF Certification' | 'NRA' | 'AHLEI' - | 'Other' - )[]; + | 'Other'; otherParticipantCertifications?: string; internshipOrExternship?: boolean; - internshipDescription?: string; + internshipOrExternshipDescription?: string; minimumWage?: number; - jobTypeFoodService?: '1-25%' | '26-50%' | '51-75%' | '76-100%'; + jobType?: '1-25%' | '26-50%' | '51-75%' | '76-100%'; jobCategory?: | 'Food Service: restaurant, cafe' | 'Food Service: institutional' @@ -174,102 +193,111 @@ export default function ProgramOutcome() { organizationName: '', responderName: '', responderTitle: '', - programCostPerTrainee: 0.0, - youthProgram: false, + programCostPerTrainee: 0, + programDesignedForYouthAndAdults: false, youthTrained: undefined, youthProgramRetentionRate: undefined, youthPositiveOutcomes: undefined, youthWage: undefined, - youthJobRetention3Months: undefined, - youthJobRetention6Months: undefined, - youthJobRetention12Months: undefined, - youthJobRetention2Years: undefined, + youthJobRetentionThreeMonths: undefined, + youthJobRetentionSixMonths: undefined, + youthJobRetentionTwelveMonths: undefined, + youthJobRetentionTwentyFourMonths: undefined, youthProgramWeeks: undefined, youthProgramHours: undefined, youthEnrollmentStructure: undefined, youthCompensation: undefined, youthTrainedDefinition: undefined, - youthGraduatedDefinition: 'All weeks of program', - measureYouthOutcomes: [], // Empty array for multiple choice - adultProgram: false, + youthGraduatedDefinition: undefined, + youthOutcomesMeasure: undefined, + programsThatServeAdults: false, adultsTrained: undefined, adultsGraduated: undefined, - adultsPositiveOutcome: undefined, - adultsJobPlacementGraduates: undefined, - adultsWage: undefined, - adultsJobRetention3Months: undefined, - adultsJobRetention6Months: undefined, - adultsWage6Months: undefined, - adultsJobRetention12Months: undefined, - adultsWage12Months: undefined, - adultsJobRetention24Months: undefined, - adultsWage24Months: undefined, + adultPositiveOutcome: undefined, + adultJobPlacement: undefined, + adultWage: undefined, + adultJobRetentionThreeMonths: undefined, + adultJobRetentionSixMonths: undefined, + adultWageAtSixMonths: undefined, + adultJobRetentionTwelveMonths: undefined, + adultWageAtTwelveMonths: undefined, + adultJobRetentionTwentyFourMonths: undefined, + adultWageTwentyFourMonths: undefined, adultProgramWeeks: undefined, adultProgramHours: undefined, - adultsEnrollmentStructure: undefined, - adultsCompensation: undefined, + adultEnrollmentStructure: undefined, + adultCompensation: undefined, adultTrainedDefinition: undefined, - traineesAge: undefined, - traineesPercentFemale: undefined, - traineesPercentMale: undefined, - traineesPercentNonBinary: undefined, - traineesPercentTransgender: undefined, - traineesPercentAmericanIndian: undefined, - traineesPercentAsian: undefined, - traineesPercentBlack: undefined, - traineesPercentLatinx: undefined, - traineesPercentNativeHawaiian: undefined, - traineesPercentMultiRacial: undefined, - traineesPercentWhite: undefined, - traineesPercentOtherRace: undefined, - traineesPercentRaceUnknown: undefined, - barrierReturningCitizens: undefined, + traineeAge: undefined, + traineePercentFemale: undefined, + traineePercentMale: undefined, + traineePercentNonBinary: undefined, + traineePercentTransgender: undefined, + traineePercentAmericanIndian: undefined, + traineePercentAsianOrAsianAmerican: undefined, + traineePercentBlackOrAfricanAmerican: undefined, + traineePercentLatinaLatinoLatinx: undefined, + traineePercentNativeHawaiianPacificIslander: undefined, + traineeMultiracial: undefined, + traineeWhite: undefined, + traineeOtherRace: undefined, + traineeRaceUnknown: undefined, + barrierReturningCitizensOrFormerlyIncarceratedPersons: undefined, barrierPhysicalDisability: undefined, - barrierIntellectualDisability: undefined, - barrierUnhoused: 0, - barrierMentalHealth: 0, - barrierNewAmericans: 0, - barrierInRecovery: 0, - barrierVeteran: 0, - wrapAroundHousing: undefined, - wrapAroundLifeSkills: undefined, - wrapAroundCaseManagement: undefined, - wrapAroundJobSearch: undefined, - wrapAroundRecoveryTreatment: undefined, - wrapAroundMentalHealthServices: undefined, - wrapAroundHealthcare: undefined, - wrapAroundChildcare: undefined, - wrapAroundTransportation: undefined, - otherWrapAroundServices: '', - fundingPublic: undefined, - fundingPrivate: undefined, - fundingSocialEnterprise: undefined, - snapET: undefined, - wioa: undefined, + barrierIntellectualOrDevelopmentalDisability: undefined, + barrierUnhoused: undefined, + barrierMentalHealth: undefined, + barrierNewAmericans: undefined, + barrierInRecovery: undefined, + barrierVeteran: undefined, + wrapAroundServicesHousing: undefined, + wrapAroundServicesLifeSkillsOrSocialEmotionalLearning: undefined, + wrapAroundServicesCaseManagement: undefined, + wrapAroundServicesJobSearchAndPlacement: undefined, + wrapAroundServicesRecoveryTreatment: undefined, + wrapAroundServicesMentalHealthServices: undefined, + wrapAroundServicesHealthcareAllOther: undefined, + wrapAroundServicesChildcare: undefined, + wrapAroundServicesTransportation: undefined, + otherPleaseSpecifyOtherWrapAroundServices: '', + fundingPercentFromPublicFunding: undefined, + fundingPercentFromPrivateFunding: undefined, + fundingPercentFromSocialEnterpriseOrGeneratedRevenue: undefined, + SNAPEAndT: undefined, + WIOA: undefined, curriculum: undefined, - programCertifications: [], // Empty array for multiple choice - otherProgramCertifications: undefined, - participantCertifications: [], // Empty array for multiple choice - otherParticipantCertifications: undefined, + programCertifications: undefined, + otherProgramCertifications: '', + participantCertifications: undefined, + otherParticipantCertifications: '', internshipOrExternship: false, - internshipDescription: undefined, + internshipOrExternshipDescription: '', minimumWage: undefined, - jobTypeFoodService: undefined, + jobType: undefined, jobCategory: undefined, alumniHiredByOrg: undefined, }; const [formState, setFormState] = React.useState(noState); const validateInputs = () => { - const { adultProgram, minimumWage, jobTypeFoodService } = formState; - if (!adultProgram || !minimumWage || !jobTypeFoodService) { - return false; - } + // Add validation logic here: + // ex: + // const { adultProgram, minimumWage, jobTypeFoodService } = formState; + // if (!adultProgram || !minimumWage || !jobTypeFoodService) { + // return false; + // } + return true; }; const handleSubmit = async () => { if (validateInputs()) { try { - const response = await postData('program.outcomes/', formState); + const formData = { + ...formState, + youthOutcomesMeasure: + formState.youthOutcomesMeasure?.join(', ') || '', + }; + + const response = await postData('program_outcomes/', formData); console.log('Program outcome submitted successfully:', response); // Handle success (e.g., show a success message, reset form, etc.) } catch (error) { @@ -375,16 +403,19 @@ export default function ProgramOutcome() { - setFormState({ ...formState, youthProgram: e.target.checked }) + setFormState({ + ...formState, + programDesignedForYouthAndAdults: e.target.checked, + }) } /> } label="Youth Program" /> - {formState.youthProgram && ( + {formState.programDesignedForYouthAndAdults && (
setFormState({ ...formState, - youthJobRetention3Months: Number(e.target.value), + youthJobRetentionThreeMonths: Number(e.target.value), }) } label="Youth Job Retention (3 Months)" @@ -468,7 +499,7 @@ export default function ProgramOutcome() { onChange={(e) => setFormState({ ...formState, - youthJobRetention6Months: Number(e.target.value), + youthJobRetentionSixMonths: Number(e.target.value), }) } label="Youth Job Retention (6 Months)" @@ -483,7 +514,7 @@ export default function ProgramOutcome() { onChange={(e) => setFormState({ ...formState, - youthJobRetention12Months: Number(e.target.value), + youthJobRetentionTwelveMonths: Number(e.target.value), }) } label="Youth Job Retention (12 Months)" @@ -498,7 +529,7 @@ export default function ProgramOutcome() { onChange={(e) => setFormState({ ...formState, - youthJobRetention2Years: Number(e.target.value), + youthJobRetentionTwentyFourMonths: Number(e.target.value), }) } label="Youth Job Retention (2 Years)" @@ -659,12 +690,12 @@ export default function ProgramOutcome() { { setFormState({ ...formState, - adultsEnrollmentStructure: e.target.value as + adultEnrollmentStructure: e.target.value as | 'Single Cohort' | 'Staggered' | undefined, @@ -959,11 +990,11 @@ export default function ProgramOutcome() { setFormState({ ...formState, - wrapAroundHousing: e.target.value as - | 'Partner agency' - | 'In-house' - | 'Not provided', + wrapAroundServicesHousing: e.target.value as + | 'You mostly facilitate access through partner agency' + | 'You mostly provide in-house' + | 'Your program does not provide or facilitate access', }) } > - Partner agency - In-house - Not provided + + Partner agency + + In-house + + Not provided + @@ -1430,20 +1469,27 @@ export default function ProgramOutcome() { Wraparound Lifeskills @@ -1452,20 +1498,24 @@ export default function ProgramOutcome() { Wraparound Case Management @@ -1474,20 +1524,24 @@ export default function ProgramOutcome() { Wraparound Job Search @@ -1496,20 +1550,24 @@ export default function ProgramOutcome() { Wrap Around Recovery Treatment @@ -1518,20 +1576,24 @@ export default function ProgramOutcome() { Wrap Around Mental Health Services @@ -1540,20 +1602,24 @@ export default function ProgramOutcome() { Wraparound Healthcare @@ -1562,20 +1628,24 @@ export default function ProgramOutcome() { Wraparound Childcare @@ -1584,31 +1654,35 @@ export default function ProgramOutcome() { Wraparound Transportation setFormState({ ...formState, - otherWrapAroundServices: e.target.value, + otherPleaseSpecifyOtherWrapAroundServices: e.target.value, }) } fullWidth @@ -1619,11 +1693,11 @@ export default function ProgramOutcome() { setFormState({ ...formState, - fundingPublic: Number(e.target.value), + fundingPercentFromPublicFunding: Number(e.target.value), }) } fullWidth @@ -1633,11 +1707,11 @@ export default function ProgramOutcome() { setFormState({ ...formState, - fundingPrivate: Number(e.target.value), + fundingPercentFromPrivateFunding: Number(e.target.value), }) } fullWidth @@ -1647,11 +1721,13 @@ export default function ProgramOutcome() { setFormState({ ...formState, - fundingSocialEnterprise: Number(e.target.value), + fundingPercentFromSocialEnterpriseOrGeneratedRevenue: Number( + e.target.value, + ), }) } fullWidth @@ -1663,11 +1739,11 @@ export default function ProgramOutcome() { SNAP E&T setFormState({ ...formState, - wioa: e.target.value as 'Yes' | 'No But' | 'No And' | undefined, + WIOA: e.target.value as 'Yes' | 'No But' | 'No And' | undefined, }) } > @@ -1738,11 +1814,11 @@ export default function ProgramOutcome() { setFormState({ ...formState, - internshipDescription: e.target.value, + internshipOrExternshipDescription: e.target.value, }) } fullWidth @@ -1771,11 +1847,11 @@ export default function ProgramOutcome() { Job Type in Food Service