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

Tidy time #179

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
30 changes: 30 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/** @type {import("eslint").Linter.Config} */
const config = {
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
ignorePatterns: [".eslintrc.js", "lib/db/types/**/*"],
extends: ["next/core-web-vitals", "prettier", "plugin:storybook/recommended"],
plugins: [
"@typescript-eslint",
"eslint-plugin-unused-imports",
"eslint-plugin-react",
],
rules: {
"@next/next/no-async-client-component": "error",
"@typescript-eslint/consistent-type-imports": [
"warn",
{
prefer: "type-imports",
fixStyle: "inline-type-imports",
},
],
"@typescript-eslint/no-unused-vars": [
"warn",
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
],
},
};

module.exports = config;
11 changes: 0 additions & 11 deletions .eslintrc.json

This file was deleted.

3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["prettier-plugin-organize-imports"]
}
3 changes: 1 addition & 2 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Preview } from "@storybook/react";

import { withThemeByClassName } from "@storybook/addon-styling";
import type { Preview } from "@storybook/react";

/* TODO: update import to your tailwind styles file. If you're using Angular, inject this through your angular.json config instead */
import "../app/globals.css";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use client";

import { Anchor, Breadcrumbs, Text } from "@mantine/core";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useMemo } from "react";
import Link from "next/link";
import { Anchor, Breadcrumbs, Text } from "@mantine/core";
import { LuHome } from "react-icons/lu";

const breadcrumbSegments: { [K: string]: string } = {
calendar: "Calendar",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use client";
import YSTVBreadcrumbs from "@/app/(authenticated)/_components/Breadcrumbs";
import Logo from "@/app/_assets/logo.png";
import { UserMenu } from "@/components/UserMenu";
import styles from "@/styles/Nav.module.css";
import { AppShell, Group, rem } from "@mantine/core";
import { useHeadroom } from "@mantine/hooks";
import Image from "next/image";
import Link from "next/link";
import Logo from "@/app/_assets/logo.png";
import { UserMenu } from "@/components/UserMenu";
import styles from "@/styles/Nav.module.css";
import YSTVBreadcrumbs from "@/components/Breadcrumbs";

interface NavProps {
children: React.ReactNode;
Expand Down
3 changes: 1 addition & 2 deletions app/(authenticated)/admin/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ErrorPage from "@/components/ErrorPage";
import ErrorPage from "@/components/helpers/ErrorPage";
import { hasPermission } from "@/lib/auth/server";
import { notFound } from "next/navigation";

export default async function AuthenticatedLayout({
children,
Expand Down
2 changes: 1 addition & 1 deletion app/(authenticated)/admin/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PageInfo } from "@/components/PageInfo";
import { PageInfo } from "@/components/helpers/PageInfo";
import { Button, Card, Stack } from "@mantine/core";
import Link from "next/link";

Expand Down
12 changes: 6 additions & 6 deletions app/(authenticated)/admin/positions/PositionCard.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Card, Group, Stack, Menu, ActionIcon, Text } from "@mantine/core";
import type { FormResponse } from "@/components/forms";
import { ActionIcon, Card, Group, Menu, Stack, Text } from "@mantine/core";
import { modals } from "@mantine/modals";
import { notifications } from "@mantine/notifications";
import { Position } from "@prisma/client";
import type { Position } from "@prisma/client";
import { FaEdit } from "react-icons/fa";
import { MdMoreHoriz, MdDeleteForever } from "react-icons/md";
import { deletePositionSchema } from "./schema";
import { z } from "zod";
import { FormResponse } from "@/components/Form";
import { MdDeleteForever, MdMoreHoriz } from "react-icons/md";
import type { z } from "zod";
import type { deletePositionSchema } from "./schema";

export function PositionCard(props: {
position: Position;
Expand Down
36 changes: 18 additions & 18 deletions app/(authenticated)/admin/positions/PositionView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
"use client";

import { SearchBar } from "@/components/SearchBar";
import {
CountControls,
PageControls,
PaginationProvider,
} from "@/components/navigation/Pagination";
import { getSearchParamsString } from "@/lib/searchParams/util";
import { useValidSearchParams } from "@/lib/searchParams/validate";
import {
Button,
Center,
Expand All @@ -10,32 +18,23 @@ import {
Stack,
Text,
} from "@mantine/core";
import { Position } from "@prisma/client";
import { usePathname, useSearchParams } from "next/navigation";
import { searchParamsSchema } from "./schema";
import { useRouter } from "next/navigation";
import { FaPlus } from "react-icons/fa";
import { z } from "zod";
import { useEffect, useState } from "react";
import {
CountControls,
PageControls,
PaginationProvider,
} from "@/components/Pagination";
import { useDisclosure } from "@mantine/hooks";
import { SearchBar } from "@/components/SearchBar";
import { CreatePositionForm, UpdatePositionForm } from "./form";
import { useValidSearchParams } from "@/lib/searchParams/validate";
import { getSearchParamsString } from "@/lib/searchParams/util";
import type { Position } from "@prisma/client";
import { useQuery } from "@tanstack/react-query";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useEffect, useState } from "react";
import { FaPlus } from "react-icons/fa";
import type { z } from "zod";
import { PositionCard } from "./PositionCard";
import {
createPositionAction,
deletePositionAction,
fetchPositionsAction,
TFetchPositions,
updatePositionAction,
type TFetchPositions,
} from "./actions";
import { useQuery } from "@tanstack/react-query";
import { CreatePositionForm, UpdatePositionForm } from "./form";
import { searchParamsSchema } from "./schema";

export function PositionView(props: { initialPositions: TFetchPositions }) {
const pathname = usePathname();
Expand Down Expand Up @@ -74,6 +73,7 @@ export function PositionView(props: { initialPositions: TFetchPositions }) {
) {
router.push(`${pathname}?${newSearchParamsString}`);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [searchParamsState]);

// States for modals
Expand Down
17 changes: 8 additions & 9 deletions app/(authenticated)/admin/positions/actions.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
"use server";

import { zodErrorResponse } from "@/components/FormServerHelpers";
import {
createPositionSchema,
deletePositionSchema,
searchParamsSchema,
updatePositionSchema,
} from "./schema";
import { zodErrorResponse, type FormResponse } from "@/components/forms";
import {
createPosition,
deletePosition,
fetchPositions,
updatePosition,
} from "@/features/positions";
import { Position } from "@prisma/client";
import { FormResponse } from "@/components/Form";
import type { Position } from "@prisma/client";
import {
createPositionSchema,
deletePositionSchema,
searchParamsSchema,
updatePositionSchema,
} from "./schema";

export type TFetchPositions = {
positions: Position[];
Expand Down
13 changes: 8 additions & 5 deletions app/(authenticated)/admin/positions/form.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import Form, { FormResponse } from "@/components/Form";
import { createPositionSchema, updatePositionSchema } from "./schema";
import { z } from "zod";
import { TextAreaField, TextField } from "@/components/FormFields";
import { Position } from "@prisma/client";
import Form, {
TextAreaField,
TextField,
type FormResponse,
} from "@/components/forms";
import { notifications } from "@mantine/notifications";
import type { Position } from "@prisma/client";
import type { z } from "zod";
import { createPositionSchema, updatePositionSchema } from "./schema";

export function CreatePositionForm(props: {
action: (data: z.infer<typeof createPositionSchema>) => Promise<FormResponse>;
Expand Down
2 changes: 1 addition & 1 deletion app/(authenticated)/admin/positions/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ErrorPage from "@/components/ErrorPage";
import ErrorPage from "@/components/helpers/ErrorPage";
import { hasPermission } from "@/lib/auth/server";

export default async function AuthenticatedLayout({
Expand Down
10 changes: 5 additions & 5 deletions app/(authenticated)/admin/positions/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PositionView } from "./PositionView";
import { PageInfo } from "@/components/helpers/PageInfo";
import { fetchPositions } from "@/features/positions";
import { searchParamsSchema } from "./schema";
import { redirect } from "next/navigation";
import { validateSearchParams } from "@/lib/searchParams/validate";
import { getSearchParamsString } from "@/lib/searchParams/util";
import { PageInfo } from "@/components/PageInfo";
import { validateSearchParams } from "@/lib/searchParams/validate";
import { redirect } from "next/navigation";
import { PositionView } from "./PositionView";
import { searchParamsSchema } from "./schema";

export const dynamic = "force-dynamic";

Expand Down
18 changes: 9 additions & 9 deletions app/(authenticated)/admin/roles/RoleCard.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { RoleWithPermissions } from "@/features/people";
import type { FormResponse } from "@/components/forms";
import type { RoleWithPermissions } from "@/features/people";
import {
ActionIcon,
Card,
Stack,
Highlight,
Group,
ActionIcon,
Tooltip,
Highlight,
Stack,
Text,
Tooltip,
} from "@mantine/core";
import { FaEdit } from "react-icons/fa";
import { z } from "zod";
import { deleteRoleSchema } from "./schema";
import { FormResponse } from "@/components/Form";
import { modals } from "@mantine/modals";
import { notifications } from "@mantine/notifications";
import { FaEdit } from "react-icons/fa";
import { MdDeleteForever } from "react-icons/md";
import type { z } from "zod";
import type { deleteRoleSchema } from "./schema";

export function RoleCard(props: {
role: RoleWithPermissions;
Expand Down
36 changes: 18 additions & 18 deletions app/(authenticated)/admin/roles/RoleView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
"use client";

import { SearchBar } from "@/components/SearchBar";
import {
CountControls,
PageControls,
PaginationProvider,
} from "@/components/navigation/Pagination";
import type { RoleWithPermissions } from "@/features/people";
import { getSearchParamsString } from "@/lib/searchParams/util";
import { useValidSearchParams } from "@/lib/searchParams/validate";
import {
Button,
Center,
Expand All @@ -10,32 +19,22 @@ import {
Stack,
Text,
} from "@mantine/core";
import { usePathname, useSearchParams } from "next/navigation";
import { searchParamsSchema } from "./schema";
import { useRouter } from "next/navigation";
import { z } from "zod";
import { useEffect, useState } from "react";
import {
CountControls,
PageControls,
PaginationProvider,
} from "@/components/Pagination";
import { useDisclosure } from "@mantine/hooks";
import { SearchBar } from "@/components/SearchBar";
import { useValidSearchParams } from "@/lib/searchParams/validate";
import { getSearchParamsString } from "@/lib/searchParams/util";
import { RoleCard } from "./RoleCard";
import { CreateRoleForm, UpdateRoleForm } from "./form";
import { useQuery } from "@tanstack/react-query";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useEffect, useState } from "react";
import { FaPlus } from "react-icons/fa";
import { RoleWithPermissions } from "@/features/people";
import type { z } from "zod";
import { RoleCard } from "./RoleCard";
import {
createRoleAction,
deleteRoleAction,
fetchRolesAction,
TFetchRoles,
updateRoleAction,
type TFetchRoles,
} from "./actions";
import { useQuery } from "@tanstack/react-query";
import { CreateRoleForm, UpdateRoleForm } from "./form";
import { searchParamsSchema } from "./schema";

export function RoleView(props: { initialRoles: TFetchRoles }) {
const pathname = usePathname();
Expand Down Expand Up @@ -74,6 +73,7 @@ export function RoleView(props: { initialRoles: TFetchRoles }) {
) {
router.push(`${pathname}?${newSearchParamsString}`);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [searchParamsState]);

// States for modals
Expand Down
17 changes: 8 additions & 9 deletions app/(authenticated)/admin/roles/actions.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
"use server";

import { zodErrorResponse } from "@/components/FormServerHelpers";
import { zodErrorResponse, type FormResponse } from "@/components/forms";
import {
createRole,
deleteRole,
updateRole,
type RoleWithPermissions,
} from "@/features/people";
import { fetchRoles } from "@/features/roles";
import {
createRoleSchema,
deleteRoleSchema,
searchParamsSchema,
updateRoleSchema,
} from "./schema";
import { fetchRoles } from "@/features/roles";
import {
createRole,
deleteRole,
RoleWithPermissions,
updateRole,
} from "@/features/people";
import { FormResponse } from "@/components/Form";

export type TFetchRoles = {
roles: RoleWithPermissions[];
Expand Down
14 changes: 7 additions & 7 deletions app/(authenticated)/admin/roles/form.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Form, { FormResponse } from "@/components/Form";
import { createRoleSchema, updateRoleSchema } from "./schema";
import { z } from "zod";
import {
import Form, {
PermissionSelectField,
TextAreaField,
TextField,
} from "@/components/FormFields";
import { Permission } from "@/lib/auth/permissions";
type FormResponse,
} from "@/components/forms";
import type { RoleWithPermissions } from "@/features/people";
import type { Permission } from "@/lib/auth/permissions";
import { Space } from "@mantine/core";
import { RoleWithPermissions } from "@/features/people";
import type { z } from "zod";
import { createRoleSchema, updateRoleSchema } from "./schema";

export function CreateRoleForm(props: {
action: (data: z.infer<typeof createRoleSchema>) => Promise<FormResponse>;
Expand Down
Loading
Loading