8000 chore: refactoring (#184) by BryanBerger98 · Pull Request #185 · BryanBerger98/lodge-v2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore: refactoring (#184) #185

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

Merged
merged 1 commit into from
Aug 8, 2023 8000
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
< 8000 /div>
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# [1.9.0](https://github.com/BryanBerger98/lodge-v2/compare/v1.8.0...v1.9.0) (2023-08-07)


### Bug Fixes

* **auth:** fix providers auth button display ([0ed2313](https://github.com/BryanBerger98/lodge-v2/commit/0ed2313364650240b483ff7027e14e991a6cb3c0))


### Features

* **auth:** google authentication ([#181](https://github.com/BryanBerger98/lodge-v2/issues/181)) ([afe2326](https://github.com/BryanBerger98/lodge-v2/commit/afe2326f398060a221657b3662ff0d5f41596150))

# [1.8.0](https://github.com/BryanBerger98/lodge-v2/compare/v1.7.0...v1.8.0) (2023-08-02)


Expand Down
4 changes: 2 additions & 2 deletions app/(app)/account/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import dynamic from 'next/dynamic';
import { headers } from 'next/headers';
import Link from 'next/link';

import PageTitle from '@/components/layout/PageTitle';
import PageTitle from '@/components/layout/Header/PageTitle';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { findSettingByName } from '@/database/setting/setting.repository';
import { getCsrfToken } from '@/lib/csrf';
import { connectToDatabase } from '@/lib/database';
import { setServerAuthGuard } from '@/utils/auth';
import { getCsrfToken } from '@/utils/csrf.util';
import { PASSWORD_LOWERCASE_MIN_SETTING, PASSWORD_MIN_LENGTH_SETTING, PASSWORD_NUMBERS_MIN_SETTING, PASSWORD_SYMBOLS_MIN_SETTING, PASSWORD_UNIQUE_CHARS_SETTING, PASSWORD_UPPERCASE_MIN_SETTING, USER_ACCOUNT_DELETION_SETTING } from '@/utils/settings';

const DynamicSignOutButton = dynamic(() => import('./_components/SignOutButton'), { ssr: false });
Expand Down
2 changes: 1 addition & 1 deletion app/(app)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { redirect } from 'next/navigation';
import { getServerSession } from 'next-auth';
import { ReactNode } from 'react';

import HeaderProvider from '@/context/layout/header';
import HeaderProvider from '@/components/layout/Header';
import { findSettingByName } from '@/database/setting/setting.repository';
import { findUserById } from '@/database/user/user.repository';
import authOptions from '@/lib/auth';
Expand Down
2 changes: 1 addition & 1 deletion app/(app)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Home } from 'lucide-react';

import PageTitle from '@/components/layout/PageTitle';
import PageTitle from '@/components/layout/Header/PageTitle';

const AppPage = () => {

Expand Down
2 changes: 1 addition & 1 deletion app/(app)/settings/access/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { default as nextDynamic } from 'next/dynamic';
import { headers } from 'next/headers';

import { findOwnerUser } from '@/database/user/user.repository';
import { getCsrfToken } from '@/lib/csrf';
import { connectToDatabase } from '@/lib/database';
import { getCsrfToken } from '@/utils/csrf.util';

const DynamicShareSettings = nextDynamic(() => import('../_components/ShareSettings'));

Expand Down
2 changes: 1 addition & 1 deletion app/(app)/settings/auth/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { KeyRound } from 'lucide-react';
import { default as nextDynamic } from 'next/dynamic';
import { headers } from 'next/headers';

import { getCsrfToken } from '@/utils/csrf.util';
import { getCsrfToken } from '@/lib/csrf';

const DynamicPasswordSettings = nextDynamic(() => import('../_components/AuthSettings/PasswordSettings'));
const DynamicProvidersSettings = nextDynamic(() => import('../_components/AuthSettings/ProvidersSettings'));
Expand Down
4 changes: 2 additions & 2 deletions app/(app)/settings/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { headers } from 'next/headers';
import Link from 'next/link';
import { ReactNode } from 'react';

import PageTitle from '@/components/layout/PageTitle';
import PageTitle from '@/components/layout/Header/PageTitle';
import Tabs from '@/components/ui/Tabs';
import TabButton from '@/components/ui/Tabs/TabButton';
import TabsList from '@/components/ui/Tabs/TabsList';
import SettingsProvider from '@/context/settings';
import SettingsProvider from '@/context/settings/settings.provider';
import { findSettingByName } from '@/database/setting/setting.repository';
import { connectToDatabase } from '@/lib/database';
import { setServerAuthGuard } from '@/utils/auth';
Expand Down
15 changes: 15 additions & 0 deletions app/(app)/settings/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Loader2 } from 'lucide-react';

const SettingsLoading = () => {

return (
<div className="flex items-center h-full w-full">
<Loader2
className="animate-spin"
size="32"
/>
</div>
);
};

export default SettingsLoading;
2 changes: 1 addition & 1 deletion app/(app)/settings/users/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Users } from 'lucide-react';
import { default as nextDynamic } from 'next/dynamic';
import { headers } from 'next/headers';

import { getCsrfToken } from '@/utils/csrf.util';
import { getCsrfToken } from '@/lib/csrf';

const DynamicUsersSettings = nextDynamic(() => import('../_components/UsersManagementSettings'));

Expand Down
4 changes: 2 additions & 2 deletions app/(app)/users/_components/UsersDataTable/Menu.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import { Row } from '@tanstack/react-table';
import { BadgeCheck, KeyRound, Lock, MoreHorizontal, Trash, Unlock } from 'lucide-react';
import { Lock, MoreHorizontal, Trash, Unlock } from 'lucide-react';
import { signOut } from 'next-auth/react';
import { useState } from 'react';

Expand All @@ -13,7 +13,7 @@ import { useToast } from '@/components/ui/use-toast';
import useAuth from '@/context/auth/useAuth';
import useCsrf from '@/context/csrf/useCsrf';
import useUsers from '@/context/users/useUsers';
import { deleteMultipleUsers, deleteUser, sendResetPasswordTokenToUser, sendVerificationTokenToUser, updateMultipleUsers, updateUser } from '@/services/users.service';
import { deleteMultipleUsers, updateMultipleUsers } from '@/services/users.service';
import { ApiError, getErrorMessage } from '@/utils/error';

import { UserColumn } from './columns';
Expand Down
10 changes: 6 additions & 4 deletions app/(app)/users/_components/UsersDataTable/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { OnChangeFn, PaginationState, Row, SortingState } from '@tanstack/react-table';
import { Cell, OnChangeFn, PaginationState, Row, SortingState } from '@tanstack/react-table';
import { useRouter } from 'next/navigation';
import { useEffect, useState } from 'react';

Expand Down Expand Up @@ -47,8 +47,10 @@ const UsersDataTable = ({ csrfToken }: UsersDataTableProps) => {
const handleChangePagination: OnChangeFn<PaginationState> = setPagination;
const handleSelectRows = (rows: Row<UserColumn>[]) => setSelectedRows(rows);

const handleRowClick = (row: Row<UserColumn>) => {
router.push(`/users/edit/${ row.original.id }`);
const handleClickCell = (cell: Cell<UserColumn, unknown>) => {
if (cell.column.id !== 'actions' && cell.column.id F438 !== 'select') {
router.push(`/users/edit/${ cell.row.original.id }`);
}
};

return (
Expand All @@ -70,8 +72,8 @@ const UsersDataTable = ({ csrfToken }: UsersDataTableProps) => {
manualSorting
withCustomColumns
withSearch
handleClickCell }
handleChangePagination }
handleRowClick }
handleSearch }
handleSelectRows }
handleChangeSorting }
Expand Down
6 changes: 3 additions & 3 deletions app/(app)/users/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { ChevronLeft, UserPlus } from 'lucide-react';
import dynamic from 'next/dynamic';
import { headers } from 'next/headers';

import PageTitle from '@/components/layout/PageTitle';
import PageTitle from '@/components/layout/Header/PageTitle';
import BackButton from '@/components/ui/Button/BackButton';
import UsersProvider from '@/context/users';
import { getCsrfToken } from '@/utils/csrf.util';
import UsersProvider from '@/context/users/users.provider';
import { getCsrfToken } from '@/lib/csrf';


const DynamicEditUserForm = dynamic(() => import('../_components/EditUserForm'));
Expand Down
6 changes: 3 additions & 3 deletions app/(app)/users/edit/[userId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import dynamic from 'next/dynamic';
import { headers } from 'next/headers';
import { redirect } from 'next/navigation';

import PageTitle from '@/components/layout/PageTitle';
import PageTitle from '@/components/layout/Header/PageTitle';
import BackButton from '@/components/ui/Button/BackButton';
import UsersProvider from '@/context/users';
import UsersProvider from '@/context/users/users.provider';
import { findFileByKey } from '@/database/file/file.repository';
import { findUserById } from '@/database/user/user.repository';
import { getFileFromKey } from '@/lib/bucket';
import { getCsrfToken } from '@/lib/csrf';
import { Id } from '@/lib/database';
import { getCsrfToken } from '@/utils/csrf.util';


const DynamicEditUserForm = dynamic(() => import('../../_components/EditUserForm'));
Expand Down
6 changes: 3 additions & 3 deletions app/(app)/users/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import dynamic from 'next/dynamic';
import { headers } from 'next/headers';
import Link from 'next/link';

import PageTitle from '@/components/layout/PageTitle';
import PageTitle from '@/components/layout/Header/PageTitle';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import UsersProvider from '@/context/users';
import UsersProvider from '@/context/users/users.provider';
import { FetchUsersSchema } from '@/database/user/user.dto';
import { findUsers, findUsersCount } from '@/database/user/user.repository';
import { getCsrfToken } from '@/lib/csrf';
import { connectToDatabase } from '@/lib/database';
import { getCsrfToken } from '@/utils/csrf.util';

const DynamicUsersDataTable = dynamic(() => import('./_components/UsersDataTable'));

Expand Down
2 changes: 1 addition & 1 deletion app/(auth)/forgot-password/[token]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { headers } from 'next/headers';

import { findSettingByName } from '@/database/setting/setting.repository';
import { getCsrfToken } from '@/utils/csrf.util';
import { getCsrfToken } from '@/lib/csrf';
import { PASSWORD_LOWERCASE_MIN_SETTING, PASSWORD_MIN_LENGTH_SETTING, PASSWORD_NUMBERS_MIN_SETTING, PASSWORD_SYMBOLS_MIN_SETTING, PASSWORD_UNIQUE_CHARS_SETTING, PASSWORD_UPPERCASE_MIN_SETTING } from '@/utils/settings';

import ResetPasswordForm from '../_components/ResetPasswordForm';
Expand Down
2 changes: 1 addition & 1 deletion app/(auth)/forgot-password/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { headers } from 'next/headers';

import { getCsrfToken } from '@/utils/csrf.util';
import { getCsrfToken } from '@/lib/csrf';

import EmailForm from './_components/EmailForm';

Expand Down
2 changes: 1 addition & 1 deletion app/(auth)/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { headers } from 'next/headers';
import { redirect } from 'next/navigation';

import { findSettingByName } from '@/database/setting/setting.repository';
import { getCsrfToken } from '@/lib/csrf';
import { connectToDatabase } from '@/lib/database';
import { getCsrfToken } from '@/utils/csrf.util';
import { APPLE_AUTH_SETTING, GOOGLE_AUTH_SETTING, NEW_USERS_SIGNUP_SETTING, PASSWORD_LOWERCASE_MIN_SETTING, PASSWORD_MIN_LENGTH_SETTING, PASSWORD_NUMBERS_MIN_SETTING, PASSWORD_SYMBOLS_MIN_SETTING, PASSWORD_UNIQUE_CHARS_SETTING, PASSWORD_UPPERCASE_MIN_SETTING, USER_VERIFY_EMAIL_SETTING, findDefaultSettingByName } from '@/utils/settings';


Expand Down
2 changes: 1 addition & 1 deletion app/(auth)/verify-email/[token]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { redirect } from 'next/navigation';
import { getServerSession } from 'next-auth';

import authOptions from '@/lib/auth';
import { getCsrfToken } from '@/utils/csrf.util';
import { getCsrfToken } from '@/lib/csrf';

import ConfirmEmailCard from '../_components/ConfirmEmailCard';

Expand Down
2 changes: 1 addition & 1 deletion app/(auth)/verify-email/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { redirect } from 'next/navigation';
import { getServerSession } from 'next-auth';

import authOptions from '@/lib/auth';
import { getCsrfToken } from '@/utils/csrf.util';
import { getCsrfToken } from '@/lib/csrf';

import SendEmailConfirmationCard from './_components/SendEmailConfirmationCard';

Expand Down
4 changes: 2 additions & 2 deletions app/_components/Providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { SessionProvider } from 'next-auth/react';
import { ReactNode, useState } from 'react';

import RefreshTokenHandler from '@/components/utils/auth/RefetchTokenHandler';
import AuthProvider from '@/context/auth';
import CsrfProvider from '@/context/csrf';
import AuthProvider from '@/context/auth/auth.provider';
import CsrfProvider from '@/context/csrf/csrf.provider';

type ProvidersProps = {
children: ReactNode;
Expand Down
4 changes: 2 additions & 2 deletions app/api/auth/reset-password/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { findSettingByName } from '@/database/setting/setting.repository';
import { createToken, deleteTokenById, getTokenFromTargetId, getTokenFromTokenString } from '@/database/token/token.repository';
import { findUserByEmail, findUserById, updateUserPassword } from '@/database/user/user.repository';
import { connectToDatabase } from '@/lib/database';
import { generateToken, verifyToken } from '@/lib/jwt';
import { IToken } from '@/types/token.type';
import { Optional } from '@/types/utils.type';
import { Optional } from '@/types/utils';
import { sendResetPasswordEmail } from '@/utils/email';
import { buildError, sendError } from '@/utils/error';
import { INTERNAL_ERROR, INVALID_INPUT_ERROR, INVALID_TOKEN_ERROR, TOKEN_ALREADY_SENT_ERROR, TOKEN_NOT_FOUND_ERROR, USER_NOT_FOUND_ERROR } from '@/utils/error/error-codes';
import { getErrorMessageFromPasswordRules, getValidationRegexFromPasswordRules, hashPassword } from '@/utils/password.util';
import { PASSWORD_LOWERCASE_MIN_SETTING, PASSWORD_MIN_LENGTH_SETTING, PASSWORD_NUMBERS_MIN_SETTING, PASSWORD_SYMBOLS_MIN_SETTING, PASSWORD_UNIQUE_CHARS_SETTING, PASSWORD_UPPERCASE_MIN_SETTING } from '@/utils/settings';
import { generateToken, verifyToken } from '@/utils/token.util';

export const POST = async (request: NextRequest) => {

Expand Down
2 changes: 1 addition & 1 deletion app/api/auth/signup/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { createToken } from '@/database/token/token.repository';
import { SignUpUserSchema } from '@/database/user/user.dto';
import { createUser, findUserByEmail } from '@/database/user/user.repository';
import { connectToDatabase } from '@/lib/database';
import { generateToken } from '@/lib/jwt';
import { sendAccountVerificationEmail } from '@/utils/email';
import { buildError, sendError } from '@/utils/error';
import { FORBIDDEN_ERROR, INTERNAL_ERROR, INVALID_INPUT_ERROR, USER_ALREADY_EXISTS_ERROR } from '@/utils/error/error-codes';
import { getErrorMessageFromPasswordRules, getValidationRegexFromPasswordRules, hashPassword } from '@/utils/password.util';
import { NEW_USERS_SIGNUP_SETTING, PASSWORD_LOWERCASE_MIN_SETTING, PASSWORD_MIN_LENGTH_SETTING, PASSWORD_NUMBERS_MIN_SETTING, PASSWORD_SYMBOLS_MIN_SETTING, PASSWORD_UNIQUE_CHARS_SETTING, PASSWORD_UPPERCASE_MIN_SETTING } from '@/utils/settings';
import { generateToken } from '@/utils/token.util';

export const POST = async (request: NextRequest) => {

Expand Down
4 changes: 2 additions & 2 deletions app/api/auth/verify-email/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { findSettingByName } from '@/database/setting/setting.repository';
import { createToken, deleteTokenById, getTokenFromTargetId, getTokenFromTokenString } from '@/database/token/token.repository';
import { findUserByEmail, findUserById, updateUser } from '@/database/user/user.repository';
import { connectToDatabase } from '@/lib/database';
import { generateToken, verifyToken } from '@/lib/jwt';
import { IToken } from '@/types/token.type';
import { Optional } from '@/types/utils.type';
import { Optional } from '@/types/utils';
import { setServerAuthGuard } from '@/utils/auth';
import { sendAccountVerificationEmail } from '@/utils/email';
import { buildError, sendError } from '@/utils/error';
import { EMAIL_ALREADY_VERIFIED_ERROR, FORBIDDEN_ERROR, INTERNAL_ERROR, INVALID_TOKEN_ERROR, TOKEN_ALREADY_SENT_ERROR, TOKEN_EXPIRED_ERROR, TOKEN_NOT_FOUND_ERROR, USER_NOT_FOUND_ERROR } from '@/utils/error/error-codes';
import { USER_VERIFY_EMAIL_SETTING } from '@/utils/settings';
import { generateToken, verifyToken } from '@/utils/token.util';

export const GET = async () => {

Expand Down
4 changes: 2 additions & 2 deletions app/api/users/[userId]/reset-password/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { NextResponse } from 'next/server';
import { createToken, deleteTokenById, getTokenFromTargetId } from '@/database/token/token.repository';
import { findUserById } from '@/database/user/user.repository';
import { connectToDatabase } from '@/lib/database';
import { generateToken } from '@/lib/jwt';
import { IToken } from '@/types/token.type';
import { Optional } from '@/types/utils.type';
import { Optional } from '@/types/utils';
import { setServerAuthGuard } from '@/utils/auth';
import { sendResetPasswordEmail } from '@/utils/email';
import { buildError, sendError } from '@/utils/error';
import { INTERNAL_ERROR, INVALID_INPUT_ERROR, TOKEN_ALREADY_SENT_ERROR, USER_NOT_FOUND_ERROR } from '@/utils/error/error-codes';
import { generateToken } from '@/utils/token.util';

export const POST = async (_: any, { params }: { params: { userId: string } }) => {

Expand Down
4 changes: 2 additions & 2 deletions app/api/users/[userId]/verify-email/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { NextResponse } from 'next/server';
import { createToken, deleteTokenById, getTokenFromTargetId } from '@/database/token/token.repository';
import { findUserById } from '@/database/user/user.repository';
import { connectToDatabase } from '@/lib/database';
import { generateToken } from '@/lib/jwt';
import { IToken } from '@/types/token.type';
import { Optional } from '@/types/utils.type';
import { Optional } from '@/types/utils';
import { setServerAuthGuard } from '@/utils/auth';
import { sendAccountVerificationEmail } from '@/utils/email';
import { buildError, sendError } from '@/utils/error';
import { EMAIL_ALREADY_VERIFIED_ERROR, INTERNAL_ERROR, INVALID_INPUT_ERROR, TOKEN_ALREADY_SENT_ERROR, USER_NOT_FOUND_ERROR } from '@/utils/error/error-codes';
import { generateToken } from '@/utils/token.util';

export const POST = async (_: any, { params }: { params: { userId: string } }) => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import { HTMLAttributes, RefAttributes, useEffect } from 'react';

import { ButtonProps } from '@/components/ui/button';
import useHeader from '@/context/layout/header/useHeader';

import useHeader from './useHeader';

type PageTitleProps = HTMLAttributes<HTMLHeadingElement> & {
headerButton?: ButtonProps & RefAttributes<HTMLButtonElement>;
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions components/layout/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import { usePathname } from 'next/navigation';
import { useEffect, useState } from 'react';

import CurrentUserAvatar from '@/components/features/users/CurrentUserAvatar';
import HeaderButton from '@/components/layout/Header/HeaderButton';
import { Badge } from '@/components/ui/badge';
import useAuth from '@/context/auth/useAuth';
import HeaderButton from '@/context/layout/header/HeaderButton';
import useHeader from '@/context/layout/header/useHeader';
import useBreakPoint from '@/hooks/utils/useBreakPoint';
import { isProductionEnv } from '@/utils/env.util';
import { SETTINGS_ACTIONS } from '@/utils/roles/settings.permissions';
import { USERS_ACTIONS } from '@/utils/roles/users.permissions';

import { Button } from '../../ui/button';
import useHeader from '../Header/useHeader';


type SidebarProps = {
Expand Down
Loading
0