Skip to content
This repository has been archived by the owner on Dec 10, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
BuddyLongLegs committed Aug 24, 2023
2 parents 5ef2ce4 + c97a373 commit aab4299
Show file tree
Hide file tree
Showing 4 changed files with 751 additions and 361 deletions.
32 changes: 27 additions & 5 deletions components/elements/FormInput/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import React from "react";
import { Input, Checkbox, Dropdown, Button, Space, Select, message } from "antd";
import {
Input,
Checkbox,
Dropdown,
Button,
Space,
Select,
message,
} from "antd";
import { AiOutlineDown, AiOutlinePlus, AiOutlineClose } from "react-icons/ai";
import CustomParameter from "../CustomParameterInput";
export default function FormInput({ fields, setFields, hasFileField }) {
Expand Down Expand Up @@ -32,7 +40,10 @@ export default function FormInput({ fields, setFields, hasFileField }) {
const handleMenuClick = (e) => {};
const addField = () => {
if (fields.length < 10) {
setFields([...fields, { name: "", isRequired: false }]);
setFields((prev) => [
...prev,
{ label: "", type: "text", required: false },
]);
} else {
message.error("You cannot add more than 10 fields");
}
Expand All @@ -51,7 +62,9 @@ export default function FormInput({ fields, setFields, hasFileField }) {
return (
<>
<div className="rounded-lg border-solid border-2 border-[#01684a] p-4 flex flex-col gap-2">
<div className="text-lg text-[#01684a] font-bold">Add Fields to your Form</div>
<div className="text-lg text-[#01684a] font-bold">
Add Fields to your Form
</div>
{fields.map((field, i) => (
<div className="flex flex-col gap-4" key={i}>
<div className="border-2 rounded-lg p-4 flex flex-col gap-2">
Expand All @@ -63,7 +76,11 @@ export default function FormInput({ fields, setFields, hasFileField }) {
style={{ width: "100%" }}
options={
hasFileField
? options.filter((option) => option.label !== "file" && option.label !== "image")
? options.filter(
(option) =>
option.label !== "file" &&
option.label !== "image"
)
: options
}
showArrow={true}
Expand Down Expand Up @@ -109,7 +126,12 @@ export default function FormInput({ fields, setFields, hasFileField }) {
</Checkbox>
</div>
<div onClick={() => handleRemove(i)}>
<AiOutlineClose size={20} strokeWidth={12} className="cursor-pointer" fill="#970606" />
<AiOutlineClose
size={20}
strokeWidth={12}
className="cursor-pointer"
fill="#970606"
/>
</div>
</div>
{/* <div className="flex flex-col gap-2">
Expand Down
Loading

1 comment on commit aab4299

@vercel
Copy link

@vercel vercel bot commented on aab4299 Aug 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.