-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial setup for headless (#385)
* feat: define headless setup * fix: define expected param * fix: use import for type in index.d.ts (#399) Co-authored-by: Micah Thomas <micah.thomas@bigcommerce.com> --------- Co-authored-by: Micah Thomas <micah.thomas@bigcommerce.com>
- Loading branch information
1 parent
37fb86f
commit 457c75f
Showing
12 changed files
with
1,602 additions
and
1,447 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Dispatch, SetStateAction, useEffect } from 'react' | ||
import type { OpenPageState } from '@b3/hooks' | ||
|
||
import { HeadlessRoutes } from '@/constants' | ||
|
||
interface HeadlessControllerProps { | ||
setOpenPage: Dispatch<SetStateAction<OpenPageState>> | ||
} | ||
|
||
export default function HeadlessController({ | ||
setOpenPage, | ||
}: HeadlessControllerProps) { | ||
useEffect(() => { | ||
window.b2b = { | ||
utils: { | ||
openPage: (page) => { | ||
setOpenPage({ isOpen: false }) | ||
setTimeout( | ||
() => setOpenPage({ isOpen: true, openUrl: HeadlessRoutes[page] }), | ||
0 | ||
) | ||
}, | ||
}, | ||
} | ||
}, []) | ||
return null | ||
} |
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
Oops, something went wrong.