-
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.
Merge pull request #5 from arayavalencia96/feature/MEMO-5-several-cor…
…rections Feature/memo 5 several corrections
- Loading branch information
Showing
8 changed files
with
153 additions
and
43 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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { type Note } from "@prisma/client"; | ||
import React, { createContext, useContext, useState } from "react"; | ||
|
||
const InitialValues: Note = { | ||
content: '', | ||
createdAt: new Date(), | ||
id: '', | ||
title: '', | ||
topicId: '', | ||
updatedAt: new Date(), | ||
}; | ||
|
||
interface SelectedNoteContextType { | ||
selectedNote: Note | null; | ||
setSelectedNote: (note: Note | null) => void; | ||
isEdit: boolean | null; | ||
setIsEdit: (set: boolean | null) => void; | ||
} | ||
|
||
const SelectedNoteContext = createContext< | ||
SelectedNoteContextType | undefined | ||
>(undefined); | ||
|
||
export const SelectedNoteProvider: React.FC<{ children: React.ReactNode }> = ({ | ||
children, | ||
}) => { | ||
const [selectedNote, setSelectedNote] = useState<Note | null>(InitialValues); | ||
const [isEdit, setIsEdit] = useState<boolean | null>(false); | ||
|
||
return ( | ||
<SelectedNoteContext.Provider | ||
value={{ | ||
selectedNote, | ||
setSelectedNote, | ||
isEdit, | ||
setIsEdit, | ||
}} | ||
> | ||
{children} | ||
</SelectedNoteContext.Provider> | ||
); | ||
}; | ||
|
||
export const useSelectedNote = () => { | ||
const context = useContext(SelectedNoteContext); | ||
if (context === undefined) { | ||
throw new Error( | ||
"useSelectedNote must be used within a SelectedNoteProvider" | ||
); | ||
} | ||
return context; | ||
}; |
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 |
---|---|---|
|
@@ -15,4 +15,12 @@ | |
.min-h { | ||
min-height: 45vh; | ||
} | ||
|
||
.widthMobile { | ||
width: 100%; | ||
} | ||
|
||
.flexWrow { | ||
flex-grow: 1; | ||
} | ||
} |