* Implementation * Unifying UI to password screen * Tweaks for session in password section * Update apps/web/pages/settings/security/password.tsx Co-authored-by: Omar López <zomars@me.com> * Update packages/features/kbar/Kbar.tsx Co-authored-by: Omar López <zomars@me.com> * Update packages/features/settings/layouts/SettingsLayout.tsx Co-authored-by: Omar López <zomars@me.com> * Relying on extra db query * Upgrades typescript * Update yarn lock * Typings * Hotfix: ping,riverside,whereby and around not showing up in list (#6712) * Hotfix: ping,riverside,whereby and around not showing up in list (#6712) (#6713) * Adds deployment settings to DB (#6706) * WIP * Adds DeploymentTheme * Add missing migrations * Adds client extensions for deployment * Cleanup * Using same version as other deps * Reverting prisma changes and fixing things * Uneeded tx-expect-error * Fixing default value * Update apps/web/public/static/locales/en/common.json Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> --------- Co-authored-by: Omar López <zomars@me.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
79 lines
2.5 KiB
TypeScript
79 lines
2.5 KiB
TypeScript
import { App_RoutingForms_Form } from "@prisma/client";
|
|
import { Dispatch, SetStateAction } from "react";
|
|
|
|
import { getQueryBuilderConfig } from "../lib/getQueryBuilderConfig";
|
|
import isRouterLinkedField from "../lib/isRouterLinkedField";
|
|
import { Response, SerializableForm } from "../types/types";
|
|
|
|
type Props = {
|
|
form: SerializableForm<App_RoutingForms_Form>;
|
|
response: Response;
|
|
setResponse: Dispatch<SetStateAction<Response>>;
|
|
};
|
|
|
|
export default function FormInputFields(props: Props) {
|
|
const { form, response, setResponse } = props;
|
|
|
|
const queryBuilderConfig = getQueryBuilderConfig(form);
|
|
|
|
return (
|
|
<>
|
|
{form.fields?.map((field) => {
|
|
if (isRouterLinkedField(field)) {
|
|
// @ts-expect-error FIXME @hariombalhara
|
|
field = field.routerField;
|
|
}
|
|
const widget = queryBuilderConfig.widgets[field.type];
|
|
if (!("factory" in widget)) {
|
|
return null;
|
|
}
|
|
const Component = widget.factory;
|
|
|
|
const optionValues = field.selectText?.trim().split("\n");
|
|
const options = optionValues?.map((value) => {
|
|
const title = value;
|
|
return {
|
|
value,
|
|
title,
|
|
};
|
|
});
|
|
return (
|
|
<div key={field.id} className="mb-4 block flex-col sm:flex ">
|
|
<div className="min-w-48 mb-2 flex-grow">
|
|
<label
|
|
id="slug-label"
|
|
htmlFor="slug"
|
|
className="flex text-sm font-medium text-gray-700 dark:text-white">
|
|
{field.label}
|
|
</label>
|
|
</div>
|
|
<div className="flex rounded-sm">
|
|
<Component
|
|
value={response[field.id]?.value}
|
|
// required property isn't accepted by query-builder types
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
/* @ts-ignore */
|
|
required={!!field.required}
|
|
listValues={options}
|
|
data-testid="form-field"
|
|
setValue={(value) => {
|
|
setResponse((response) => {
|
|
response = response || {};
|
|
return {
|
|
...response,
|
|
[field.id]: {
|
|
label: field.label,
|
|
value,
|
|
},
|
|
};
|
|
});
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
})}
|
|
</>
|
|
);
|
|
}
|