fix: survey overview is throwing a server-side error (#2638)

This commit is contained in:
Piyush Gupta
2024-05-17 12:32:40 +05:30
committed by GitHub
parent 084307bdb2
commit c2fbb20787
3 changed files with 17 additions and 17 deletions

View File

@@ -78,7 +78,7 @@ export const MainNavigation = ({
const [currentTeamId, setCurrentTeamId] = useState("");
const [showAddProductModal, setShowAddProductModal] = useState(false);
const [showCreateTeamModal, setShowCreateTeamModal] = useState(false);
const [isCollapsed, setIsCollapsed] = useState(localStorage.getItem("isMainNavCollapsed") === "true");
const [isCollapsed, setIsCollapsed] = useState(true);
const [isTextVisible, setIsTextVisible] = useState(true);
const product = products.find((product) => product.id === environment.productId);
@@ -90,6 +90,11 @@ export const MainNavigation = ({
localStorage.setItem("isMainNavCollapsed", isCollapsed ? "false" : "true");
};
useEffect(() => {
const isCollapsedValueFromLocalStorage = localStorage.getItem("isMainNavCollapsed") === "true";
setIsCollapsed(isCollapsedValueFromLocalStorage);
}, []);
useEffect(() => {
const toggleTextOpacity = () => {
setIsTextVisible(isCollapsed ? true : false);

View File

@@ -82,14 +82,11 @@ export const Onboarding = ({
}, [iframeVisible, currentStep]); // Depend on iframeVisible and currentStep to re-evaluate when needed
useEffect(() => {
if (typeof window !== "undefined") {
// Access localStorage only when window is available
const pathwayValueFromLocalStorage = localStorage.getItem("onboardingPathway");
const currentStepValueFromLocalStorage = parseInt(localStorage.getItem("onboardingCurrentStep") ?? "1");
const pathwayValueFromLocalStorage = localStorage.getItem("onboardingPathway");
const currentStepValueFromLocalStorage = parseInt(localStorage.getItem("onboardingCurrentStep") ?? "1");
setSelectedPathway(pathwayValueFromLocalStorage);
setCurrentStep(currentStepValueFromLocalStorage);
}
setSelectedPathway(pathwayValueFromLocalStorage);
setCurrentStep(currentStepValueFromLocalStorage);
}, []);
useEffect(() => {

View File

@@ -23,17 +23,15 @@ export const SurveyInline = (props: Omit<SurveyInlineProps, "containerId">) => {
useEffect(() => {
const loadScript = async () => {
if (typeof window !== "undefined") {
if (!window.formbricksSurveys) {
try {
await loadSurveyScript();
renderInline();
} catch (error) {
console.error("Failed to load the surveys package: ", error);
}
} else {
if (!window.formbricksSurveys) {
try {
await loadSurveyScript();
renderInline();
} catch (error) {
console.error("Failed to load the surveys package: ", error);
}
} else {
renderInline();
}
};