Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaning code #142

Merged
merged 2 commits into from
Mar 2, 2023
Merged
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
1 change: 0 additions & 1 deletion app/core/components/Comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import Edit from "@mui/icons-material/Edit";
import Delete from "@mui/icons-material/Delete";
import { z } from "zod";

import type { getComments } from "~/models/comment.server";
import { zfd } from "zod-form-data";
import { withZod } from "@remix-validated-form/with-zod";
Expand Down
1 change: 0 additions & 1 deletion app/core/components/DisciplinesSelect/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useEffect } from "react";

import {
CircularProgress,
TextField,
Expand Down
2 changes: 0 additions & 2 deletions app/core/components/DropDownButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
MenuList,
} from "@mui/material";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";

import { DropdownPlaceholderContainer } from "./DropDownButton.styles";
import Link from "../Link";

Expand Down Expand Up @@ -54,7 +53,6 @@ export const DropDownButton = ({
}
}

// return focus to the button when we transitioned from !openActionsUser -> openActionsUser
const prevOpen = useRef(openActionsUser);
useEffect(() => {
if (prevOpen.current === true && openActionsUser === false) {
Expand Down
1 change: 0 additions & 1 deletion app/core/components/JoinProjectModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import DisciplinesSelect from "app/core/components/DisciplinesSelect";
import SkillsSelect from "app/core/components/SkillsSelect";
import ModalBox from "app/core/components/ModalBox";
import Button from "@mui/material/Button";

import {
Grid,
FormDivContainer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const Grid = styled.div`
overflow: scroll;
}
`;

export const FormDivContainer = styled.div`
h1 {
margin: 0.5rem 0 1rem 0;
Expand Down
1 change: 0 additions & 1 deletion app/core/components/LabeledTextField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useControlField, useField } from "remix-validated-form";
interface LabeledTextFieldProps {
name: string;
label: string;
/** Field type. Doesn't include radio buttons and checkboxes */
type?: "text" | "password" | "email" | "number";
helperText?: string;
placeholder?: string;
Expand Down
1 change: 0 additions & 1 deletion app/core/components/LabeledTextFieldArea/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useField } from "remix-validated-form";
interface LabeledTextFieldAreaProps {
name: string;
label: string;
/** Field type. Doesn't include radio buttons and checkboxes */
type?: "text" | "password" | "email" | "number";
helperText?: string;
placeholder?: string;
Expand Down
1 change: 0 additions & 1 deletion app/core/components/LabelsSelect/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Fragment, useEffect } from "react";

import {
CircularProgress,
TextField,
Expand Down
2 changes: 0 additions & 2 deletions app/core/components/MembershipStatusModal.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { useState } from "react";

import FormControl from "@mui/material/FormControl";
import InputLabel from "@mui/material/InputLabel";
import MenuItem from "@mui/material/MenuItem";
import Select from "@mui/material/Select";
import type { SelectChangeEvent } from "@mui/material/Select";

import type { ProjectComplete } from "~/models/project.server";
import type { ProjectMembers } from "@prisma/client";
import { withZod } from "@remix-validated-form/with-zod";
Expand Down
2 changes: 1 addition & 1 deletion app/core/components/MultiUrl/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import { useState } from "react";
import { Chip, Grid, TextField } from "@mui/material";
import styled from "@emotion/styled";
import { useField, FieldArray, useFormContext } from "remix-validated-form";
Expand Down
1 change: 0 additions & 1 deletion app/core/components/ProposalCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import EllipsisText from "app/core/components/EllipsisText";
import ThumbUpIcon from "@mui/icons-material/ThumbUp";
import PersonIcon from "@mui/icons-material/Person";
import HelpIcon from "@mui/icons-material/Help";

import { ProposalCardWrap } from "./ProposalCard.styles";

interface IProps {
Expand Down
4 changes: 0 additions & 4 deletions app/core/components/RelatedProjectsSelect/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { PropsWithoutRef } from "react";

import { TextField, Autocomplete } from "@mui/material";
import { useField, useControlField } from "remix-validated-form";

Expand All @@ -17,16 +16,13 @@ interface RelatedProjectsSelectProps {
}

export const RelatedProjectsSelect = ({
customOnChange,
defaultValue = [],
fullWidth,
name,
label,
helperText,
outerProps,
size,
style,
thisProject,
}: RelatedProjectsSelectProps) => {
const { error, getInputProps } = useField(name);
const [values, setValue] = useControlField<string[]>(name);
Expand Down
1 change: 0 additions & 1 deletion app/core/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const Search = () => {
: "";
const [searchValue, setSearchValue] = useState(searchQuery);
const projectsSearch = "/projects";

const handleEnterKeyPress = (e: React.KeyboardEvent<HTMLDivElement>) => {
if (e.key === "Enter") {
navigate(`${projectsSearch}?q=${searchValue}`);
Expand Down
1 change: 0 additions & 1 deletion app/core/components/SkillsSelect/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useEffect } from "react";

import {
CircularProgress,
TextField,
Expand Down
1 change: 0 additions & 1 deletion app/core/components/SortInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ interface SortOption {
}

export const SortInput = ({ setSortQuery, sortBy }: iProps) => {
//sorting options
const sortOptions: { [key: string]: SortOption } = {
hotness: {
label: "Hotness",
Expand Down
1 change: 0 additions & 1 deletion app/core/layouts/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const StyledHeaderButton = styled(Button)(({ theme }) => ({
const Header = ({ title }: IProps) => {
const currentUser = useUser();
const submit = useSubmit();

const options: MenuItemArgs[] = [
{
onClick: async () => {
Expand Down
1 change: 0 additions & 1 deletion app/models/note.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { User, Note } from "@prisma/client";

import { prisma } from "~/db.server";

export type { Note } from "@prisma/client";
Expand Down
1 change: 0 additions & 1 deletion app/models/profile.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { User, Profiles, PrismaClient } from "@prisma/client";
import { Prisma } from "@prisma/client";

import { prisma } from "../db.server";

interface UserProfile extends Profiles {
Expand Down
3 changes: 1 addition & 2 deletions app/models/project.server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Profiles, Projects } from "@prisma/client";
import { Prisma } from "@prisma/client";
import { defaultStatus } from "~/constants";

import { joinCondition, prisma as db } from "~/db.server";

interface SearchProjectsInput {
Expand Down Expand Up @@ -754,4 +753,4 @@ export async function updateProjectResources(projectId: string, resources: Array
await db.resource.deleteMany({ where: { projectId } });
const data = resources.map(resource => ({ ...resource, projectId }))
return db.resource.createMany({ data })
}
}
1 change: 0 additions & 1 deletion app/models/user.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { User } from "@prisma/client";

import { prisma } from "~/db.server";

export type { User } from "@prisma/client";
Expand Down
3 changes: 0 additions & 3 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import {
Scripts,
ScrollRestoration,
} from "@remix-run/react";

import StylesheetUrl from "./styles/style.css";

import { getUser } from "./session.server";
import { CssBaseline, useMediaQuery } from "@mui/material";
import { createTheme } from "./theme";
Expand Down Expand Up @@ -53,7 +51,6 @@ export default function App() {
[prefersDarkMode]
);

// TODO: https://mui.com/material-ui/customization/dark-mode/#dark-mode-by-default
return (
<ThemeProvider theme={theme}>
<CssBaseline />
Expand Down
1 change: 0 additions & 1 deletion app/routes/auth/auth0/callback.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { LoaderFunction } from "@remix-run/node";
import { createUserSession } from "~/session.server";

import { authenticator } from "~/auth.server";

export let loader: LoaderFunction = async ({ request }) => {
Expand Down
1 change: 0 additions & 1 deletion app/routes/healthcheck.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// learn more: https://fly.io/docs/reference/configuration/#services-http_checks
import type { LoaderFunction } from "@remix-run/node";

import { prisma } from "~/db.server";

export const loader: LoaderFunction = async ({ request }) => {
Expand Down
1 change: 0 additions & 1 deletion app/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
Footer,
LoginPageContainer,
} from "./login.styles";

import { useOptionalUser } from "~/utils";
import { Grid } from "@mui/material";

Expand Down
1 change: 0 additions & 1 deletion app/routes/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
Footer,
LoginPageContainer,
} from "./login.styles";

import { getUserId } from "~/session.server";

export const loader: LoaderFunction = async ({ request }) => {
Expand Down
1 change: 0 additions & 1 deletion app/routes/logout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { ActionFunction, LoaderFunction } from "@remix-run/node";
import { redirect } from "@remix-run/node";

import { logout } from "~/session.server";

export const action: ActionFunction = async ({ request }) => {
Expand Down
1 change: 0 additions & 1 deletion app/routes/manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
NavBarTabsStyles,
LinkStyles,
} from "./manager/manager.styles";

import { adminRoleName } from "app/constants";
import { requireUser } from "~/session.server";
import { Container, Paper } from "@mui/material";
Expand Down
1 change: 0 additions & 1 deletion app/routes/manager/admins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import DeleteIcon from "@mui/icons-material/DeleteOutlined";
import SaveIcon from "@mui/icons-material/Save";
import CancelIcon from "@mui/icons-material/Close";
import invariant from "tiny-invariant";

import ConfirmationModal from "../../core/components/ConfirmationModal";
import {
getAdminUsers,
Expand Down
1 change: 0 additions & 1 deletion app/routes/manager/filter-tags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { MetaFunction, LoaderFunction } from "@remix-run/node"
import { useLoaderData, Outlet } from "@remix-run/react"
import { redirect } from "@remix-run/node"
import { json } from "@remix-run/node"

import { LinkTabStyles, EditPanelsStyles, BoxStyles } from "./manager.styles"

export const loader: LoaderFunction = async ({ request }) => {
Expand Down
1 change: 0 additions & 1 deletion app/routes/manager/filter-tags/labels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import DeleteIcon from "@mui/icons-material/DeleteOutlined";
import SaveIcon from "@mui/icons-material/Save";
import CancelIcon from "@mui/icons-material/Close";
import invariant from "tiny-invariant";

import ConfirmationModal from "../../../core/components/ConfirmationModal";
import {
getLabels,
Expand Down
1 change: 0 additions & 1 deletion app/routes/notes.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { LoaderFunction } from "@remix-run/node";
import { json } from "@remix-run/node";
import { Form, Link, NavLink, Outlet, useLoaderData } from "@remix-run/react";

import { requireUserId } from "~/session.server";
import { useUser } from "~/utils";
import { getNoteListItems } from "~/models/note.server";
Expand Down
1 change: 0 additions & 1 deletion app/routes/notes/$noteId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { redirect } from "@remix-run/node";
import { Form, useCatch } from "@remix-run/react";
import { typedjson, useTypedLoaderData } from "remix-typedjson";
import invariant from "tiny-invariant";

import { deleteNote } from "~/models/note.server";
import { getNote } from "~/models/note.server";
import { requireUserId } from "~/session.server";
Expand Down
1 change: 0 additions & 1 deletion app/routes/notes/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { ActionFunction } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { Form, useActionData } from "@remix-run/react";
import * as React from "react";

import { createNote } from "~/models/note.server";
import { requireUserId } from "~/session.server";

Expand Down
1 change: 0 additions & 1 deletion app/routes/projects/$projectId.members.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
PrismaClientKnownRequestError,
PrismaClientValidationError,
} from "@prisma/client/runtime";

import type { ActionFunction, LoaderFunction } from "@remix-run/node";
import type { SubmitOptions } from "@remix-run/react";
import { json, redirect } from "@remix-run/node";
Expand Down
9 changes: 2 additions & 7 deletions app/routes/projects/$projectId/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
updateProjects,
} from "~/models/project.server";
import { adminRoleName } from "app/constants";

import {
Box,
Button,
Expand All @@ -35,7 +34,6 @@ import { TabStyles } from "../components/Styles/TabStyles.component";
import TabPanel from "~/core/components/TabPanel";
import { getProjectStatuses } from "~/models/status.server";
import { getInnovationTiers } from "~/models/innovationTier.server";

import MDEditorStyles from "@uiw/react-md-editor/markdown-editor.css";
import MarkdownStyles from "@uiw/react-markdown-preview/markdown.css";
import { isProjectMemberOrOwner } from "~/utils";
Expand All @@ -57,13 +55,12 @@ export const loader = async ({ request, params }: LoaderArgs) => {

const statuses = await getProjectStatuses();
const tiers = await getInnovationTiers();

const user = await requireUser(request);
const profile = await requireProfile(request);
const isTeamMember = isProjectTeamMember(profile.id, project);

const isAdmin = user.role == adminRoleName;
const profileId = profile.id;

return typedjson({
isAdmin,
isTeamMember,
Expand All @@ -79,7 +76,6 @@ export const loader = async ({ request, params }: LoaderArgs) => {
export const action: ActionFunction = async ({ request, params }) => {
invariant(params.projectId, "projectId could not be found");
const projectId = params.projectId;

// Validate permissions
const user = await requireUser(request);
const isAdmin = user.role == adminRoleName;
Expand All @@ -92,7 +88,7 @@ export const action: ActionFunction = async ({ request, params }) => {
} = currentProject;
isProjectMemberOrOwner(profile.id, currentMembers, currentOwnerId);
}

const result = await validator.validate(await request.formData());
if (result.error) return validationError(result.error);
const project = await updateProjects(projectId, result.data);
Expand Down Expand Up @@ -183,7 +179,6 @@ export default function EditProjectPage() {
skills: project.skills,
labels: project.labels,
projectBoard: project.projectBoard || "",
//projectMembers: project.projectMembers,
}}
method="post"
>
Expand Down
Loading