-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] refactor/http-requests-and-add-context (#97)
- Loading branch information
1 parent
1f20c0d
commit 405baa0
Showing
55 changed files
with
471 additions
and
454 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use client'; | ||
import React from 'react'; | ||
import { useRouter } from 'next/navigation'; | ||
|
||
const UnauthorizedPage = () => { | ||
const router = useRouter(); | ||
const handleGoBack = () => { | ||
router.push('/dashboard'); | ||
}; | ||
|
||
return ( | ||
<div className='flex min-h-screen flex-col items-center justify-center'> | ||
<div className='rounded-lg p-8 text-center shadow-lg'> | ||
<h1 className='mb-4 text-4xl font-bold text-red-600'>Acceso No Autorizado</h1> | ||
<p className='mb-6 text-xl text-gray-700'>Lo sentimos, no tienes permiso para acceder a esta página.</p> | ||
<button | ||
onClick={handleGoBack} | ||
className='rounded bg-blue-500 px-6 py-2 text-white transition-colors hover:bg-blue-600' | ||
> | ||
Volver | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default UnauthorizedPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use client'; | ||
|
||
import React, { createContext, useState, useContext } from 'react'; | ||
import { StaticImageData } from 'next/image'; | ||
|
||
import { images } from '@/features/shared/hooks/images'; | ||
|
||
interface UserContextType { | ||
avatar: StaticImageData | string; | ||
handleSetAvatar: (avatar: string) => void; | ||
} | ||
|
||
const UserContext = createContext<UserContextType | undefined>(undefined); | ||
|
||
export function UserProvider({ children }: { children: React.ReactNode }) { | ||
const { Avatar } = images(); | ||
const [avatar, setUserAvatar] = useState<StaticImageData | string>(Avatar); | ||
|
||
const handleSetAvatar = (avatar: string): void => { | ||
setUserAvatar(avatar); | ||
}; | ||
|
||
return <UserContext.Provider value={{ avatar, handleSetAvatar }}>{children}</UserContext.Provider>; | ||
} | ||
|
||
export function useContextUser() { | ||
const context = useContext(UserContext); | ||
|
||
if (!context) throw new Error('Context not defined'); | ||
|
||
return context; | ||
} |
4 changes: 2 additions & 2 deletions
4
src/features/auth/forgot-password/actions/forgotPasswordAction.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { InitialPaginationParams } from '@/features/shared/interfaces/InitialPaginationParams'; | ||
|
||
export const paginationInitialParams: InitialPaginationParams = { | ||
limit: '5', | ||
limit: '6', | ||
offset: '0', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
import React from 'react'; | ||
|
||
import { NavbarTop } from '@/features/navbar/organisms/NavbarTop'; | ||
import { fetchUser } from '@/features/shared/actions/fetchUsers'; | ||
import { handleGetFile } from '@/features/shared/actions/fileActions'; | ||
import { fetchUser } from '@/features/shared/actions/userActions'; | ||
|
||
type Props = { | ||
isPublic: boolean; | ||
}; | ||
|
||
export const NavbarTopTemplate = async (props: Props) => { | ||
const user = props.isPublic ? undefined : await fetchUser(); | ||
|
||
if (user) { | ||
const metadata = await handleGetFile(user.user_id.image_id); | ||
user.user_id.image_id = metadata.path; | ||
} | ||
|
||
return <NavbarTop isPublic={props.isPublic} user={user} />; | ||
}; |
Oops, something went wrong.