Skip to content

Commit 776faf4

Browse files
authored
Merge pull request #3900 from Northeastern-Electric-Racing/#2398-add-weeks-to-duration-wp
#2398 sponsor notes field and added in weeks to wp duration
2 parents 7babaa8 + fef1f7e commit 776faf4

12 files changed

Lines changed: 89 additions & 19 deletions

File tree

src/backend/src/controllers/finance.controllers.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export default class FinanceController {
1414
taxExempt,
1515
sponsorContact,
1616
sponsorTasks,
17-
discountCode
17+
discountCode,
18+
sponsorNotes
1819
} = req.body;
1920

2021
const sponsor = await FinanceServices.createSponsor(
@@ -29,7 +30,8 @@ export default class FinanceController {
2930
sponsorContact,
3031
sponsorTasks,
3132
req.organization,
32-
discountCode
33+
discountCode,
34+
sponsorNotes
3335
);
3436
res.status(200).json(sponsor);
3537
} catch (error: unknown) {
@@ -328,7 +330,8 @@ export default class FinanceController {
328330
sponsorContact,
329331
taxExempt,
330332
sponsorTasks,
331-
discountCode
333+
discountCode,
334+
sponsorNotes
332335
} = req.body;
333336

334337
const updatedSponsor = await FinanceServices.editSponsor(
@@ -344,7 +347,8 @@ export default class FinanceController {
344347
sponsorContact,
345348
taxExempt,
346349
sponsorTasks,
347-
discountCode
350+
discountCode,
351+
sponsorNotes
348352
);
349353

350354
res.status(200).json(updatedSponsor);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterTable
2+
ALTER TABLE "Sponsor" ADD COLUMN "sponsorNotes" TEXT;

src/backend/src/prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,7 @@ model Sponsor {
795795
discountCode String?
796796
activeYears Int[]
797797
taxExempt Boolean
798+
sponsorNotes String?
798799
sponsorTasks Sponsor_Task[]
799800
800801
@@unique([name, organizationId], name: "uniqueSponsor")

src/backend/src/services/finance.services.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default class FinanceServices {
4848
* @param sponsorTierId The ID of the sponsor's tier.
4949
* @param taxExempt Boolean indicating if the sponsor is tax-exempt.
5050
* @param discountCode The discount code associated with the sponsor.
51+
* @param sponsorNotes Additional notes about the sponsor.
5152
* @param sponsorContact The contact information for the sponsor.
5253
* @param sponsorTasks An array of sponsor tasks associated with the sponsor.
5354
* @param organization The organization for which the sponsor is being created.
@@ -68,7 +69,8 @@ export default class FinanceServices {
6869
sponsorContact: string,
6970
sponsorTasks: CreateSponsorTask[],
7071
organization: Organization,
71-
discountCode?: string
72+
discountCode?: string,
73+
sponsorNotes?: string
7274
) {
7375
if (!(await userHasPermission(submitter.userId, organization.organizationId, isHead)))
7476
throw new AccessDeniedException('Only heads can create a sponsor');
@@ -94,6 +96,7 @@ export default class FinanceServices {
9496
sponsorTierId,
9597
taxExempt,
9698
discountCode,
99+
sponsorNotes,
97100
vendorContact: sponsorContact,
98101
sponsorTasks: {
99102
create: sponsorTasks.map((task) => ({
@@ -1102,6 +1105,7 @@ export default class FinanceServices {
11021105
* @param sponsorTierId The ID of the sponsor's tier.
11031106
* @param taxExempt Boolean indicating if the sponsor is tax-exempt.
11041107
* @param discountCode The discount code associated with the sponsor.
1108+
* @param sponsorNotes Additional notes about the sponsor.
11051109
* @param sponsorContact The contact information for the sponsor.
11061110
* @param sponsorTasks An array of sponsor tasks associated with the sponsor.
11071111
* @param organization The organization for which the sponsor is being edited.
@@ -1121,7 +1125,8 @@ export default class FinanceServices {
11211125
sponsorContact: string,
11221126
taxExempt: boolean,
11231127
sponsorTasks: CreateSponsorTask[],
1124-
discountCode?: string
1128+
discountCode?: string,
1129+
sponsorNotes?: string
11251130
): Promise<Sponsor> {
11261131
if (!(await userHasPermission(submitter.userId, organization.organizationId, isHead)))
11271132
throw new AccessDeniedException('Only heads can edit sponsors.');
@@ -1202,7 +1207,8 @@ export default class FinanceServices {
12021207
},
12031208
vendorContact: sponsorContact,
12041209
taxExempt,
1205-
discountCode
1210+
discountCode,
1211+
sponsorNotes
12061212
},
12071213
...getSponsorQueryArgs(organization.organizationId)
12081214
});

src/backend/src/transformers/finance.transformer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const sponsorTransformer = (sponsor: Prisma.SponsorGetPayload<SponsorQuer
77
return {
88
...sponsor,
99
sponsorContact: sponsor.vendorContact,
10+
sponsorNotes: sponsor.sponsorNotes ?? undefined,
1011
discountCode: sponsor.discountCode ?? undefined,
1112
sponsorTasks: sponsor.sponsorTasks.map(sponsorTaskTranformer)
1213
};

src/frontend/src/hooks/finance.hooks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export interface SponsorPayload {
166166
sponsorContact: string;
167167
sponsorTasks: CreateSponsorTask[];
168168
discountCode?: string;
169+
sponsorNotes?: string;
169170
}
170171

171172
interface EditSponsorPayload extends SponsorPayload {

src/frontend/src/pages/FinancePage/FinanceComponents/CreateSponsorPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const CreateSponsorPage = ({ showPage, handleClose }: CreateSponsorPageProps) =>
3232
sponsorTierId: '',
3333
sponsorContact: '',
3434
taxExempt: false,
35+
discountCode: '',
36+
sponsorNotes: '',
3537
sponsorTasks: []
3638
}
3739
});

src/frontend/src/pages/FinancePage/FinanceComponents/EditSponsorPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const EditSponsorPage = ({ showPage, handleClose, sponsor }: EditSponsorPageProp
4545
sponsorContact: sponsor.sponsorContact,
4646
taxExempt: sponsor.taxExempt,
4747
discountCode: sponsor.discountCode ?? undefined,
48+
sponsorNotes: sponsor.sponsorNotes ?? undefined,
4849
sponsorTasks: defaultSponsorTasks
4950
}
5051
});

src/frontend/src/pages/FinancePage/FinanceComponents/SponsorForm.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const sponsorSchema = yup.object().shape({
5454
sponsorContact: yup.string().required('Sponsor contact is required'),
5555
taxExempt: yup.boolean().required('Tax exempt is required'),
5656
discountCode: yup.string().trim().optional(),
57+
sponsorNotes: yup.string().trim().optional(),
5758
sponsorTasks: yup
5859
.array()
5960
.of(
@@ -296,6 +297,21 @@ export const SponsorForm: React.FC<SponsorFormProps> = ({ control, errors, defau
296297
<FormHelperText error> {errors.discountCode?.message}</FormHelperText>
297298
</FormControl>
298299
</Grid>
300+
<Grid item xs={12}>
301+
<FormControl fullWidth>
302+
<Typography variant="h5" color="#EF4345">
303+
Sponsor Notes:
304+
</Typography>
305+
<ReactHookTextField
306+
name="sponsorNotes"
307+
control={control}
308+
placeholder="Enter Additional Information"
309+
multiline
310+
rows={4}
311+
/>
312+
<FormHelperText error> {errors.sponsorNotes?.message}</FormHelperText>
313+
</FormControl>
314+
</Grid>
299315
<Grid item xs={12} sm={12}>
300316
<FormControl fullWidth>
301317
<Typography variant="h5" color="#EF4345" sx={{ mb: 1 }}>

src/frontend/src/pages/FinancePage/SponsorsTable.tsx

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
22
import { GridRenderCellParams } from '@mui/x-data-grid';
33
import type { MapRowResult } from '../../components/NERDataGrid';
44
import type { MouseEvent } from 'react';
5-
import { Box, IconButton, Checkbox } from '@mui/material';
5+
import { Box, IconButton, Checkbox, Tooltip } from '@mui/material';
66
import LoadingIndicator from '../../components/LoadingIndicator';
77
import { useEditSponsor, useGetAllSponsors } from '../../hooks/finance.hooks';
88
import ErrorPage from '../ErrorPage';
@@ -19,6 +19,7 @@ import SponsorTasksModal from './FinanceComponents/SponsorTasksModal';
1919
import SidePagePopup from './FinanceComponents/SidePagePopup';
2020
import NERDataGrid from '../../components/NERDataGrid';
2121
import { useCurrentUser } from '../../hooks/users.hooks';
22+
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
2223

2324
const SponsorsTable = () => {
2425
const { data: sponsors, isLoading: sponsorIsLoading, isError: sponsorIsError, error: sponsorError } = useGetAllSponsors();
@@ -50,11 +51,13 @@ const SponsorsTable = () => {
5051
};
5152

5253
const columns = [
53-
{ field: 'name', headerName: 'Sponsor', flex: 1 },
54+
{ field: 'name', headerName: 'Sponsor', flex: 1, minWidth: 50 },
5455
{
5556
field: 'activeStatus',
5657
headerName: 'Active?',
57-
width: 160,
58+
flex: 1,
59+
minWidth: 50,
60+
maxWidth: 100,
5861
renderCell: (p: GridRenderCellParams<boolean, MapRowResult<Sponsor>>) => (
5962
<Checkbox
6063
disabled={!canEditSponsors}
@@ -69,33 +72,38 @@ const SponsorsTable = () => {
6972
/>
7073
)
7174
},
72-
{ field: 'sponsorContact', headerName: 'Contact', flex: 1 },
75+
{ field: 'sponsorContact', headerName: 'Contact', flex: 1, minWidth: 50 },
7376
{
7477
field: 'tier',
7578
headerName: 'Sponsor Tier',
76-
width: 140,
79+
flex: 1,
80+
minWidth: 100,
7781
renderCell: (params: GridRenderCellParams<any, MapRowResult<Sponsor>>) => (
7882
<SponsorTierPill tier={(params.row as MapRowResult<Sponsor>).raw!.tier} />
7983
)
8084
},
8185
{
8286
field: 'sponsorValue',
8387
headerName: 'Sponsor Value',
84-
width: 160,
88+
flex: 1,
89+
minWidth: 50,
8590
renderCell: (p: GridRenderCellParams<number, MapRowResult<Sponsor>>) => `$${p.value}`
8691
},
8792
{
8893
field: 'joinDate',
8994
headerName: 'Sponsor Join Date',
90-
width: 180,
95+
flex: 1,
96+
minWidth: 100,
9197
renderCell: (p: GridRenderCellParams<string | null, MapRowResult<Sponsor>>) =>
9298
datePipe(new Date(String(p.value ?? '')))
9399
},
94-
{ field: 'discountCode', headerName: 'Discount', flex: 1 },
100+
{ field: 'discountCode', headerName: 'Discount', flex: 1, minWidth: 50 },
95101
{
96102
field: 'taxExempt',
97103
headerName: 'Tax Exempt?',
98-
width: 120,
104+
flex: 1,
105+
minWidth: 50,
106+
maxWidth: 100,
99107
renderCell: (p: GridRenderCellParams<boolean, MapRowResult<Sponsor>>) => {
100108
return (
101109
<Checkbox
@@ -112,10 +120,35 @@ const SponsorsTable = () => {
112120
);
113121
}
114122
},
123+
{
124+
field: 'sponsorNotes',
125+
headerName: 'Notes',
126+
flex: 1,
127+
minWidth: 40,
128+
maxWidth: 80,
129+
sortable: false,
130+
filterable: false,
131+
renderCell: (p: GridRenderCellParams<string | null, MapRowResult<Sponsor>>) => {
132+
const notes = (p.row as MapRowResult<Sponsor>).raw?.sponsorNotes;
133+
134+
if (!notes || notes.trim() === '') {
135+
return null;
136+
}
137+
138+
return (
139+
<Tooltip title={notes} arrow placement="left">
140+
<IconButton size="small" sx={{ p: 0.5, color: 'white' }}>
141+
<InfoOutlinedIcon fontSize="small" />
142+
</IconButton>
143+
</Tooltip>
144+
);
145+
}
146+
},
115147
{
116148
field: 'tasks',
117149
headerName: 'Sponsor Tasks',
118-
width: 180,
150+
flex: 1,
151+
minWidth: 100,
119152
sortable: false,
120153
filterable: false,
121154
renderCell: (params: GridRenderCellParams<any, MapRowResult<Sponsor>>) => {
@@ -147,7 +180,9 @@ const SponsorsTable = () => {
147180
{
148181
field: 'actions',
149182
headerName: 'Delete',
150-
width: 100,
183+
flex: 1,
184+
minWidth: 50,
185+
maxWidth: 80,
151186
sortable: false,
152187
filterable: false,
153188
renderCell: (params: GridRenderCellParams<any, MapRowResult<Sponsor>>) => {

0 commit comments

Comments
 (0)