Skip to content

Commit

Permalink
CCS-100179 Fix input with empty data, add clean icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Kudinov committed Aug 5, 2024
1 parent 92ec8a0 commit a3e7825
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
25 changes: 24 additions & 1 deletion frontend/app/components/Input.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { FC } from 'react'
import styled from 'styled-components'
import Icon from '../assets/clear-input.svg'

const InputStyled = styled.input.attrs({ className: 'input' })`
padding: 12px 20px;
Expand All @@ -13,6 +14,13 @@ const InputStyled = styled.input.attrs({ className: 'input' })`
background-color: var(--input-bg);
`

const CloseIcon = styled(Icon)`
position: absolute;
transform: translate(-150%, 102%);
color: #767676;
cursor: pointer;
`

type Props = {
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void
id?: string
Expand All @@ -22,7 +30,22 @@ type Props = {
}

const Input: FC<Props> = props => {
return <InputStyled {...props} />
const handleClear = () => {
const event = {
target: {
value: '',
},
} as React.ChangeEvent<HTMLInputElement>

props.onChange?.(event)
}

return (
<>
<InputStyled {...props} />
{!props.type && props.value && <CloseIcon onClick={handleClear} id={`${props.id}.field-clear`} />}
</>
)
}

export default Input
4 changes: 3 additions & 1 deletion frontend/app/modules/send-message/send-message.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ export class SendMessageStore {
this.response = null
}

async sendMessage(messageBody: string, groupChatId: string, userHuid: string): Promise<void> {
async sendMessage(messageBody: string, groupChatId: string, userHuidRaw: string): Promise<void> {
try {
const userHuid = !userHuidRaw ? null : userHuidRaw

const response = (await SDK.sendMessage({ messageBody, groupChatId, userHuid })) as StatusResponse

if (response.payload.status === STATUS.ERROR) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-feature-smartapp",
"version": "2.2.5",
"version": "2.2.6",
"description": "SmartApp with all features",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit a3e7825

Please sign in to comment.