Skip to content

Commit

Permalink
refactor: invite user input (#1919)
Browse files Browse the repository at this point in the history
  • Loading branch information
kanikabansal-juspay authored Dec 18, 2024
1 parent 3b155e5 commit 84cf9aa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
12 changes: 11 additions & 1 deletion src/components/form/PillInput.res
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@send external focus: Dom.element => unit = "focus"
@react.component
let make = (~name, ~initialItems: array<string>=[], ~placeholder, ~duplicateCheck=true) => {
let form = ReactFinalForm.useForm()
Expand Down Expand Up @@ -113,7 +114,15 @@ let make = (~name, ~initialItems: array<string>=[], ~placeholder, ~duplicateChec
setEditInput(_ => item)
}

<div className="w-full">
let inputRef = React.useRef(Nullable.null)
let handleContainerClick = () => {
switch inputRef.current->Nullable.toOption {
| Some(inputElement) => inputElement->focus
| None => ()
}
}

<div className="w-full cursor-text" onClick={_ => handleContainerClick()}>
<div className="w-full flex flex-wrap gap-2 border p-2 text-sm rounded-md">
{items
->Array.mapWithIndex((item, i) =>
Expand Down Expand Up @@ -142,6 +151,7 @@ let make = (~name, ~initialItems: array<string>=[], ~placeholder, ~duplicateChec
->React.array}
<div className="relative">
<input
ref={inputRef->ReactDOM.Ref.domRef}
type_="text"
value={inputValue}
placeholder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,10 @@ let inviteEmail = FormRenderer.makeFieldInfo(
~name="email_list",
~customInput=(~input, ~placeholder as _) => {
let showPlaceHolder = input.value->LogicUtils.getArrayFromJson([])->Array.length === 0
InputFields.textTagInput(
~input,
~placeholder=showPlaceHolder ? "Eg: [email protected], [email protected]" : "",
~customButtonStyle="!rounded-full !px-4",
~seperateByComma=true,
)
<PillInput name="email_list" placeholder={showPlaceHolder ? "Eg: [email protected]" : ""} />
},
~isRequired=true,
)

module SwitchMerchantForUserAction = {
@react.component
let make = (~userInfoValue: UserManagementTypes.userDetailstype) => {
Expand Down
17 changes: 0 additions & 17 deletions src/screens/UserManagement/UserRevamp/UserManagementUtils.res
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
let errorClass = "text-sm leading-4 font-medium text-start ml-1 mt-2"

let inviteEmail = FormRenderer.makeFieldInfo(
~label="Enter email",
~name="emailList",
~customInput=(
(~input, ~placeholder as _) => {
let showPlaceHolder = input.value->LogicUtils.getArrayFromJson([])->Array.length === 0
InputFields.textTagInput(
~input,
~placeholder=showPlaceHolder ? "Eg: [email protected], [email protected]" : "",
~customButtonStyle="!rounded-full !px-4",
~seperateByComma=true,
)
}
)->InputFields.iconFieldWithMessageDes(~description="Press Enter to add more"),
~isRequired=true,
)

let createCustomRole = FormRenderer.makeFieldInfo(
~label="Enter custom role name",
~name="role_name",
Expand Down

0 comments on commit 84cf9aa

Please sign in to comment.