Files
formbricks-formbricks/apps/web/components/shared/SurveyStatusIndicator.tsx
Shubham Palriwala 13afba7615 feat: move env vars from build-time to run-time to better support self-hosting environments (#789)
* feat: privacy, imprint, and terms URL env vars now do not need rebuilding

* feat: disable_singup env var now do not need rebuilding

* feat: password_reset_disabled env var now do not need rebuilding

* feat: email_verification_disabled env var now do not need rebuilding

* feat: github_oauth & google_oauth env var now do not need rebuilding

* feat: move logic of env vars to serverside and send boolean client-side

* feat: invite_disabled env var now do not need rebuilding

* feat: rename vars logically

* feat: migration guide

* feat: update docker-compose as per v1.1

* deprecate: unused NEXT_PUBLIC_VERCEL_URL & VERCEL_URL

* deprecate: unused RAILWAY_STATIC_URL

* deprecate: unused RENDER_EXTERNAL_URL

* deprecate: unused HEROKU_APP_NAME

* fix: define WEBAPP_URL & replace NEXT_WEBAPP_URL with it

* migrate: NEXT_PUBLIC_IS_FORMBRICKS_CLOUD to IS_FORMBRICKS_CLOUD

* chore: move all env parsing to a constants.ts from page files

* feat: migrate client side envs to server side

* redo: isFormbricksCloud to navbar serverside page

* fix: constants is now a server only file

* fix: removal of use swr underway

* fix: move 1 tag away from swr to service

* feat: move away from tags swr

* feat: move away from surveys  swr

* feat: move away from eventClass swr

* feat: move away from event swr

* fix: make constants server-only

* remove comments from .env.example, use constants in MetaInformation

* clean up services

* rename tag function

* fix build error

* fix smaller bugs, fix Response % not working in summary

---------

Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
2023-09-30 21:40:59 +02:00

106 lines
4.2 KiB
TypeScript

"use client";
import { TEnvironment } from "@formbricks/types/v1/environment";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@formbricks/ui";
import { ArchiveBoxIcon, CheckIcon, PauseIcon } from "@heroicons/react/24/solid";
interface SurveyStatusIndicatorProps {
status: string;
tooltip?: boolean;
environment: TEnvironment;
}
export default function SurveyStatusIndicator({ status, tooltip, environment }: SurveyStatusIndicatorProps) {
if (!environment.widgetSetupCompleted) return null;
if (tooltip) {
return (
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
{status === "inProgress" && (
<span className="relative flex h-3 w-3">
<span className="animate-ping-slow absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"></span>
<span className="relative inline-flex h-3 w-3 rounded-full bg-green-500"></span>
</span>
)}
{status === "paused" && (
<div className=" rounded-full bg-slate-300 p-1">
<PauseIcon className="h-3 w-3 text-slate-600" />
</div>
)}
{status === "completed" && (
<div className=" rounded-full bg-slate-200 p-1">
<CheckIcon className="h-3 w-3 text-slate-600" />
</div>
)}
{status === "archived" && (
<div className=" rounded-full bg-slate-300 p-1">
<ArchiveBoxIcon className="h-3 w-3 text-slate-600" />
</div>
)}
</TooltipTrigger>
<TooltipContent>
<div className="flex items-center space-x-2">
{status === "inProgress" ? (
<>
<span>Gathering responses</span>
<span className="relative flex h-3 w-3">
<span className="animate-ping-slow absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"></span>
<span className="relative inline-flex h-3 w-3 rounded-full bg-green-500"></span>
</span>
</>
) : status === "paused" ? (
<>
<span className="text-slate-800">Survey paused.</span>
<div className=" rounded-full bg-slate-300 p-1">
<PauseIcon className="h-3 w-3 text-slate-600" />
</div>
</>
) : status === "completed" ? (
<div className="flex items-center space-x-2">
<span>Survey completed.</span>
<div className=" rounded-full bg-slate-200 p-1">
<CheckIcon className="h-3 w-3 text-slate-600" />
</div>
</div>
) : status === "archived" ? (
<div className="flex items-center space-x-2">
<span>Survey archived.</span>
<div className=" rounded-full bg-slate-300 p-1">
<ArchiveBoxIcon className="h-3 w-3 text-slate-600" />
</div>
</div>
) : null}
</div>
</TooltipContent>
</Tooltip>
</TooltipProvider>
);
} else
return (
<span>
{status === "inProgress" && (
<span className="relative flex h-3 w-3">
<span className="animate-ping-slow absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"></span>
<span className="relative inline-flex h-3 w-3 rounded-full bg-green-500"></span>
</span>
)}
{status === "paused" && (
<div className=" rounded-full bg-slate-300 p-1">
<PauseIcon className="h-3 w-3 text-slate-600" />
</div>
)}
{status === "completed" && (
<div className=" rounded-full bg-slate-200 p-1">
<CheckIcon className="h-3 w-3 text-slate-600" />
</div>
)}
{status === "archived" && (
<div className=" rounded-full bg-slate-300 p-1">
<ArchiveBoxIcon className="h-3 w-3 text-slate-600" />
</div>
)}
</span>
);
}