mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-29 10:46:12 -06:00
fix: restricting archived attributes in the survey and segment editor (#4269)
Co-authored-by: Piyush Gupta <piyushguptaa2z123@gmail.com>
This commit is contained in:
@@ -48,7 +48,7 @@ const Page = async ({ params, searchParams }) => {
|
||||
getProductByEnvironmentId(params.environmentId),
|
||||
getEnvironment(params.environmentId),
|
||||
getActionClasses(params.environmentId),
|
||||
getAttributeClasses(params.environmentId),
|
||||
getAttributeClasses(params.environmentId, undefined, { skipArchived: true }),
|
||||
getResponseCountBySurveyId(params.surveyId),
|
||||
getOrganizationByEnvironmentId(params.environmentId),
|
||||
getServerSession(authOptions),
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useTranslations } from "next-intl";
|
||||
import { useMemo, useState } from "react";
|
||||
import { TAttributeClass } from "@formbricks/types/attribute-classes";
|
||||
import { TUserLocale } from "@formbricks/types/user";
|
||||
import { Label } from "@formbricks/ui/components/Label";
|
||||
import { Switch } from "@formbricks/ui/components/Switch";
|
||||
import { AttributeDetailModal } from "./AttributeDetailModal";
|
||||
import { AttributeClassDataRow } from "./AttributeRowData";
|
||||
@@ -49,8 +50,15 @@ export const AttributeClassesTable = ({
|
||||
{hasArchived && (
|
||||
<div className="my-4 flex items-center justify-end text-right">
|
||||
<div className="flex items-center text-sm font-medium">
|
||||
{t("environments.attributes.show_archived")}
|
||||
<Switch className="mx-3" checked={showArchived} onCheckedChange={toggleShowArchived} />
|
||||
<Label htmlFor="showArchivedToggle" className="cursor-pointer">
|
||||
{t("environments.attributes.show_archived")}
|
||||
</Label>
|
||||
<Switch
|
||||
id="showArchivedToggle"
|
||||
className="mx-3"
|
||||
checked={showArchived}
|
||||
onCheckedChange={toggleShowArchived}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -24,7 +24,7 @@ const Page = async ({ params }) => {
|
||||
const [environment, segments, attributeClasses, organization, product] = await Promise.all([
|
||||
getEnvironment(params.environmentId),
|
||||
getSegments(params.environmentId),
|
||||
getAttributeClasses(params.environmentId),
|
||||
getAttributeClasses(params.environmentId, undefined, { skipArchived: true }),
|
||||
getOrganizationByEnvironmentId(params.environmentId),
|
||||
getProductByEnvironmentId(params.environmentId),
|
||||
]);
|
||||
|
||||
@@ -32,7 +32,6 @@ export const ActionActivityTab = ({ actionClass, environmentId }: ActivityTabPro
|
||||
const getActiveInactiveSurveysResponse = await getActiveInactiveSurveysAction({
|
||||
actionClassId: actionClass.id,
|
||||
});
|
||||
console.log(getActiveInactiveSurveysResponse, "randike");
|
||||
if (getActiveInactiveSurveysResponse?.data) {
|
||||
setActiveSurveys(getActiveInactiveSurveysResponse.data.activeSurveys);
|
||||
setInactiveSurveys(getActiveInactiveSurveysResponse.data.inactiveSurveys);
|
||||
|
||||
@@ -48,7 +48,11 @@ export const getAttributeClass = reactCache(
|
||||
);
|
||||
|
||||
export const getAttributeClasses = reactCache(
|
||||
async (environmentId: string, page?: number): Promise<TAttributeClass[]> =>
|
||||
async (
|
||||
environmentId: string,
|
||||
page?: number,
|
||||
options?: { skipArchived: boolean }
|
||||
): Promise<TAttributeClass[]> =>
|
||||
cache(
|
||||
async () => {
|
||||
validateInputs([environmentId, ZId], [page, ZOptionalNumber]);
|
||||
@@ -57,6 +61,7 @@ export const getAttributeClasses = reactCache(
|
||||
const attributeClasses = await prisma.attributeClass.findMany({
|
||||
where: {
|
||||
environmentId: environmentId,
|
||||
...(options?.skipArchived ? { archived: false } : {}),
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
|
||||
Reference in New Issue
Block a user