Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
andlrutt committed Oct 22, 2024
2 parents 8cc1172 + 53bf42a commit 33c8cac
Show file tree
Hide file tree
Showing 28 changed files with 262 additions and 177 deletions.
51 changes: 35 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"mongoose": "^7.4.5",
"next": "13.4.19",
"next-auth": "^4.24.7",
"nodemailer": "^6.9.15",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-google-button": "^0.7.2",
Expand All @@ -34,6 +35,7 @@
"@testing-library/react": "^14.0.0",
"@types/jest": "^29.5.4",
"@types/node": "20.5.6",
"@types/nodemailer": "^6.4.16",
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7",
"@typescript-eslint/eslint-plugin": "^6.4.1",
Expand Down
17 changes: 17 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/app/api/donors/[donorId]/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DonorResponse } from '@/types/persons';
import { DonorResponse } from '@/types/donors';
import { NextResponse, NextRequest } from 'next/server';
import { getDonorById, updateDonor } from '../../../../server/actions/donors';

Expand All @@ -19,7 +19,7 @@ export async function GET(
return NextResponse.json(result, { status: 200 });
} catch (error) {
// if the donor is not found, return a 500 error
return NextResponse.json({ error: 'Donor not found' }, { status: 500 });
return NextResponse.json({ error: 'Donor not found' }, { status: 404 });
}
}

Expand Down Expand Up @@ -52,7 +52,7 @@ export async function PUT(
return NextResponse.json(updatedDonor, { status: 200 });
} catch (error) {
// Handle any errors during parsing or updating
const message = error instanceof Error ? error.message : 'Unknowm errpr';
const message = error instanceof Error ? error.message : 'Unknown error';
return NextResponse.json(
{ error: 'Failed to update donor information', details: message },
{ status: 500 }
Expand Down
20 changes: 8 additions & 12 deletions src/app/api/donors/route.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAllDonors, createDonors } from '@/server/actions/donors';
import { DonorResponse, zCreateDonorRequest } from '@/types/persons';
import { DonorResponse, zCreateDonorRequest } from '@/types/donors';

export async function GET(request: NextRequest) {
if (request.method == 'GET') {
try {
const response: DonorResponse[] = await getAllDonors(); // Call getDonors function
return NextResponse.json(response, { status: 200 }); // Return result with status 200 on success
} catch (error) {
console.error(error); // Log the error for debugging
return NextResponse.json('Unknown error', { status: 500 }); // Return status 500 for unknown errors
}
export async function GET() {
try {
const response: DonorResponse[] = await getAllDonors(); // Call getDonors function
return NextResponse.json(response, { status: 200 }); // Return result with status 200 on success
} catch (error) {
console.error(error); // Log the error for debugging
return NextResponse.json('Unknown error', { status: 500 }); // Return status 500 for unknown errors
}
}


export async function POST(request: NextRequest) {
try {
const requestBody = await request.json();
Expand All @@ -36,6 +33,5 @@ export async function POST(request: NextRequest) {
// create a response for any unknown errors
console.log(error);
return NextResponse.json({ message: 'Unknown Error' }, { status: 500 });

}
}
1 change: 0 additions & 1 deletion src/app/api/items/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { NextRequest, NextResponse } from 'next/server';
import { createItem, getAllItems } from '@/server/actions/items';
import { zCreateItemRequest } from '@/types/items';
// import { CreateItem } from '@/server/actions/items';

export async function POST(request: NextRequest) {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/app/donors/[donorId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getDonorById } from '@/server/actions/donors';
import { DonorResponse } from '@/types/persons';
import { DonorResponse } from '@/types/donors';
import DonorIdView from '@/views/donorIdView';

export default async function DonorEditPage({
Expand Down
2 changes: 1 addition & 1 deletion src/app/donors/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getAllDonations } from '@/server/actions/donations';
import { getAllDonors } from '@/server/actions/donors';
import { DonationResponse } from '@/types/donation';
import { DonorResponse } from '@/types/persons';
import { DonorResponse } from '@/types/donors';
import DonorView from '@/views/donorView';

export default async function DonorPage() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/donation-form/AutofillDonorEmail.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DonorFormData } from '@/types/forms/donor';
import { DonorResponse } from '@/types/persons';
import { DonorResponse } from '@/types/donors';
import { Autocomplete, TextField } from '@mui/material';
import { useState } from 'react';

Expand Down
39 changes: 20 additions & 19 deletions src/components/donationItemForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function DonationItemForm({

return (
<>
<Grid item xs={7}>
<Grid item xs={12} sm={8}>
<AutofillItem
ItemOptions={itemOptions}
onItemSelect={handleItemSelect}
Expand All @@ -90,18 +90,7 @@ export default function DonationItemForm({
// helperText={validationErrors?.donatedItemName}
/>
</Grid>
<Grid item xs={4}>
<AutofillCategory
ItemOptions={itemOptions}
onCategorySelect={handleCategorySelect}
name={donationItemData.name}
value={donationItemData.category}
disabled={disabled}
// error={!!validationErrors?.category}
// helperText={validationErrors?.category}
/>
</Grid>
<Grid item xs={3} sm={4}>
<Grid item xs={12} sm={4}>
<TextField
fullWidth
id="outlined-required"
Expand All @@ -119,7 +108,7 @@ export default function DonationItemForm({
// helperText={validationErrors?.quantity}
/>
</Grid>
<Grid item xs={9} sm={8}>
<Grid item xs={12} sm={8}>
<TextField
fullWidth
id="outlined-required"
Expand All @@ -137,15 +126,26 @@ export default function DonationItemForm({
// helperText={validationErrors?.quantity}
/>
</Grid>
<Grid item xs={12} sm={4}>
<AutofillCategory
ItemOptions={itemOptions}
onCategorySelect={handleCategorySelect}
name={donationItemData.name}
value={donationItemData.category}
disabled={disabled}
// error={!!validationErrors?.category}
// helperText={validationErrors?.category}
/>
</Grid>
<Grid item xs={12} sm={4}>
<FormControl fullWidth disabled={disabled}>
<InputLabel>New or Used</InputLabel>
<InputLabel>New or Used?</InputLabel>
<Select
value={donationItemData.newOrUsed ?? ''}
onChange={(e) => {
onChange({ ...donationItemData, newOrUsed: e.target.value });
}}
label="New or Used"
label="New or Used?"
id="new-or-used"
// error={!!validationErrors?.newOrUsed}
>
Expand All @@ -161,7 +161,7 @@ export default function DonationItemForm({
disabled={donationItemData.newOrUsed !== 'Used' || disabled} // Disable if new
>
<InputLabel id="high-or-low-value-label">
High or Low Value
High or Low Value?
</InputLabel>
<Select
labelId="high-or-low-value-label"
Expand All @@ -172,7 +172,7 @@ export default function DonationItemForm({
highOrLow: e.target.value,
});
}}
label="High or Low Value"
label="High or Low Value?"
id="high-or-low-value"
// error={!!validationErrors?.highOrLow}
>
Expand All @@ -185,7 +185,7 @@ export default function DonationItemForm({
setHighOrLow(e.target.value);
}}*/}
</Grid>
<Grid item xs={12} sm={4}>
<Grid item xs={12} sm={3} md={3.5}>
<TextField
id="price"
label="Price"
Expand All @@ -207,6 +207,7 @@ export default function DonationItemForm({
startAdornment: <InputAdornment position="start">$</InputAdornment>,
}}
disabled={donationItemData.newOrUsed !== 'New' || disabled} // Disable if used
fullWidth
// error={!!validationErrors?.price}
// helperText={validationErrors?.price}
/>
Expand Down
6 changes: 3 additions & 3 deletions src/components/donorForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function DonorForm(props: donorProps) {
}}
/>
</Grid>
<Grid item xs={12} sm={5}>
<Grid item xs={12} sm={4}>
<TextField
fullWidth
id="outlined-required"
Expand All @@ -75,7 +75,7 @@ export default function DonorForm(props: donorProps) {
}}
/>
</Grid>
<Grid item xs={12} sm={3}>
<Grid item xs={12} sm={4}>
<TextField
fullWidth
id="outlined-required"
Expand All @@ -87,7 +87,7 @@ export default function DonorForm(props: donorProps) {
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
props.onChange({
...props.donorData,
zip: Number(e.target.value),
zip: e.target.value,
});
}}
/>
Expand Down
Loading

0 comments on commit 33c8cac

Please sign in to comment.