Skip to content

Commit

Permalink
Update select for scheduled messages (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
Teddarific authored Sep 13, 2022
1 parent e0036eb commit 5d90570
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions app/src/components/Productivity/MessageSchedulerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import {
ModalFooter,
ModalHeader,
ModalOverlay,
Select,
Text,
Textarea,
} from '@chakra-ui/react';
import { ipcRenderer } from 'electron';
import { useEffect, useState } from 'react';
import DateTimePicker from 'react-datetime-picker';
import Select from 'react-select';
import { v4 as uuidv4 } from 'uuid';

import SeasonChange from '../../../assets/illustrations/season_change.svg';
Expand Down Expand Up @@ -43,10 +43,19 @@ export function MessageSchedulerModal({

const [dateTime, setDateTime] = useState<Date>(getDefaultDate());
const [message, setMessage] = useState<string>('');
const [selectedPhoneNumber, setSelectedPhoneNumber] = useState<string>('');
const [error, setError] = useState<string | null>(null);
const [showOnboarding, setShowOnboarding] = useState<boolean>(false);

const [selectedContact, setSelectedContact] = useState<{
value: string;
label: string;
}>({
value: '',
label: '',
});

const selectedPhoneNumber = selectedContact.value;

const scheduleMessage = async () => {
// Find matching contact
const contactName =
Expand Down Expand Up @@ -108,18 +117,23 @@ export function MessageSchedulerModal({
if (!isOpen) {
setDateTime(getDefaultDate());
setMessage('');
setSelectedPhoneNumber('');
setSelectedContact({ value: '', label: '' });
}
}, [isOpen]);

const contactOptions = contacts.map((contact) => ({
value: contact.phoneNumber,
label: contact.label,
}));

let content = (
<>
<ModalHeader>Schedule a Message</ModalHeader>
<ModalCloseButton />
<ModalBody>
<FormControl>
<FormLabel>Contact</FormLabel>
<Select
{/* <Select
placeholder="Select a contact"
value={selectedPhoneNumber}
onChange={(event) => {
Expand All @@ -129,7 +143,16 @@ export function MessageSchedulerModal({
{contacts.map((contact) => (
<option value={contact.phoneNumber}>{`${contact.label}`}</option>
))}
</Select>
</Select> */}
<Select
value={selectedContact}
onChange={(newValue) => {
if (newValue) {
setSelectedContact(newValue);
}
}}
options={contactOptions}
/>
</FormControl>
<FormControl style={{ marginTop: 16 }}>
<FormLabel>Message</FormLabel>
Expand Down

0 comments on commit 5d90570

Please sign in to comment.