Merge branch 'main' of github.com:formbricks/formbricks

This commit is contained in:
Johannes
2023-04-12 12:15:28 +02:00
6 changed files with 17 additions and 54 deletions

View File

@@ -55,6 +55,7 @@ interface EnvironmentsNavbarProps {
export default function EnvironmentsNavbar({ environmentId, session }: EnvironmentsNavbarProps) {
const router = useRouter();
const [loading, setLoading] = useState(false);
const { environment, isErrorEnvironment, isLoadingEnvironment } = useEnvironment(environmentId);
const pathname = usePathname();
@@ -180,7 +181,7 @@ export default function EnvironmentsNavbar({ environmentId, session }: Environme
router.push(`/environments/${newEnvironmentId}/`);
};
if (isLoadingEnvironment) {
if (isLoadingEnvironment || loading) {
return <LoadingSpinner />;
}
@@ -328,12 +329,9 @@ export default function EnvironmentsNavbar({ environmentId, session }: Environme
<div className="flex items-center">
<ArrowRightOnRectangleIcon className="mr-2 h-4 w-4" />
<button
onClick={async () => {
try {
await signOut();
} catch (error) {
console.error("Failed to sign out:", error);
}
onClick={() => {
signOut();
setLoading(true);
}}>
Logout
</button>

View File

@@ -19,10 +19,10 @@ const AddEmailAlertModal: React.FC<AddEmailAlertModalProps> = ({ open, setOpen }
];
const onTest = () => {
console.log("Test button clicked!");
throw Error("not implemented");
};
const onSave = () => {
console.log("Save button clicked!");
throw Error("not implemented");
};
return (

View File

@@ -33,7 +33,5 @@ export default function ApiKeyList({
const environmentTypeId = findEnvironmentByType(product?.environments, environmentType);
console.log(environmentTypeId);
return <EditApiKeys environmentTypeId={environmentTypeId} environmentType={environmentType} />;
}

View File

@@ -80,7 +80,7 @@ export default function RecontactOptionsCard({
)}>
<Collapsible.CollapsibleTrigger asChild className="h-full w-full cursor-pointer">
<div className="inline-flex px-4 py-6">
<div className="flex items-center pr-5 pl-2">
<div className="flex items-center pl-2 pr-5">
<CheckCircleIcon className="h-8 w-8 text-green-400" />
</div>
<div>
@@ -173,7 +173,7 @@ export default function RecontactOptionsCard({
htmlFor="newDays"
className="flex w-full cursor-pointer items-center rounded-lg border bg-slate-50 p-4">
<RadioGroupItem
value={inputDays.toString()}
value={inputDays === 0 ? "1" : inputDays.toString()} //Fixes that both radio buttons are checked when inputDays is 0
id="newDays"
className="aria-checked:border-brand-dark mx-5 disabled:border-slate-400 aria-checked:border-2"
/>
@@ -184,7 +184,7 @@ export default function RecontactOptionsCard({
type="number"
min="1"
id="inputDays"
value={inputDays}
value={inputDays === 0 ? 1 : inputDays}
onChange={handleRecontactDaysChange}
className="ml-2 mr-2 inline w-16 text-center text-sm"
/>
@@ -192,7 +192,7 @@ export default function RecontactOptionsCard({
</p>
<p className="mt-2 text-xs font-normal text-slate-600">
Overwrites waiting period between surveys to {inputDays} day(s).
Overwrites waiting period between surveys to {inputDays === 0 ? 1 : inputDays} day(s).
</p>
</div>
</label>

View File

@@ -94,7 +94,7 @@ export default async function handle(req: NextApiRequest, res: NextApiResponse)
const events = [
...displays.map((display) => ({
name: "formbricks_display_created",
name: "formbricks_survey_displayed",
timestamp: display.createdAt,
userId: display.person?.attributes?.find((attr) => attr.attributeClass.name === "userId")?.value,
})),

View File

@@ -24,6 +24,8 @@ export default async function handle(req: NextApiRequest, res: NextApiResponse)
// lastSyncedAt is the last time the environment was synced (iso string)
const { users }: { users: FormbricksUser[] } = req.body;
console.log(users);
for (const user of users) {
// check if user with this userId as attribute already exists
const existingUser = await prisma.person.findFirst({
@@ -54,43 +56,7 @@ export default async function handle(req: NextApiRequest, res: NextApiResponse)
},
});
if (!existingUser) {
const attributeType: "noCode" = "noCode";
// create user with this attributes (create or connect attribute with the same attributeClass name)
await prisma.person.create({
data: {
attributes: {
create: Object.keys(user.attributes).map((key) => ({
value: user.attributes[key],
attributeClass: {
connectOrCreate: {
where: {
name_environmentId: {
name: key,
environmentId,
},
},
create: {
name: key,
type: attributeType,
environment: {
connect: {
id: environmentId,
},
},
},
},
},
})),
},
environment: {
connect: {
id: environmentId,
},
},
},
});
} else {
if (existingUser) {
// user already exists, loop through attributes and update or create them
const attributeType: "noCode" = "noCode";
for (const key of Object.keys(user.attributes)) {
@@ -107,7 +73,7 @@ export default async function handle(req: NextApiRequest, res: NextApiResponse)
id: existingAttribute.id,
},
data: {
value: user.attributes[key],
value: user.attributes[key].toString(),
},
});
} else {
@@ -125,6 +91,7 @@ export default async function handle(req: NextApiRequest, res: NextApiResponse)
},
create: {
name: key,
description: "Created by Posthog Import",
type: attributeType,
environment: {
connect: {