Skip to content

Commit

Permalink
Merge branch 'main' into contribution-style
Browse files Browse the repository at this point in the history
  • Loading branch information
jackbravo authored Mar 8, 2024
2 parents df56b20 + 1db63c4 commit 0f6c709
Show file tree
Hide file tree
Showing 20 changed files with 1,363 additions and 721 deletions.
6 changes: 3 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ module.exports = {
],
rules: {
"import/no-named-as-default": 0,
"@typescript-eslint/no-explicit-any": "warn"
}
"@typescript-eslint/no-explicit-any": "warn",
},
},

// Markdown
Expand Down Expand Up @@ -115,7 +115,7 @@ module.exports = {
"jest/no-standalone-expect": "off",
"testing-library/no-node-access": "warn",
"testing-library/no-container": "warn",
}
},
},

// Cypress
Expand Down
11 changes: 4 additions & 7 deletions app/core/components/ApplicantComments/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
Paper,
IconButton,
} from "@mui/material";
import type { internsComments as CommentType, Profiles } from "@prisma/client";
import { Form, useNavigation } from "@remix-run/react";
import { withZod } from "@remix-validated-form/with-zod";
import Markdown from "marked-react";
Expand All @@ -22,11 +21,9 @@ import { zfd } from "zod-form-data";
import type { getCommentsApplicant } from "~/models/applicantComment.server";
import { validateNavigationRedirect } from "~/utils";

type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
type CommentsArrayType = Awaited<ReturnType<typeof getCommentsApplicant>>;
type CommentItemType = CommentType & {
author?: Profiles;
children?: CommentType[];
};
type CommentItemType = Optional<CommentsArrayType[number], "children">;

export const validator = withZod(
zfd.formData({
Expand Down Expand Up @@ -104,10 +101,10 @@ function CommentItem({
<Paper sx={{ padding: 2, marginY: 2 }}>
<Grid container spacing={2} alignItems="center">
<Grid item>
<Avatar alt={"alt"} src={comment.author?.avatarUrl ?? ""}></Avatar>
<Avatar alt={"alt"} src={comment.authorAvatarUrl ?? ""}></Avatar>
</Grid>
<Grid justifyContent="left" item xs zeroMinWidth>
<Typography variant="body1">{`${comment.author?.preferredName} ${comment.author?.lastName}`}</Typography>
<Typography variant="body1">{`${comment.authorPreferredName} ${comment.authorLastName}`}</Typography>
<Typography variant="body2">
{comment.updatedAt.toLocaleString()}
</Typography>
Expand Down
11 changes: 4 additions & 7 deletions app/core/components/Comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
Paper,
IconButton,
} from "@mui/material";
import type { Comments as CommentType, Profiles } from "@prisma/client";
import { Form, useNavigation } from "@remix-run/react";
import { withZod } from "@remix-validated-form/with-zod";
import Markdown from "marked-react";
Expand All @@ -22,11 +21,9 @@ import { zfd } from "zod-form-data";
import type { getComments } from "~/models/comment.server";
import { validateNavigationRedirect } from "~/utils";

type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
type CommentsArrayType = Awaited<ReturnType<typeof getComments>>;
type CommentItemType = CommentType & {
author?: Profiles;
children?: CommentType[];
};
type CommentItemType = Optional<CommentsArrayType[number], "children">;

export const validator = withZod(
zfd.formData({
Expand Down Expand Up @@ -104,10 +101,10 @@ function CommentItem({
<Paper sx={{ padding: 2, marginY: 2 }}>
<Grid container spacing={2} alignItems="center">
<Grid item>
<Avatar alt={"alt"} src={comment.author?.avatarUrl ?? ""}></Avatar>
<Avatar alt={"alt"} src={comment.authorAvatarUrl ?? ""}></Avatar>
</Grid>
<Grid justifyContent="left" item xs zeroMinWidth>
<Typography variant="body1">{`${comment.author?.preferredName} ${comment.author?.lastName}`}</Typography>
<Typography variant="body1">{`${comment.authorPreferredName} ${comment.authorLastName}`}</Typography>
<Typography variant="body2">
{comment.updatedAt.toLocaleString()}
</Typography>
Expand Down
9 changes: 3 additions & 6 deletions app/core/components/RegularSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
InputLabel,
FormHelperText,
} from "@mui/material";
import { useState } from "react";
import { useControlField, useField } from "remix-validated-form";

interface SelectValue {
Expand Down Expand Up @@ -36,31 +35,29 @@ export const RegularSelect = ({

const [value, setValue] = useControlField<SelectValue>(name);
//This state variable is to have a controlled input and avoid errors in the console
const [selectValue, setSelectValue] = useState<string>("");
return (
<FormControl fullWidth id={name} size="small" error={!!error}>
<input type="hidden" name={`${name}.name`} value={value?.name} />
<input type="hidden" name={`${name}.id`} value={value?.id} />
<InputLabel id={name}>{label}</InputLabel>
<Select
label={label}
value={selectValue}
value={value?.id}
error={!!error}
style={style ? style : { margin: "1em 0" }}
onChange={(event) => {
const newValue = valuesList.find(
(item) => item.name === event.target.value
(item) => item.id === event.target.value
);
if (newValue) {
setValue(newValue);
setSelectValue(newValue.name);
}
onChange && onChange(newValue as SelectValue);
}}
disabled={disabled}
>
{valuesList.map((item) => (
<MenuItem key={item.id} value={item.name}>
<MenuItem key={item.id} value={item.id}>
{item.name}
</MenuItem>
))}
Expand Down
20 changes: 19 additions & 1 deletion app/db.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
import { DB } from "./kysely";
import { singleton } from "./singleton.server";
import { PrismaClient, Prisma } from "@prisma/client";
import { Sql } from "@prisma/client/runtime/library";
import { singleton } from "./singleton.server";
import { Kysely, PostgresDialect } from "kysely";
import { Pool } from "pg";

const dialect = new PostgresDialect({
pool: new Pool({
connectionString: process.env.DATABASE_URL,
max: 10,
}),
});

// Database interface is passed to Kysely's constructor, and from now on, Kysely
// knows your database structure.
// Dialect is passed to Kysely's constructor, and from now on, Kysely knows how
// to communicate with your database.
export const db = new Kysely<DB>({
dialect,
});

// Hard-code a unique key, so we can look up the client when this module gets re-imported
const prisma = singleton("prisma", () => new PrismaClient());
Expand Down
Loading

0 comments on commit 0f6c709

Please sign in to comment.