mirror of
https://github.com/LucasVbr/meeting-app.git
synced 2026-12-05 17:30:50 +00:00
Parse invitation in messages
Took 1 hour 33 minutes
This commit is contained in:
@@ -1,18 +1,28 @@
|
||||
import {Flex, Text} from '@chakra-ui/react';
|
||||
import type {Message as MessageType, User} from '@prisma/client';
|
||||
import type {Message as MessageType} from '@prisma/client';
|
||||
import MessageText from '@/components/chat/MessageText';
|
||||
import React from 'react';
|
||||
import { Icon } from "leaflet";
|
||||
import MessageMap from '@/components/chat/MessageMap';
|
||||
|
||||
type Props = {
|
||||
align: "left" | 'right'
|
||||
message: MessageType
|
||||
}
|
||||
|
||||
const Message = ({message, align}: Props) => (
|
||||
<Flex justifyContent={align}>
|
||||
<Text maxW={"70%"} w={'fit-content'} bg={'purple.500'} borderRadius={10}
|
||||
color={'white'} px={'10px'} py={'5px'}>
|
||||
{message.text}
|
||||
</Text>
|
||||
</Flex>
|
||||
);
|
||||
const Message = ({message, align}: Props) => {
|
||||
if (message.text.match(/<!.+>/g)) {
|
||||
const regex = /<!lon=(?<lon>-?\d+\.\d+),lat=(?<lat>-?\d+\.\d+),name=(?<name>.+)>/g;
|
||||
const p = regex.exec(message.text)?.groups as unknown as {
|
||||
lon: number
|
||||
lat: number
|
||||
name: string
|
||||
}
|
||||
if (p) return <MessageMap align={align} point={p}/>
|
||||
}
|
||||
|
||||
return (
|
||||
<MessageText message={message} align={align} />
|
||||
)
|
||||
}
|
||||
|
||||
export default Message;
|
||||
Reference in New Issue
Block a user