Skip to content

Commit

Permalink
Merge branch 'main' into sandino/thinkcell
Browse files Browse the repository at this point in the history
  • Loading branch information
ssandino authored May 1, 2024
2 parents cd7ccf5 + 5f3344f commit 41c2e7e
Show file tree
Hide file tree
Showing 43 changed files with 2,372 additions and 140 deletions.
6 changes: 5 additions & 1 deletion admin/src/collections/Expenses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ export const expensesCollection = buildAuditedCollection<Expense>({
dataType: 'string',
name: 'Type',
enumValues: [
{ id: ExpenseType.AccountFees, label: 'Account fees' },
{ id: ExpenseType.Administrative, label: 'Administrative' },
{ id: ExpenseType.DeliveryFees, label: 'Delivery fees' },
{ id: ExpenseType.DonationFees, label: 'Donation fees' },
{ id: ExpenseType.ExchangeRateFluctuation, label: 'Exchange rate fluctuation' },
{ id: ExpenseType.ExchangeRateLoss, label: 'Exchange rate fluctuation' },
{ id: ExpenseType.FundraisingAdvertising, label: 'Fundraising and advertising' },
{ id: ExpenseType.Staff, label: 'Staff' },
],
validation: { required: true },
},
Expand Down
13 changes: 10 additions & 3 deletions functions/src/cron/first-payout-email/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { FirestoreAdmin } from '@socialincome/shared/src/firebase/admin/FirestoreAdmin';
import { toFirebaseAdminTimestamp } from '@socialincome/shared/src/firebase/admin/utils';
import { Contribution, CONTRIBUTION_FIRESTORE_PATH } from '@socialincome/shared/src/types/contribution';
import { LanguageCode } from '@socialincome/shared/src/types/language';
import { User, USER_FIRESTORE_PATH } from '@socialincome/shared/src/types/user';
import { toDateTime } from '@socialincome/shared/src/utils/date';
import { onSchedule } from 'firebase-functions/v2/scheduler';
import { DateTime } from 'luxon';
import { FirstPayoutEmailTemplateData, SendgridMailClient } from '../../../../shared/src/sendgrid/SendgridMailClient';
Expand All @@ -13,6 +15,7 @@ export const getFirstPayoutEmailReceivers = async (
): Promise<
{
email: string;
language: LanguageCode;
templateData: FirstPayoutEmailTemplateData;
}[]
> => {
Expand All @@ -39,11 +42,15 @@ export const getFirstPayoutEmailReceivers = async (
return [
{
email: user.email,
language: user.language || 'en',
templateData: {
email: user.email,
first_name: user.personal?.name,
donation_amount: contribution.amount,
currency: contribution.currency,
n_days_ago: Math.abs(Math.round(toDateTime(contribution.created).diffNow('days').days)),
donation_amount_sm: Math.max(5, Math.floor(contribution.amount / 50) * 5),
donation_amount_md: Math.max(10, Math.ceil(contribution.amount / 40) * 5),
one_time_donation: contribution.monthly_interval === 0,
},
},
];
Expand All @@ -66,8 +73,8 @@ export default onSchedule('0 0 16 * *', async () => {

await Promise.all(
firstPayoutEmailReceivers.map(async (entry) => {
const { email, templateData } = entry;
await sendgridClient.sendFirstPayoutEmail(email, templateData);
const { email, language, templateData } = entry;
await sendgridClient.sendFirstPayoutEmail(email, language, templateData);
}),
);
});
1 change: 1 addition & 0 deletions recipients_selection/draws/1-reachoutsalone-2024-04-26.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"time":1714132273347,"round":7109637,"randomness":"7aa4f51107fc324b31dad8c8f8cff6ce59ced0d5484eed663e3daca04ad643b2","totalCount":354,"winners":["3afdea18b9d626e8284d355dfd1f673c14348c3050d7f616fdf248095067d328"]}
354 changes: 354 additions & 0 deletions recipients_selection/lists/1-reachoutsalone-2024-04-26.txt

Large diffs are not rendered by default.

567 changes: 567 additions & 0 deletions recipients_selection/lists/10-aurora-2023-10-31.txt

Large diffs are not rendered by default.

365 changes: 365 additions & 0 deletions recipients_selection/lists/11-reachoutsalone-2024-04-22.txt

Large diffs are not rendered by default.

557 changes: 557 additions & 0 deletions recipients_selection/lists/4-aurora-2023-11-08.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion seed/auth_export/accounts.json

Large diffs are not rendered by default.

Binary file not shown.
Binary file modified seed/firestore_export/all_namespaces/all_kinds/output-0
Binary file not shown.
Binary file modified seed/firestore_export/firestore_export.overall_export_metadata
Binary file not shown.
6 changes: 5 additions & 1 deletion shared/locales/de/website-home2.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
"title-5": "Ongoing Support",
"text-5": "Our recipients receive continuous support from our local partners throughout and even after the program, maximizing the overall impact. Specifically, the third year of the program is focused on facilitating a seamless transition as they move on from the program."
},
"section-3": {},
"section-3": {
"title-faded": "Meine Wirkung",
"title": "Wie hoch ist Ihr monatliches Einkommen?",
"subtitle": "Warum ist das wichtig?"
},
"section-4": {
"title-1": [
{ "text": "What would change if you gave " },
Expand Down
2 changes: 1 addition & 1 deletion shared/locales/de/website-reporting.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
{
"title": "Bestätigung Steuerbefreiung",
"href": "https://drive.google.com/file/d/1-YAtyYjUL_LqMKyG0IN41Cohr58EAy7S/view",
"language": "Deutsch"
"language": "Englisch"
}
]
}
67 changes: 61 additions & 6 deletions shared/locales/en/website-home2.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@
"title-5": "Ongoing Support",
"text-5": "Our recipients receive continuous support from our local partners throughout and even after the program, maximizing the overall impact. Specifically, the third year of the program is focused on facilitating a seamless transition as they move on from the program."
},
"section-3": {},
"section-3": {
"title-faded": "My impact",
"title": "What's your monthly income?",
"subtitle": "Why is this important?"
},
"section-4": {
"title-1": [
{ "text": "What would change if you gave " },
{ "text": "away 1% of your income every month?", "color": "accent" }
{ "text": "away 1% of your income ", "color": "accent" },
{ "text": "every month?" }
],
"cta": "Watch video and find out"
"cta": "Watch video and find out"
},
"section-5": {
"title-1": [{ "text": "Change from human to human. " }, { "text": "From mobile to mobile.", "color": "accent" }],
Expand Down Expand Up @@ -124,15 +129,49 @@
}
]
},
"section-x": {
"section-8": {
"cards": [
{
"quote": [
{
"text": "«Wir müssen uns ernsthaft damit befassen "
},
{
"text": "ein klug konzipiertes bedingungsloses Grundeinkommen ",
"color": "accent"
},
{
"text": "zu implementieren. So können uns Krisen zwar treffen, aber ohne zerstörerische Kraft zu entfalten.»"
}
],
"author": "Vereinte Nationen"
},
{
"quote": [
{
"text": "«Wir müssen uns ernsthaft damit befassen, "
},
{
"text": "ein klug konzipiertes bedingungsloses Grundeinkommen ",
"color": "accent"
},
{
"text": "zu implementieren. So können uns Krisen zwar treffen, aber ohne zerstörerische Kraft zu entfalten.»"
}
],
"author": "Vereinte Nationen"
}
]
},
"section-9": {
"title-1": [
{ "text": "Unique Recipients Selection Process for " },
{ "text": "Fair Selection.", "color": "accent" }
],
"text-1.1": "Identifying those in need: Through collaboration with local NGOs in Sierra Leone, we target individuals living in poverty who can benefit from a three-year predictable income, empowering them to invest in their future.",
"text-1.2": "Selecting randomly: Our randomized selection process is transparent and publicly verifiable, eliminating human biases and favoritism. This ensures fairness and equal chances for all individuals in poverty to benefit."
},
"section-8": {
"section-x": {
"portraits": [
{
"name": "Vanja",
Expand All @@ -150,10 +189,26 @@
"author-5": "Claudia, Switzerland"
},
"section-10": {
"title-1": [{ "text": "Contribute to the United Nations’ " }, { "text": "United Nations", "color": "primary" }],
"title-1": [{ "text": "Contribute to the " }, { "text": "United Nations", "color": "primary" }, { "text": "" }],
"sdg-1-title": "End poverty in all its forms, everywhere.",
"sdg-1": "SDG #1",
"sdg-10-title": "Reduce inequality within and \namong countries.",
"sdg-10": "SDG #10"
},
"section-11": {
"title": "Journal",
"card-1-title": "Waking up",
"card-1-author": "Aurélie Schmiedlin",
"card-1-description": "The other night I woke up with the sensation that we were hacked. Luckily this was just a dream. It may have been related to our participation in Finclusion Week, which is a big deal in the ...",
"card-2-title": "The other night I woke up",
"card-2-author": "Aurélie Schmiedlin",
"card-2-description": "The other night I woke up with the sensation that we were hacked. Luckily this was just a dream. It may have been related to our participation in Finclusion Week, which is a big deal in the ...",
"card-3-title": "The other night I woke up",
"card-3-author": "Aurélie Schmiedlin",
"card-3-description": "The other night I woke up with the sensation that we were hacked. Luckily this was just a dream. It may have been related to our participation in Finclusion Week, which is a big deal in the ...",
"card-4-title": "The other night I woke up",
"card-4-author": "Aurélie Schmiedlin",
"card-4-description": "The other night I woke up with the sensation that we were hacked. Luckily this was just a dream. It may have been related to our participation in Finclusion Week, which is a big deal in the ...",
"all-articles": "Alle Artikel ansehen ›"
}
}
2 changes: 1 addition & 1 deletion shared/locales/en/website-reporting.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
{
"title": "Confirmation Tax Exemption",
"href": "https://drive.google.com/file/d/1-YAtyYjUL_LqMKyG0IN41Cohr58EAy7S/view",
"language": "German"
"language": "English"
}
]
}
17 changes: 14 additions & 3 deletions shared/src/sendgrid/SendgridMailClient.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { MailService } from '@sendgrid/mail';
import { Currency } from '../types/currency';
import { LanguageCode } from '../types/language';

export type FirstPayoutEmailTemplateData = {
first_name?: string;
donation_amount: number;
currency: Currency;
n_days_ago: number;
donation_amount_sm: number;
donation_amount_md: number;
one_time_donation: boolean;
};

export class SendgridMailClient extends MailService {
Expand All @@ -13,11 +18,17 @@ export class SendgridMailClient extends MailService {
this.setApiKey(apiKey);
}

sendFirstPayoutEmail = async (email: string, data: FirstPayoutEmailTemplateData) => {
sendFirstPayoutEmail = async (email: string, language: LanguageCode, data: FirstPayoutEmailTemplateData) => {
let templateId = '';
if (language === 'de') {
templateId = 'd-3146eb9ee2054b28b22376113eb96ca9';
} else {
templateId = 'd-4e616d721b0240509f468c1e5ff22e6d';
}
await this.send({
to: email,
from: '[email protected]',
templateId: 'd-4e616d721b0240509f468c1e5ff22e6d',
from: { name: 'Social Income', email: '[email protected]' },
templateId,
dynamicTemplateData: data,
});
};
Expand Down
8 changes: 6 additions & 2 deletions shared/src/types/expense.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
export const EXPENSES_FIRESTORE_PATH = 'expenses';

export enum ExpenseType {
DonationFees = 'donation_fees',
AccountFees = 'account_fees',
Administrative = 'Administrative',
DeliveryFees = 'delivery_fees',
ExchangeRateFluctuation = 'exchange_rate_fluctuation',
DonationFees = 'donation_fees',
ExchangeRateLoss = 'exchange_rate_loss',
FundraisingAdvertising = 'FundraisingAdvertising',
Staff = 'staff',
}

export type Expense = {
Expand Down
12 changes: 9 additions & 3 deletions shared/src/utils/stats/ExpensesStatsCalculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ type ExpenseStatsEntry = Expense & {
amount: number;
};

export type ExpenseStats = {
totalExpensesByYear: { [year: string]: number };
totalExpensesByType: { [type: string]: number };
totalExpensesByYearAndType: { [year: string]: { [type in ExpenseType]: number } };
};

export class ExpensesStatsCalculator {
private expenses: _.Collection<ExpenseStatsEntry>;

Expand Down Expand Up @@ -46,10 +52,10 @@ export class ExpensesStatsCalculator {
.reduce((a, b) => ({ ...a, ...b }), {});
}

public allStats() {
public allStats(): ExpenseStats {
return {
totalExpensesByYear: this.totalExpensesBy('year'),
totalExpensesByType: this.totalExpensesBy('type'),
totalExpensesByYear: this.totalExpensesBy('year') as { [year: string]: number },
totalExpensesByType: this.totalExpensesBy('type') as { [type in ExpenseType]: number },
totalExpensesByYearAndType: this.totalExpensesByYearAndType(),
};
}
Expand Down
41 changes: 38 additions & 3 deletions ui/src/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
--card-muted: hsl(222, 100%, 99%);

--primary: hsl(48, 100%, 49%);
--primary-muted: hsl(48, 100%, 57%);
--primary-muted: hsl(48, 100%, 85%);
--primary-foreground: hsl(48, 100%, 0%);
--primary-foreground-muted: hsl(48, 100%, 30%);

Expand All @@ -82,8 +82,34 @@

.theme-v2 {
--background: #f9f8f3;
--foreground: #2a63a4;
--foreground-dark: #01579b;
--foreground: #3373bb;
--foreground-dark: #2a63a4;
}

.theme-blue-v2 {
--background: hsl(212, 57%, 47%);
--foreground: hsl(50, 33%, 96%);

--muted: hsl(212, 59%, 75%);
--muted-foreground: hsl(50, 33%, 99%);

--card: hsl(212, 57%, 47%);
--card-muted: hsl(212, 59%, 75%);
--card-foreground: hsl(50, 33%, 96%);
--card-foreground-muted: hsl(50, 33%, 99%);
}

.theme-dark-blue-v2 {
--background: hsl(212, 59%, 40%);
--foreground: hsl(50, 33%, 96%);

--muted: hsl(212, 59%, 75%);
--muted-foreground: hsl(50, 33%, 99%);

--card: hsl(212, 59%, 40%);
--card-muted: hsl(212, 59%, 75%);
--card-foreground: hsl(50, 33%, 96%);
--card-foreground-muted: hsl(50, 33%, 99%);
}
}

Expand All @@ -93,7 +119,16 @@
.theme-dark-blue {
@apply bg-background text-foreground;
}

.theme-v2 {
@apply bg-background text-foreground;
}

.theme-blue-v2 {
@apply bg-background text-foreground;
}

.theme-dark-blue-v2 {
@apply bg-background text-foreground;
}
}
2 changes: 2 additions & 0 deletions ui/src/interfaces/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const COLORS = [
'popover-foreground',
'card',
'card-foreground',
'bg-primary',
'bg-red-50',
'bg-yellow-50',
'bg-green-50',
Expand Down Expand Up @@ -53,6 +54,7 @@ export type FontColor = Extract<

export type BackgroundColor = Extract<
Color,
| 'bg-primary'
| 'bg-red-50'
| 'bg-yellow-50'
| 'bg-green-50'
Expand Down
Binary file added website/public/assets/sdg-town.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 41c2e7e

Please sign in to comment.