generated from peeldao/next-juicebox-pages-router
-
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.
allow selection of nfts in pay project (#122)
### Description Allow the selection of NFTs in the pay project page [Screen Recording 2023-10-25 at 1.27.33 pm.mov](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/pinTSPPZHK80UCzWAYgo/2c5972e2-9594-4737-807c-4e028a7b7599.mov)
- Loading branch information
1 parent
490e3db
commit 154dd14
Showing
6 changed files
with
148 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react' | ||
import { | ||
ProjectPayAction, | ||
ProjectPayState, | ||
projectPayReducer, | ||
} from './projectPayReducer' | ||
|
||
export type ProjectPayContextType = ProjectPayState & { | ||
dispatch: React.Dispatch<ProjectPayAction> | ||
} | ||
|
||
export const ProjectPayContext = React.createContext<ProjectPayContextType>({ | ||
nftRewardIds: [], | ||
dispatch: () => { | ||
console.error('ProjectPayContext not initialized') | ||
}, | ||
}) | ||
|
||
export const useProjectPay = () => React.useContext(ProjectPayContext) |
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 @@ | ||
export type ProjectPayAction = | ||
| { type: 'addNftReward'; id: bigint } | ||
| { type: 'removeNftReward'; id: bigint } | ||
|
||
export type ProjectPayState = { | ||
nftRewardIds: bigint[] | ||
} | ||
|
||
export const projectPayReducer = ( | ||
state: ProjectPayState, | ||
action: ProjectPayAction, | ||
): ProjectPayState => { | ||
switch (action.type) { | ||
case 'addNftReward': | ||
return { | ||
...state, | ||
nftRewardIds: [...state.nftRewardIds, action.id], | ||
} | ||
case 'removeNftReward': | ||
return { | ||
...state, | ||
nftRewardIds: state.nftRewardIds.filter(id => id !== action.id), | ||
} | ||
default: | ||
return state | ||
} | ||
} |