-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Fernando Cremer
authored and
Fernando Cremer
committed
Jul 27, 2023
1 parent
a899cb0
commit 12534db
Showing
9 changed files
with
17,182 additions
and
1,437 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,5 +1,5 @@ | ||
{ | ||
"name": "Survey Plugin", | ||
"name": "Survey-Plugin", | ||
"version": "0.1.0", | ||
"license": "MIT", | ||
"dependencies": { | ||
|
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,48 @@ | ||
import React from "react"; | ||
import { Loader, usePluginContext } from "@cortexapps/plugin-core/components"; | ||
import "../baseStyles.css"; | ||
import { PluginContextLocation } from "@cortexapps/plugin-core"; | ||
|
||
// Update this with your default/Global Survey Form | ||
const defaultSurvey = | ||
"https://docs.google.com/forms/d/e/1FAIpQLSd068wYDvfxbhB75fTx-KM7aWb9gNiLLcnjA6SQ4ulT9SLgqA/viewform?embedded=true"; | ||
|
||
const Survey: React.FC = () => { | ||
const context = usePluginContext(); | ||
console.log(context); | ||
const [entitySurvey, setEntitySurvey] = React.useState<any | string>(); | ||
const [isLoading, setIsLoading] = React.useState( | ||
context.location === PluginContextLocation.Entity | ||
); | ||
React.useEffect(() => { | ||
if (context.location === PluginContextLocation.Entity) { | ||
const fetchData = async (): Promise<void> => { | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const cortexTag = context.entity!.tag; | ||
console.log(cortexTag); | ||
const cortexURL = context.apiBaseUrl; | ||
console.log(cortexURL); | ||
const result = await fetch( | ||
`${cortexURL}/catalog/${cortexTag}/custom-data/survey` | ||
); | ||
if (result.ok) { | ||
const resultJson = await result.json(); | ||
console.log({ resultJson }); | ||
console.log(defaultSurvey); | ||
setEntitySurvey(resultJson.value); | ||
} else { | ||
setEntitySurvey(defaultSurvey); | ||
} | ||
setIsLoading(false); | ||
}; | ||
void fetchData(); | ||
} | ||
}, []); | ||
|
||
return isLoading ? ( | ||
<Loader /> | ||
) : ( | ||
<iframe src={entitySurvey ?? defaultSurvey} height="2967px" /> | ||
); | ||
}; | ||
export default Survey; |
Oops, something went wrong.