UNPKG

flowstudio

Version:
34 lines 2.45 kB
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; import { Text, Flex, TextField, Button, Card } from "@radix-ui/themes"; import { useQuery } from "@tanstack/react-query"; import { useEffect, useState } from "react"; import { FaPlay } from "react-icons/fa"; export default function Simulator({ open, setOpen, projectIdentifier }) { const { data: project, status: projectStatus, refetch: projectRefetch } = useQuery({ queryKey: [`project_${projectIdentifier}`], queryFn: async () => { const res = await fetch(`/api/projects/${projectIdentifier}`); return res === null || res === void 0 ? void 0 : res.json(); }, ...{ enabled: !!projectIdentifier } }); const [getMessage, setMessage] = useState(''); useEffect(() => { fetchCallback(); }, []); const fetchCallback = async () => { try { const response = await fetch('/api/123456789/callback?network=mtn&mode=start&msisdn=233241844442&sessionid=1234567&userdata=800*008&username=uxxd&trafficid=1234567&other=g4m&serviceCode=1234'); if (await response) { const data = await response.text(); if (response.ok) { setMessage(data); } } } catch (err) { console.log(err); } }; const [loading, setLoading] = useState(false); return (_jsx(_Fragment, { children: _jsx(Flex, { direction: 'column', gap: '5', width: '100%', height: '100%', children: _jsx(Card, { children: _jsxs(Flex, { width: '100%', height: '100%', direction: 'column', children: [_jsxs(Flex, { flexShrink: '0', width: '100%', justify: 'between', p: '2', align: 'center', children: [_jsx(Flex, { align: 'center', children: _jsx(Text, { children: "12:00PM" }) }), _jsx(Flex, { align: 'center', children: _jsx(Text, { children: "59%" }) })] }), _jsx(Flex, { flexGrow: '1', children: _jsx(Text, { children: getMessage }) }), _jsxs(Flex, { flexShrink: '0', gap: '2', children: [_jsx(Flex, { flexGrow: '1', children: _jsx(TextField.Root, { size: '1', type: 'text', placeholder: 'Your Input', style: { width: '100%' } }) }), _jsx(Flex, { flexShrink: '0', children: _jsxs(Button, { loading: loading, size: '1', onClick: () => { setLoading(true); }, color: 'teal', variant: 'soft', children: [_jsx(FaPlay, {}), " Send"] }) })] })] }) }) }) })); } //# sourceMappingURL=simulator.js.map