-
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.
feat: update exports, fix a bug with authentication and switchorg and…
… update docs (#109) ## Description <!-- Write and explain of the changes introduced by this PR for the reviewers to fully understand --> ## Screenshot <!-- Provide a screenshot or gif of the change to demonstrate it --> ## Test Plan <!-- Explain what you tested and why --> <!-- Have any questions? Check out the contributing doc for more -->
- Loading branch information
Showing
35 changed files
with
244 additions
and
221 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
16 changes: 0 additions & 16 deletions
16
documentation/docs/api/Types/AuthenticationContextValue.mdx
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
documentation/docs/api/Types/OrfiumProductsContextValue.mdx
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
documentation/docs/api/Types/OrganizationsContextValue.mdx
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
documentation/docs/api/Types/TopBarUtilitySectionContextValue.mdx
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
documentation/docs/api/Types/UseAuthenticationReturnValue.mdx
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,13 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
import Type from '../_type-definitions/UseAuthenticationReturnValue.md'; | ||
|
||
|
||
```ts | ||
import { type AuthenticationContextValue } from '@orfium/toolbox'; | ||
``` | ||
|
||
### Definition | ||
|
||
<Type /> |
13 changes: 13 additions & 0 deletions
13
documentation/docs/api/Types/UseOrfiumProductsReturnValue.mdx
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,13 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
import Type from '../_type-definitions/UseOrfiumProductsReturnValue.md'; | ||
|
||
|
||
```ts | ||
import { type OrfiumProductsContextValue } from '@orfium/toolbox'; | ||
``` | ||
|
||
### Definition | ||
|
||
<Type /> |
13 changes: 13 additions & 0 deletions
13
documentation/docs/api/Types/UseOrganizationsReturnValue.mdx
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,13 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
import Type from '../_type-definitions/UseOrganizationsReturnValue.md'; | ||
|
||
|
||
```ts | ||
import { type OrganizationsContextValue } from '@orfium/toolbox'; | ||
``` | ||
|
||
### Definition | ||
|
||
<Type /> |
1 change: 0 additions & 1 deletion
1
documentation/docs/api/_type-definitions/OrfiumProductsContextValue.md
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
documentation/docs/api/_type-definitions/TopBarUtilitySectionContextValue.md
This file was deleted.
Oops, something went wrong.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
documentation/docs/api/_type-definitions/UseOrfiumProductsReturnValue.md
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 @@ | ||
[`Product`](../Types/Product)`[] | null` |
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
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,8 +1,2 @@ | ||
export { | ||
type AuthenticationContextValue, | ||
type DecodedTokenResponse, | ||
type User, | ||
} from './authentication'; | ||
export { type OrfiumProductsContextValue, type Product } from './orfium-products'; | ||
export { type OrganizationsContextValue } from './organizations'; | ||
export { type TopBarUtilitySectionContextValue } from './top-bar-utility-section'; | ||
export { type DecodedTokenResponse, type User } from './authentication'; | ||
export { type Product } from './orfium-products'; |
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,51 @@ | ||
## Hook utilities usage examples | ||
|
||
### useSafeContext | ||
|
||
_Description:</br> Accepts two parameters a **react context instance**, and a ** string** that specifies the name of the context.<br />It will throw an exception if someone tries to use hook outside of provider._ | ||
|
||
```typescript jsx | ||
import { useSafeContext } from '@orfium/toolbox'; | ||
|
||
const CustomContext = React.createContext(null); | ||
|
||
export const useCustomContext = () => useSafeContext(CustomContext, 'CustomContext'); | ||
``` | ||
|
||
_Error log_ | ||
|
||
``` | ||
Error: useCustomContext must be used within a CustomContextProvider | ||
``` | ||
|
||
### useSafeDispatch | ||
|
||
_Description:</br> Accepts a **dispatch method** generated from a `useReducer` hook.<br />It will return an optimized and guarded dispatch callback which will be invoked only when the component is mounted._ | ||
|
||
```typescript jsx | ||
import { useSafeDispatch } from '@orfium/toolbox'; | ||
|
||
type State = Record<string, string> | null; | ||
type Action = { type: string; payload: boolean }; | ||
|
||
const init = (shouldInit: boolean) => ({ type: 'INIT', payload: shouldInit }); | ||
|
||
const reducer = (state: State, action: Dispatch<Action>) => { | ||
if (action.type === 'INIT') { | ||
return { ...state, init: action.payload }; | ||
} | ||
|
||
return state; | ||
}; | ||
|
||
export const Component = () => { | ||
const [state, dispatch] = useReducer<typeof reducer>(reducer, null); | ||
const safeDispatch = useSafeDispatch<Action>(dispatch); | ||
|
||
const onClick = () => { | ||
safeDispatch(init(true)); | ||
}; | ||
|
||
return <button onClick={onClick}>init state</button>; | ||
}; | ||
``` |
Oops, something went wrong.