Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve newlines from inbound and outbound sms. #168

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/tender-geckos-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@twilio-labs/dev-phone-ui": patch
---

Preserve newlines in inbound and outbound sms.
Add react text area auto resize component.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
"packages/dev-phone-ui"
],
"devDependencies": {
"@changesets/cli": "^2.23.0",
"@changesets/cli": "^2.26.1",
"turbo": "^1.2.16"
},
"dependencies": {
"redux": "^4.2.1",
"twilio-cli": "^5.5.0"
}
}
13 changes: 9 additions & 4 deletions packages/dev-phone-ui/src/components/SendSmsForm/SendSmsForm.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useContext, useState, useMemo } from "react";
import { Button, Input, Label, Box, Grid, Column } from "@twilio-paste/core";
import { useContext, useState, useEffect, useMemo } from "react";
import { Button, Input, Label, Box, Grid, TextArea, HelpText, Column } from "@twilio-paste/core";
import { SendIcon } from '@twilio-paste/icons/esm/SendIcon';
import { useSelector } from "react-redux";
import { TwilioConversationsContext } from '../WebsocketManagers/ConversationsManager';
Expand All @@ -12,12 +12,13 @@ function SendSmsForm({ numberInUse }) {
const destinationNumber = useSelector(state => state.destinationNumber)

const conversationsClient = useContext(TwilioConversationsContext)
const {sendMessage, sendSms} = conversationsClient
const { sendMessage, sendSms } = conversationsClient

const canSendMessages = useMemo(() => {
return destinationNumber && destinationNumber.length > 6;
}, [destinationNumber]);


// Handles the UI state for sending messages
const sendIt = async (e) => {
e.preventDefault()
Expand All @@ -37,9 +38,11 @@ function SendSmsForm({ numberInUse }) {
/>
<form onSubmit={(e) => sendIt(e)} method={"GET"}>
<Label htmlFor="sendSmsBody" required>Message</Label>

<Grid gutter={"space20"} marginBottom="space40">
<Column span={10}>
<Input id="sendSmsBody" type="text" value={messageBody} onChange={(e) => setMessageBody(e.target.value)} />
<TextArea resize="vertical" maxLength={1600} id="sendSmsBody" type="text" messageBody={messageBody} onChange={(e) => setMessageBody(e.target.value)} aria-describedby="send_sms_help_text" required />
<HelpText id="send_sms_help_text">Enter at most 1600 characters</HelpText>
</Column>
<Column span={2}>
<Button type={"submit"} disabled={!canSendMessages}>
Expand All @@ -48,6 +51,8 @@ function SendSmsForm({ numberInUse }) {
</Button>
</Column>
</Grid>


</form>
</Box>

Expand Down