generated from vtex-apps/react-app-template
-
Notifications
You must be signed in to change notification settings - Fork 19
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 #173 from EmanuelRamos115/feat/add-to-cart-prop
Feat/add to cart prop
- Loading branch information
Showing
10 changed files
with
84 additions
and
21 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
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,6 @@ | ||
query getSettings($version: String!) { | ||
publicSettingsForApp(app: "vtex.quickorder", version: $version) | ||
@context(provider: "vtex.apps-graphql") { | ||
message | ||
} | ||
} |
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,41 @@ | ||
import { useQuery } from 'react-apollo' | ||
import { useEffect, useState } from 'react' | ||
/* eslint-disable no-restricted-imports */ | ||
import { pathOr } from 'ramda' | ||
|
||
import AppSettings from '../queries/getSettings.gql' | ||
|
||
const useAppSettings = () => { | ||
const { data: appSettingsData } = useQuery(AppSettings, { | ||
variables: { | ||
version: process.env.VTEX_APP_VERSION, | ||
}, | ||
ssr: false, | ||
}) | ||
|
||
const [appSettings, setAppSettings] = useState({ | ||
checkoutUrl: '/checkout#/cart', | ||
}) | ||
|
||
useEffect(() => { | ||
if (appSettingsData) { | ||
const settingsString = pathOr( | ||
`""`, | ||
['publicSettingsForApp', 'message'], | ||
appSettingsData | ||
) | ||
|
||
try { | ||
const parsedAppSettings = JSON.parse(settingsString) | ||
|
||
setAppSettings(parsedAppSettings) | ||
} catch (error) { | ||
console.error('Error parsing app settings:', error) | ||
} | ||
} | ||
}, [appSettingsData]) | ||
|
||
return appSettings | ||
} | ||
|
||
export default useAppSettings |