Skip to content

Commit

Permalink
Ticket #199 and ticket #213 (#228)
Browse files Browse the repository at this point in the history
Co-authored-by: Brandon Cruz-Youll <brandon.cruzyoull@gmail.com>
  • Loading branch information
2 people authored and amantri committed Nov 11, 2023
1 parent a9703c2 commit 27d169d
Show file tree
Hide file tree
Showing 8 changed files with 312 additions and 46 deletions.
42 changes: 42 additions & 0 deletions src/backend/routers/case_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,48 @@ export const case_manager = router({
.executeTakeFirstOrThrow();
}),

/**
* Edits the given student in the CM's roster. Throws an error if the student was not found in the db.
*/
editStudent: authenticatedProcedure
.input(
z.object({
student_id: z.string(),
first_name: z.string(),
last_name: z.string(),
email: z.string().email(),
grade: z.number(),
})
)
.mutation(async (req) => {
const { student_id, first_name, last_name, email, grade } = req.input;
const { userId } = req.ctx.auth; // case manager id

// Check if the student exists and if the case manager is assigned to the student
const existingStudent = req.ctx.db
.selectFrom("student")
.selectAll()
.where("student_id", "=", student_id)
.where("assigned_case_manager_id", "=", userId);

if (!existingStudent) {
throw new Error("Student not found");
}

// Update the student's information
return await req.ctx.db
.updateTable("student")
.set({
first_name,
last_name,
email: email.toLowerCase(),
grade,
})
.where("student_id", "=", student_id)
.returningAll()
.executeTakeFirstOrThrow();
}),

/**
* Removes the case manager associated with this student.
*/
Expand Down
8 changes: 5 additions & 3 deletions src/backend/routers/para.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export const para = router({
.selectAll()
.executeTakeFirst();

const caseManagerName = req.ctx.auth.session.user?.name ?? "";

if (!paraData) {
paraData = await req.ctx.db
.insertInto("user")
Expand All @@ -66,10 +68,10 @@ export const para = router({
to: email,
subject: "Para-professional email confirmation",
text: "Email confirmation",
html: "<h1>Email confirmation</h1><p>Please confirm your email by going to the following link: <a>no link yet</a></p>",
html: `<p>Dear ${first_name},</p><p>Welcome to the data collection team for SFUSD.EDU!</p><p>I am writing to invite you to join our data collection efforts for our students. We are using an online platform called <strong>Project Compass</strong> to track and monitor student progress, and your participation is crucial to the success of this initiative.</p><p>To access Project Compass and begin collecting data, please follow these steps:</p><ul><li>Go to the website: (<a href="https://staging.compassiep.com/">https://staging.compassiep.com/</a>)</li> <li>Login using your provided username and password</li><li>Once logged in, navigate to the dashboard where you would see the student goals page</li></ul><p>By clicking on the <strong>data collection</strong> button, you will be directed to the instructions outlining the necessary steps for data collection. Simply follow the provided instructions and enter the required data points accurately.</p><p>If you encounter any difficulties or have any questions, please feel free to reach out to me. I am here to assist you throughout the process and ensure a smooth data collection experience. Your dedication and contribution will make a meaningful impact on our students' educational journeys.</p><p>Thank you,</p><p>${caseManagerName}<br>Case Manager</p>`,
});
// TODO: when site is deployed, add url to html above
// to do elsewhere: add "email_verified_at" timestamp when para first signs in with their email address (entered into db by cm)
// TODO: when site is deployed, add new url to html above
// TODO elsewhere: add "email_verified_at" timestamp when para first signs in with their email address (entered into db by cm)
}

return paraData;
Expand Down
2 changes: 2 additions & 0 deletions src/backend/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { TRPCError, initTRPC } from "@trpc/server";
import { createContext } from "./context";
import superjson from "superjson";

// initialize tRPC exactly once per application:
export const t = initTRPC.context<typeof createContext>().create({
// SuperJSON allows us to transparently use, e.g., standard Date/Map/Sets
// over the wire between the server and client.
Expand Down Expand Up @@ -34,6 +35,7 @@ const isAdmin = t.middleware(({ next, ctx }) => {
});
});

// Define and export the tRPC router
export const router = t.router;
export const authenticatedProcedure = t.procedure.use(isAuthenticated);
export const adminProcedure = t.procedure.use(isAuthenticated).use(isAdmin);
7 changes: 4 additions & 3 deletions src/components/iep/Iep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import $input from "@/styles/Input.module.css";
import Box from "@mui/material/Box";
import Container from "@mui/material/Container";
import List from "@mui/material/List";
import Stack from "@mui/material/Stack";
import Image from "next/image";
import noGoals from "../../public/img/no-goals-icon.png";
import $Iep from "./Iep.module.css";
import $Image from "../../styles/Image.module.css";
import $Iep from "./Iep.module.css";

interface IepProps {
iep_id: string;
Expand Down Expand Up @@ -42,7 +43,7 @@ const Iep = ({ iep_id }: IepProps) => {
}

return (
<>
<Stack sx={{ width: 1 }}>
<Container>
<Box className={$Iep.goalBox}>
<p className={$Iep.goalTab}>Goals &#40;{goals?.length ?? 0}&#41;</p>
Expand Down Expand Up @@ -104,7 +105,7 @@ const Iep = ({ iep_id }: IepProps) => {
</Box>
</Container>
)}
</>
</Stack>
);
};
export default Iep;
Loading

0 comments on commit 27d169d

Please sign in to comment.