Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions apps/backend/src/emails/emailTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export const EMAIL_REDIRECT_URL = 'http://localhost:4200';
export const SSF_PARTNER_EMAIL = 'example@gmail.com';

export const emailTemplates = {
pantryFmApplicationApproved: (params: { name: string }): EmailTemplate => ({
pantryFmApplicationApproved: (params: {
name: string;
applicantType: 'company' | 'pantry';
}): EmailTemplate => ({
subject: 'Your Securing Safe Food Account Has Been Created',
bodyHTML: `
<p>Hi ${params.name},</p>
Expand All @@ -18,7 +21,11 @@ export const emailTemplates = {
</p>
<p>
You can <a href="${EMAIL_REDIRECT_URL}/login">log in</a> using the credentials created during registration
to begin submitting requests, managing donations, and coordinating with our network.
${
params.applicantType === 'company'
? 'to begin managing donations and coordinating with our network'
: 'to begin submitting requests, and coordinating with our network'
}.
</p>
<p>
If you have any questions as you get started or need help navigating the
Expand Down Expand Up @@ -66,14 +73,17 @@ export const emailTemplates = {

pantryFmApplicationSubmittedToUser: (params: {
name: string;
applicantType: 'company' | 'pantry';
}): EmailTemplate => ({
subject: 'Your SSF Application Has Been Submitted',
bodyHTML: `
<p>Hi ${params.name},</p>
<p>
Thank you for your interest in partnering with Securing Safe Food!
Your application has been successfully submitted and is currently under review.
If we determine that your food pantry aligns with our mission and available resources, our team will reach out.
Thank you for your interest in partnering with Securing Safe Food!
Your application has been successfully submitted and is currently under review.
If we determine that your ${
params.applicantType === 'company' ? 'company' : 'food pantry'
} aligns with our mission and available resources, our team will reach out.
</p>
<p>
While we are unable to respond to every application, submissions are reviewed on a rolling basis.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ describe('FoodManufacturersService', () => {
const id = manufacturer.foodManufacturerId;
const message = emailTemplates.pantryFmApplicationApproved({
name: manufacturer.foodManufacturerRepresentative.firstName,
applicantType: 'company',
});

await service.approve(id);
Expand Down Expand Up @@ -380,6 +381,7 @@ describe('FoodManufacturersService', () => {

const userMessage = emailTemplates.pantryFmApplicationSubmittedToUser({
name: dto.contactFirstName,
applicantType: 'company',
});
const adminMessage = emailTemplates.pantryFmApplicationSubmittedToAdmin();

Expand Down
2 changes: 2 additions & 0 deletions apps/backend/src/foodManufacturers/manufacturers.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ export class FoodManufacturersService {
const manufacturerMessage =
emailTemplates.pantryFmApplicationSubmittedToUser({
name: foodManufacturerContact.firstName,
applicantType: 'company',
});

await this.emailsService.sendEmails({
Expand Down Expand Up @@ -432,6 +433,7 @@ export class FoodManufacturersService {
try {
const message = emailTemplates.pantryFmApplicationApproved({
name: newFoodManufacturer.firstName,
applicantType: 'company',
});

await this.emailsService.sendEmails({
Expand Down
2 changes: 2 additions & 0 deletions apps/backend/src/pantries/pantries.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ describe('PantriesService', () => {
const pantry = await service.findOne(5);
const message = emailTemplates.pantryFmApplicationApproved({
name: pantry.pantryUser.firstName,
applicantType: 'pantry',
});

await service.approve(5);
Expand Down Expand Up @@ -387,6 +388,7 @@ describe('PantriesService', () => {

const userMessage = emailTemplates.pantryFmApplicationSubmittedToUser({
name: dto.contactFirstName,
applicantType: 'pantry',
});
const adminMessage = emailTemplates.pantryFmApplicationSubmittedToAdmin();

Expand Down
2 changes: 2 additions & 0 deletions apps/backend/src/pantries/pantries.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ export class PantriesService {
try {
const pantryMessage = emailTemplates.pantryFmApplicationSubmittedToUser({
name: pantryContact.firstName,
applicantType: 'pantry',
});

await this.emailsService.sendEmails({
Expand Down Expand Up @@ -516,6 +517,7 @@ export class PantriesService {
try {
const message = emailTemplates.pantryFmApplicationApproved({
name: newPantryUser.firstName,
applicantType: 'pantry',
});

await this.emailsService.sendEmails({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const DonationDetailsModal: React.FC<DonationDetailsModalProps> = ({
<Dialog.Title fontSize="lg" fontWeight="600">
Donation #{donationId} Stock
</Dialog.Title>
{donation.status === DonationStatus.AVAILABLE && (
{donation.status === DonationStatus.AVAILABLE && !isEditing && (
<>
<EditButton onClick={() => setIsEditing(true)}></EditButton>
<DeleteButton onClick={onDelete}></DeleteButton>
Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/src/components/forms/resubmitDonationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,11 @@ const ResubmitDonationModal: React.FC<ResubmitDonationModalProps> = ({
mx={3}
/>
<Text
minW={5}
w="48px"
py={2}
textStyle="p2"
color="neutral.800"
textAlign="center"
>
{item.quantity}
</Text>
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/containers/foodManufacturerDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const FoodManufacturerDashboard: React.FC = () => {
<PageEmptyState
entity="donations"
primaryButtonText="Log New Donation"
primaryButtonLink={ROUTES.FM_DONATION_MANAGEMENT}
primaryButtonLink={`${ROUTES.FM_DONATION_MANAGEMENT}?logDonation=true`}
secondaryButtonText="View Donations"
secondaryButtonLink={ROUTES.FM_DONATION_MANAGEMENT}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ const FoodManufacturerDonationManagement: React.FC = () => {
const [isResubmitOpen, setIsResubmitOpen] = useState(false);
const [loading, setLoading] = useState(true);
const [alertState, setAlertMessage] = useAlert();
const [isLogDonationOpen, setIsLogDonationOpen] = useState(false);
const [isLogDonationOpen, setIsLogDonationOpen] = useState(
searchParams.get('logDonation') === 'true',
);
const [manufacturerId, setManufacturerId] = useState<number | null>(null);
const [selectedActionDonation, setSelectedActionDonation] =
useState<DonationDetails | null>(null);
Expand Down Expand Up @@ -260,7 +262,12 @@ const FoodManufacturerDonationManagement: React.FC = () => {
foodManufacturerId={mostRecentDonationFmId ?? manufacturerId}
onDonationSuccess={() => fetchDonations()}
isOpen={isLogDonationOpen}
onClose={() => setIsLogDonationOpen(false)}
onClose={() => {
setIsLogDonationOpen(false);
if (searchParams.get('logDonation')) {
navigate(ROUTES.FM_DONATION_MANAGEMENT, { replace: true });
}
}}
/>
)}

Expand Down
Loading