Skip to content

Commit

Permalink
Merge pull request #226 from uwblueprint/release/v0.0.3
Browse files Browse the repository at this point in the history
release/v0.0.3
  • Loading branch information
MatoPlus authored Jan 4, 2022
2 parents 08b5482 + dd4850c commit cf58cad
Show file tree
Hide file tree
Showing 60 changed files with 697 additions and 525 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ jobs:
branch: $GITHUB_BASE_REF
regex: "terraform/*"

- name: Setup node env
uses: actions/setup-node@v2.1.2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

Expand Down Expand Up @@ -106,6 +106,18 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
cache: 'pip'
cache-dependency-path: '**/requirements.txt'

- name: Install Lambda dependencies
run: |
cd ../modules/lambda/files/cronMailing
pip install -r requirements.txt -t .
- name: Hashicorp Terraform Setup (wraps stdout for plan)
uses: hashicorp/setup-terraform@v1
Expand Down Expand Up @@ -172,7 +184,7 @@ jobs:
body: output
})
- name: Terraform plan status
- name: Terraform Plan error
if: steps.plan.outcome == 'failure'
run: |
echo Check terraform plan
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/ci-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
exit 1
fi
- name: Setup node env
uses: actions/setup-node@v2.1.2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

Expand Down Expand Up @@ -76,6 +76,18 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
cache: 'pip'
cache-dependency-path: '**/requirements.txt'

- name: Install Lambda dependencies
run: |
cd ../modules/lambda/files/cronMailing
pip install -r requirements.txt -t .
- name: Hashicorp Terraform Setup (wraps stdout for plan)
uses: hashicorp/setup-terraform@v1

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ yarn-error.log
*.zip
**/cronMailing/*
!**/cronMailing/*.py
!**/cronMailing/requirements.txt
47 changes: 40 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Developers: Jason Huang, Soha Khan, Cindy Wang, Brandon Wong, Victor Yun, Mahad
```bash
.
├── .github
│ ├── workflows/ci.yml # Github workflow
│ ├── workflows # Github workflows
│ └── pull_request_template.md # PR template
├── pages # Pages
Expand All @@ -57,7 +57,11 @@ Developers: Jason Huang, Soha Khan, Cindy Wang, Brandon Wong, Victor Yun, Mahad
│ └── index.tsx
├── prisma # Prisma ORM
│ └── schema.prisma # Prisma Schema
│ │── dev-seeds # seeding data for dev environment
│ │── migrations # migrations for production
│ │── schema.prisma # Prisma Schema
│ │── schema.sql # SQL Schema
│ └── seed.ts # utility to script dev environment
├── public
│ ├── icons # Icons
Expand All @@ -67,12 +71,24 @@ Developers: Jason Huang, Soha Khan, Cindy Wang, Brandon Wong, Victor Yun, Mahad
├── src # Frontend tools
│ ├── components # Components
── definitions # Chakra
── definitions # Chakra
│ └── styles # CSS and Colours
├── types # Depdendencies types
├── terraform # Infrastructure as code for dev and prod
│ ├── environments # code separated by environments
│ └── modules # terraform modules for reuse
├── types # Dependency types
├── utils # Utility functions
│ │── containers # unstated-next containers
│ │── enum # enum utils
│ │── hooks # SWR API hooks
│ │── mail # SES mailing templates
│ │── request # API request utils
│ │── session # Session and authorization utils
│ │── time # time and date utils
│ │── toast # Chakra UI Toast msg utils
│ └── validation # Data/Input Validators
├── services # Third party services
Expand All @@ -85,6 +101,7 @@ Developers: Jason Huang, Soha Khan, Cindy Wang, Brandon Wong, Victor Yun, Mahad
# Misc individual files
├── .babelrc
├── .eslintignore
├── .env.sample # required env vars
├── .gitattributes
├── .gitignore
├── .prettierignore
Expand All @@ -111,10 +128,10 @@ Reset your database on Heroku and then deploy your database schema run (one-time

```bash
# Drop all tables from current Heroku postgres database
heroku pg:reset -a YOUR_APP_NAME
heroku pg:reset -a <YOUR_APP_NAME>

# Deploy schema.sql to Heroku postgres
heroku pg:psql -a YOUR_APP_NAME -f prisma/schema.sql
heroku pg:psql -a <YOUR_APP_NAME> -f prisma/schema.sql

# Regenerate Prisma schema and client
# optional - `npx prisma introspect`
Expand Down Expand Up @@ -148,10 +165,26 @@ yarn lint
yarn fix
```

## ✈️ Migration

NOTE: Before applying your migrations a production environment, ensure the diff via `npx prisma db pull` and `npx prisma migrate status` lines up with the migrations to be applied.

To migrate a database schema without losing data:

1. change both the `schema.sql` and `schema.prisma` file as required
2. run `prisma migrate dev --name <DESCRIPTIVE_NAME> --create-only` (this will require a [shadow database](https://www.prisma.io/docs/concepts/components/prisma-migrate/shadow-database/#cloud-hosted-shadow-databases-must-be-created-manually))
3. after the migration is approved, run `npx prisma migrate deploy` to apply all new migrations

Baseline environment:

Baselining initializes a migration history for databases that contain data and cannot be reset - such as the production database. Baselining tells Prisma Migrate to assume that one or more migrations have already been applied. Run the following command to baseline for each of the required migration: `prisma migrate resolve --applied <MIGRATION_FOLDER_NAME>`

For more info, please reference: [Adding Prisma Migrate to an existing project](https://www.prisma.io/docs/guides/database/developing-with-prisma-migrate/add-prisma-migrate-to-a-project)

## 🚢 Deployment

Deployments occur automatically on push to main and staging branches through [Railway](https://docs.railway.app/).

## License
## 📝 License

[MIT](LICENSE)
2 changes: 2 additions & 0 deletions models/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type ParentInput = {
isLowIncome?: boolean;
preferredLanguage: locale;
proofOfIncomeLink?: string;
proofOfIncomeSubmittedAt?: Date;
heardFrom?: heardFrom[];
heardFromOther?: string;
createStudentInput?: CreateStudentInput;
Expand All @@ -23,6 +24,7 @@ export type VolunteerInput = {
criminalRecordCheckLink?: string;
criminalCheckApproved?: boolean;
criminalCheckExpired?: boolean;
criminalCheckSubmittedAt?: Date;
addressLine1: string;
postalCode: string;
cityName: string;
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "social-diversity-for-children",
"version": "0.1.0",
"version": "0.0.3",
"private": true,
"scripts": {
"dev": "next dev",
Expand All @@ -18,9 +18,6 @@
"fix:prettier": "prettier --write '**/*.{js,jsx,ts,tsx}'",
"fix:eslint": "eslint '**/*.{js,jsx,ts,tsx}' --format stylish --fix"
},
"prisma": {
"seed": "ts-node -O {\"module\":\"CommonJS\"} prisma/seed.ts"
},
"dependencies": {
"@chakra-ui/icons": "^1.0.14",
"@chakra-ui/react": "^1.1.4",
Expand Down
2 changes: 2 additions & 0 deletions pages/admin/archive/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { AdminLoading } from "@components/AdminLoading";
import { weekdayToString } from "@utils/enum/weekday";
import { ArchivedProgramClassInfoCard } from "@components/admin/ArchivedProgramClassInfoCard";
import { mutate } from "swr";
import convertCamelToText from "@utils/convertCamelToText";

type ArchiveBrowseProgramsProps = {
session: Session;
Expand Down Expand Up @@ -68,6 +69,7 @@ export const ArchiveBrowsePrograms: React.FC<ArchiveBrowseProgramsProps> = (prop
} else if (
prog.name.toLowerCase().includes(term) ||
prog.description.toLowerCase().includes(term) ||
convertCamelToText(prog.onlineFormat).toLowerCase().includes(term) ||
prog.onlineFormat.toLowerCase().includes(term) ||
prog.tag.toLowerCase().includes(term)
) {
Expand Down
5 changes: 4 additions & 1 deletion pages/admin/class/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { AdminLoading } from "@components/AdminLoading";
import { Session } from "next-auth";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { AdminHeader } from "@components/admin/AdminHeader";
import { roles } from "@prisma/client";

type ClassViewProps = {
session: Session;
Expand Down Expand Up @@ -69,7 +70,9 @@ export default function ClassView({ session }: ClassViewProps): JSX.Element {

return (
<Wrapper session={session}>
<AdminHeader headerLinks={headerLinks}>Programs</AdminHeader>
<AdminHeader headerLinks={session?.role !== roles.TEACHER ? headerLinks : []}>
Classes
</AdminHeader>
<VStack mx={8} spacing={8} alignItems="flex-start">
<Breadcrumb separator={">"}>
<BreadcrumbItem>
Expand Down
49 changes: 26 additions & 23 deletions pages/admin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Link from "next/link";
import React from "react";
import { MdClass, MdCreate, MdPersonAdd } from "react-icons/md";
import { RiCouponFill } from "react-icons/ri";
import { roles } from "@prisma/client";

type AdminProps = {
session: Session;
Expand Down Expand Up @@ -53,29 +54,31 @@ export default function Admin(props: AdminProps): JSX.Element {
<Wrapper session={props.session}>
<AdminHeader>Dashboard</AdminHeader>
<VStack spacing={5} mx={8} pb={4} align="flex-start">
<Grid templateColumns="repeat(4, 1fr)" gap={4} w="100%">
<AdminOptionButton
icon={MdCreate}
label="Create new Class"
href="/admin/class/edit/new"
/>
<AdminOptionButton
icon={MdClass}
label="Create new Program"
href="/admin/program/edit/new"
/>
<AdminOptionButton
icon={MdPersonAdd}
label="Add SDC Member"
href="/admin/add"
/>
<AdminOptionButton
icon={RiCouponFill}
label="Add Coupon Code"
href="https://dashboard.stripe.com/coupons"
isExternal
/>
</Grid>
{props.session?.role !== roles.TEACHER ? (
<Grid templateColumns="repeat(4, 1fr)" gap={4} w="100%">
<AdminOptionButton
icon={MdCreate}
label="Create new Class"
href="/admin/class/edit/new"
/>
<AdminOptionButton
icon={MdClass}
label="Create new Program"
href="/admin/program/edit/new"
/>
<AdminOptionButton
icon={MdPersonAdd}
label="Add SDC Member"
href="/admin/add"
/>
<AdminOptionButton
icon={RiCouponFill}
label="Add Coupon Code"
href="https://dashboard.stripe.com/coupons"
isExternal
/>
</Grid>
) : null}
<Heading size="sm" alignSelf="flex-start" fontWeight="normal">
Overview and Analytics
</Heading>
Expand Down
5 changes: 4 additions & 1 deletion pages/admin/program/[pid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { Session } from "next-auth";
import { isInternal } from "@utils/session/authorization";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { AdminHeader } from "@components/admin/AdminHeader";
import { roles } from "@prisma/client";

type ClassViewProps = {
session: Session;
Expand Down Expand Up @@ -81,7 +82,9 @@ export default function ProgramClassView({ session }: ClassViewProps): JSX.Eleme

return (
<Wrapper session={session}>
<AdminHeader headerLinks={headerLinks}>Programs</AdminHeader>
<AdminHeader headerLinks={session?.role !== roles.TEACHER ? headerLinks : []}>
Programs
</AdminHeader>
<VStack mx={8} spacing={6} alignItems="flex-start">
<Breadcrumb separator={">"}>
<BreadcrumbItem>
Expand Down
7 changes: 6 additions & 1 deletion pages/admin/program/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { Session } from "next-auth";
import { AdminLoading } from "@components/AdminLoading";
import { AdminError } from "@components/AdminError";
import { isInternal } from "@utils/session/authorization";
import { roles } from "@prisma/client";
import convertCamelToText from "@utils/convertCamelToText";

type BrowseProgramsProps = {
session: Session;
Expand Down Expand Up @@ -45,6 +47,7 @@ export const BrowsePrograms: React.FC<BrowseProgramsProps> = (props) => {
} else if (
prog.name.toLowerCase().includes(term) ||
prog.description.toLowerCase().includes(term) ||
convertCamelToText(prog.onlineFormat).toLowerCase().includes(term) ||
prog.onlineFormat.toLowerCase().includes(term) ||
prog.tag.toLowerCase().includes(term)
) {
Expand All @@ -53,7 +56,9 @@ export const BrowsePrograms: React.FC<BrowseProgramsProps> = (props) => {
});
return (
<Wrapper session={props.session}>
<AdminHeader headerLinks={headerLinks}>Programs</AdminHeader>
<AdminHeader headerLinks={props.session?.role !== roles.TEACHER ? headerLinks : []}>
Programs
</AdminHeader>

<Box mx={8}>
<Text fontSize="16px">Browse Programs</Text>
Expand Down
11 changes: 8 additions & 3 deletions pages/admin/registrant/user/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { useRouter } from "next/router";
import React, { useEffect, useState } from "react";
import { MdDescription, MdPerson, MdSupervisorAccount } from "react-icons/md";
import { mutate } from "swr";
import checkExpiry from "@utils/checkExpiry";

type AdminProps = {
session: Session;
Expand Down Expand Up @@ -173,8 +174,7 @@ export default function Registrant(props: AdminProps): JSX.Element {
/>
) : (
<EmptyState height="200px">
The participant has not uploaded a criminal record check at this
time.
The participant has not uploaded a proof of income at this time.
</EmptyState>
),
});
Expand Down Expand Up @@ -206,7 +206,12 @@ export default function Registrant(props: AdminProps): JSX.Element {
header: "Criminal Record Check",
canEdit: false,
component:
user.volunteer.criminalRecordCheckLink !== null ? (
user.volunteer.criminalRecordCheckLink !== null &&
checkExpiry(user.volunteer.criminalCheckSubmittedAt) ? (
<EmptyState height="200px">
The participant's criminal record check is expired.
</EmptyState>
) : user.volunteer.criminalRecordCheckLink !== null ? (
<FileDownloadCard
filePath={FileType.CRIMINAL_CHECK}
docName={user.volunteer.criminalRecordCheckLink}
Expand Down
Loading

0 comments on commit cf58cad

Please sign in to comment.