diff --git a/apps/web/app/(app)/environments/[environmentId]/settings/lookandfeel/components/EditLogo.tsx b/apps/web/app/(app)/environments/[environmentId]/settings/lookandfeel/components/EditLogo.tsx index 5c00fba31c..a203aec1df 100644 --- a/apps/web/app/(app)/environments/[environmentId]/settings/lookandfeel/components/EditLogo.tsx +++ b/apps/web/app/(app)/environments/[environmentId]/settings/lookandfeel/components/EditLogo.tsx @@ -9,6 +9,7 @@ import { TProduct, TProductUpdateInput } from "@formbricks/types/product"; import { AdvancedOptionToggle } from "@formbricks/ui/AdvancedOptionToggle"; import { Button } from "@formbricks/ui/Button"; import { ColorPicker } from "@formbricks/ui/ColorPicker"; +import { DeleteDialog } from "@formbricks/ui/DeleteDialog"; import { FileInput } from "@formbricks/ui/FileInput"; import { Input } from "@formbricks/ui/Input"; @@ -24,6 +25,7 @@ export const EditLogo = ({ product, environmentId, isViewer }: EditLogoProps) => const [logoUrl, setLogoUrl] = useState(product.logo?.url || undefined); const [logoBgColor, setLogoBgColor] = useState(product.logo?.bgColor || undefined); const [isBgColorEnabled, setIsBgColorEnabled] = useState(!!product.logo?.bgColor); + const [confirmRemoveLogoModalOpen, setConfirmRemoveLogoModalOpen] = useState(false); const [isLoading, setIsLoading] = useState(false); const [isEditing, setIsEditing] = useState(false); const fileInputRef = useRef(null); @@ -58,7 +60,7 @@ export const EditLogo = ({ product, environmentId, isViewer }: EditLogoProps) => setIsLoading(true); try { - const updatedProduct: Partial = { + const updatedProduct: TProductUpdateInput = { logo: { url: logoUrl, bgColor: isBgColorEnabled ? logoBgColor : undefined }, }; await updateProductAction(product.id, updatedProduct); @@ -72,26 +74,25 @@ export const EditLogo = ({ product, environmentId, isViewer }: EditLogoProps) => }; const removeLogo = async () => { - if (window.confirm("Are you sure you want to remove the logo?")) { - setLogoUrl(undefined); - if (!isEditing) { - setIsEditing(true); - return; - } + setLogoUrl(undefined); + if (!isEditing) { + setIsEditing(true); + return; + } - setIsLoading(true); - try { - const updatedProduct: Partial = { - logo: { url: undefined, bgColor: undefined }, - }; - await updateProductAction(product.id, updatedProduct); - toast.success("Logo removed successfully", { icon: "🗑️" }); - } catch (error) { - toast.error("Failed to remove the logo"); - } finally { - setIsEditing(false); - setIsLoading(false); - } + setIsLoading(true); + try { + const updatedProduct: TProductUpdateInput = { + logo: { url: undefined, bgColor: undefined }, + }; + await updateProductAction(product.id, updatedProduct); + toast.success("Logo removed successfully", { icon: "🗑️" }); + } catch (error) { + toast.error("Failed to remove the logo"); + } finally { + setIsEditing(false); + setIsLoading(false); + setConfirmRemoveLogoModalOpen(false); } }; @@ -105,7 +106,7 @@ export const EditLogo = ({ product, environmentId, isViewer }: EditLogoProps) => }; return ( -
+ @@ -164,6 +169,13 @@ export const EditLogo = ({ product, environmentId, isViewer }: EditLogoProps) => {isEditing ? "Save" : "Edit"} )} +
); }; diff --git a/apps/web/app/(app)/environments/[environmentId]/settings/lookandfeel/components/ThemeStylingPreviewSurvey.tsx b/apps/web/app/(app)/environments/[environmentId]/settings/lookandfeel/components/ThemeStylingPreviewSurvey.tsx index 9a1d218bbf..0e3b2c2e48 100644 --- a/apps/web/app/(app)/environments/[environmentId]/settings/lookandfeel/components/ThemeStylingPreviewSurvey.tsx +++ b/apps/web/app/(app)/environments/[environmentId]/settings/lookandfeel/components/ThemeStylingPreviewSurvey.tsx @@ -113,6 +113,13 @@ export const ThemeStylingPreviewSurvey = ({ const isAppSurvey = previewType === "app" || previewType === "website"; + const scrollToEditLogoSection = () => { + const editLogoSection = document.getElementById("edit-logo"); + if (editLogoSection) { + editLogoSection.scrollIntoView({ behavior: "smooth" }); + } + }; + return (
) : ( - {!product.styling?.isLogoHidden && product.logo?.url && ( -
+ {!product.styling?.isLogoHidden && ( +
)} diff --git a/apps/web/app/(app)/environments/[environmentId]/surveys/components/PreviewSurvey.tsx b/apps/web/app/(app)/environments/[environmentId]/surveys/components/PreviewSurvey.tsx index 259a805e67..5e6d643ef9 100644 --- a/apps/web/app/(app)/environments/[environmentId]/surveys/components/PreviewSurvey.tsx +++ b/apps/web/app/(app)/environments/[environmentId]/surveys/components/PreviewSurvey.tsx @@ -262,7 +262,7 @@ export const PreviewSurvey = ({ ) : (
- {!styling.isLogoHidden && product.logo?.url && ( + {!styling.isLogoHidden && ( )}
@@ -348,7 +348,7 @@ export const PreviewSurvey = ({ ) : (
- {!styling.isLogoHidden && product.logo?.url && ( + {!styling.isLogoHidden && ( )}
diff --git a/packages/ui/ClientLogo/index.tsx b/packages/ui/ClientLogo/index.tsx index 2e765ac344..be974983c5 100644 --- a/packages/ui/ClientLogo/index.tsx +++ b/packages/ui/ClientLogo/index.tsx @@ -16,7 +16,7 @@ interface ClientLogoProps { export const ClientLogo = ({ environmentId, product, previewSurvey = false }: ClientLogoProps) => { return (
{previewSurvey && environmentId && ( { + if (!environmentId) { + e.preventDefault(); + } + }} className="whitespace-nowrap rounded-md border border-dashed border-slate-400 bg-slate-200 px-6 py-3 text-xs text-slate-900 opacity-50 backdrop-blur-sm hover:cursor-pointer hover:border-slate-600" target="_blank"> Add logo