From 8bc44bd59d92bfc87e1f2a19fc9f11289ffd6bc4 Mon Sep 17 00:00:00 2001 From: csasq Date: Mon, 19 Aug 2024 18:14:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5?= =?UTF-8?q?=D0=B9=D1=81=20=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=B0=20=D0=BE=D0=BF=D1=80=D0=BE=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/screens/PollsScreen.css | 11 ++ frontend/src/screens/PollsScreen.jsx | 197 +++++++++++++++++++-------- 2 files changed, 149 insertions(+), 59 deletions(-) diff --git a/frontend/src/screens/PollsScreen.css b/frontend/src/screens/PollsScreen.css index a2b4f33..73bd997 100644 --- a/frontend/src/screens/PollsScreen.css +++ b/frontend/src/screens/PollsScreen.css @@ -38,3 +38,14 @@ flex-shrink: 0; margin-left: 1rem; } + +.poll-edit .content .message-settings { + display: flex; + flex-direction: column; + gap: 1rem; + color: var(--md-sys-color-on-surface); +} + +.poll-edit .content .message-settings > * { + flex-shrink: 0; +} diff --git a/frontend/src/screens/PollsScreen.jsx b/frontend/src/screens/PollsScreen.jsx index d9bed5b..d4c3dfe 100644 --- a/frontend/src/screens/PollsScreen.jsx +++ b/frontend/src/screens/PollsScreen.jsx @@ -21,9 +21,126 @@ const PollContext = React.createContext({ const apiUrl = new URL(window.location) apiUrl.pathname = '/api/polls' +const MessageType = { + TEXT: 'text', + POLL: 'poll', + MEDIA: 'media', + CONTACT: 'contact', + DICE: 'dice', +} + +const getMessageTypeIcon = (messageType) => { + switch (messageType) { + case MessageType.TEXT: return 'title' + case MessageType.POLL: return 'ballot' + case MessageType.MEDIA: return 'attach_file' + case MessageType.CONTACT: return 'contacts' + case MessageType.DICE: return 'casino' + default: return 'chat' + } +} + +function renderMessage (messageType) { + switch (messageType) { + case MessageType.TEXT: + return ( +
+
Текст
+ + +
+ ) + + case MessageType.POLL: + return ( +
+
Опрос
+ + + contact_support + + +
Варианты ответа
+ +
+ +
+ + + adjust + +
+ +
+ +
Настройки
+ +
+ + + +
+
+ ) + + case MessageType.MEDIA: + return ( +
+
Медиа
+ +
+ + + Прикрепить файл + attach_file + +
+ ) + + case MessageType.CONTACT: + return ( +
+
Контакт
+ + + + +
+ ) + + default: + return '' + } +} + export default function PollsScreen() { const [polls, setPolls] = useState([]) const [editPoll, setEditPoll] = useState(false) + const [messageType, setMessageType] = useState(null) const fetchPolls = async () => { const response = await fetch('/api/polls') @@ -62,10 +179,10 @@ export default function PollsScreen() { setEditPoll={setEditPoll}> + label="Название" + value={editPoll ? editPoll.name : ''} + supporting-text="Отображается в списке опросов" + required="required"> title @@ -124,7 +241,7 @@ export default function PollsScreen() { value="" supporting-text="Время отправки сообщения" required="required"> - title + line_start_circle - title + line_end_circle
@@ -147,75 +264,37 @@ export default function PollsScreen() {
- + setMessageType(event.target.value)} + required="required"> - attach_file + {getMessageTypeIcon(messageType)} - +
Текст
- +
Опрос
- -
Изображение
+ +
Медиа
- -
Видео
+ +
Контакт
- -
Аудио
-
- - -
Файл
+ +
Игральная кость
-
Опрос
- - - contact_support - - -
Варианты ответа
- -
- -
- - - adjust - -
- -
- -
Настройки
- -
- - - -
+ {renderMessage(messageType)}