agx-chat-web 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agx-chat.esm.js +1 -1
- package/dist/agx-chat.esm.js.map +1 -1
- package/package.json +2 -3
- package/src/__tests__/app/Messenger/classes/slaCalculations.spec.ts +0 -122
- package/src/app/ChatProvider/ChatProvider.tsx +0 -20
- package/src/app/Messenger/classes/slaCalculations.ts +0 -197
- package/src/app/Messenger/components/ChatButton/ChatButton.tsx +0 -64
- package/src/app/Messenger/components/ChatTabs/ChatTabs.less +0 -18
- package/src/app/Messenger/components/ChatTabs/ChatTabs.tsx +0 -32
- package/src/app/Messenger/components/DocMessage/DocMessage.less +0 -71
- package/src/app/Messenger/components/DocMessage/DocMessage.tsx +0 -50
- package/src/app/Messenger/components/ImagesContainer/ImagesContainer.less +0 -79
- package/src/app/Messenger/components/ImagesContainer/ImagesContainer.tsx +0 -51
- package/src/app/Messenger/components/IncomingMessage/IncomingMessage.tsx +0 -170
- package/src/app/Messenger/components/InfiniteScroll/InfiniteScroll.tsx +0 -80
- package/src/app/Messenger/components/InputFile/InputFile.tsx +0 -147
- package/src/app/Messenger/components/InputFile/inputFile.less +0 -59
- package/src/app/Messenger/components/MessageBallon/MessageBalloon.tsx +0 -100
- package/src/app/Messenger/components/MessengerAvatar/MessengerAvatar.tsx +0 -29
- package/src/app/Messenger/components/MessengerThemeWrapper/MessengerThemeWrapper.tsx +0 -62
- package/src/app/Messenger/components/RenderFileIcon/RenderFileIcon.tsx +0 -40
- package/src/app/Messenger/components/SearchInput/SearchInput.less +0 -45
- package/src/app/Messenger/components/SearchInput/SearchInput.tsx +0 -77
- package/src/app/Messenger/components/Select/Select.less +0 -22
- package/src/app/Messenger/components/Select/Select.tsx +0 -56
- package/src/app/Messenger/components/SendMessageForm/SendMessageForm.tsx +0 -254
- package/src/app/Messenger/components/SenderMessages/SenderMessages.tsx +0 -91
- package/src/app/Messenger/components/SystemMessage/SystemMessage.tsx +0 -25
- package/src/app/Messenger/components/TextArea/TextArea.tsx +0 -35
- package/src/app/Messenger/components/TextArea/Textarea.less +0 -22
- package/src/app/Messenger/components/Tooltip/Tooltip.less +0 -27
- package/src/app/Messenger/components/Tooltip/Tooltip.tsx +0 -17
- package/src/app/Messenger/hooks/useConversations.tsx +0 -143
- package/src/app/Messenger/hooks/useMessages.tsx +0 -49
- package/src/app/Messenger/hooks/useThemes.tsx +0 -14
- package/src/app/Messenger/icons/AttachFileIcon.tsx +0 -20
- package/src/app/Messenger/icons/CSVFileIcon.tsx +0 -26
- package/src/app/Messenger/icons/CloseIcon.tsx +0 -20
- package/src/app/Messenger/icons/DOCFileIcon.tsx +0 -54
- package/src/app/Messenger/icons/DownloadMinimalistIcon.tsx +0 -37
- package/src/app/Messenger/icons/EmptyIcon.tsx +0 -20
- package/src/app/Messenger/icons/MP4FileIcon.tsx +0 -26
- package/src/app/Messenger/icons/MessageIcon.tsx +0 -27
- package/src/app/Messenger/icons/PDFFileIcon.tsx +0 -54
- package/src/app/Messenger/icons/ReadIcon.tsx +0 -18
- package/src/app/Messenger/icons/SearchIcon.tsx +0 -20
- package/src/app/Messenger/icons/TimerIcon.tsx +0 -18
- package/src/app/Messenger/icons/TrashIcon.tsx +0 -21
- package/src/app/Messenger/views/Messenger.less +0 -623
- package/src/app/Messenger/views/MessengerList.tsx +0 -170
- package/src/app/Messenger/views/MessengerListItem.tsx +0 -178
- package/src/app/Messenger/views/MessengerMessages.tsx +0 -414
- package/src/app/Messenger/views/NewFormChat.tsx +0 -145
- package/src/app/i18n/index.ts +0 -36
- package/src/app/i18n/locales/en.json +0 -64
- package/src/app/i18n/locales/pt.json +0 -64
- package/src/assets/right-arrow.svg +0 -10
- package/src/index.ts +0 -23
- package/src/react-app-env.d.ts +0 -19
- package/src/setupTests.ts +0 -5
- package/src/styles/abstracts/animations.less +0 -8
- package/src/styles/abstracts/mixins.less +0 -5
- package/src/styles/abstracts/variables.less +0 -31
- package/src/styles/base/base.less +0 -6
- package/src/styles/index.less +0 -5
- package/src/types.ts +0 -174
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agx-chat-web",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Chat application using React and less",
|
|
5
5
|
"module": "./dist/agx-chat.esm.js",
|
|
6
6
|
"author": {
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
"main": "./dist/agx-chat.umd.js",
|
|
12
12
|
"types": "./dist/esm/index.d.ts",
|
|
13
13
|
"files": [
|
|
14
|
-
"dist"
|
|
15
|
-
"src/**/*"
|
|
14
|
+
"dist"
|
|
16
15
|
],
|
|
17
16
|
"repository": "git@github.com:AGX-Software/chat-web.git",
|
|
18
17
|
"peerDependencies": {
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from '@jest/globals'
|
|
2
|
-
import {
|
|
3
|
-
SlaDates,
|
|
4
|
-
timeAsDayjs,
|
|
5
|
-
} from '../../../../app/Messenger/classes/slaCalculations'
|
|
6
|
-
const workingHours = { start: 9, end: 18 }
|
|
7
|
-
|
|
8
|
-
describe('slaCalculations class', () => {
|
|
9
|
-
it('Should return true seconds in working hour', () => {
|
|
10
|
-
const sla = new SlaDates(1300)
|
|
11
|
-
|
|
12
|
-
expect(
|
|
13
|
-
sla.canUpdateClock(
|
|
14
|
-
timeAsDayjs('2023-07-21T10:19:29.224+00:00', { applyTimezone: false })
|
|
15
|
-
)
|
|
16
|
-
).toBeTruthy()
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('Should return false seconds from canUpdateClock', () => {
|
|
20
|
-
const sla = new SlaDates(1300)
|
|
21
|
-
|
|
22
|
-
expect(
|
|
23
|
-
sla.canUpdateClock(
|
|
24
|
-
timeAsDayjs('2023-07-21T20:19:29.224+00:00', { applyTimezone: false })
|
|
25
|
-
)
|
|
26
|
-
).toBeFalsy()
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('Should return false in holiday', () => {
|
|
30
|
-
const sla = new SlaDates(1300)
|
|
31
|
-
|
|
32
|
-
expect(
|
|
33
|
-
sla.canUpdateClock(
|
|
34
|
-
timeAsDayjs('2023-10-12T10:19:29.224+00:00', { applyTimezone: false })
|
|
35
|
-
)
|
|
36
|
-
).toBeFalsy()
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('Should return 3600 seconds diffence', () => {
|
|
40
|
-
const sla = new SlaDates(3600)
|
|
41
|
-
|
|
42
|
-
expect(
|
|
43
|
-
sla.getDifferenceInSeconds(
|
|
44
|
-
timeAsDayjs('2023-07-19T09:19:29.224+00:00', { applyTimezone: false }),
|
|
45
|
-
timeAsDayjs('2023-07-19T10:19:29.224+00:00', { applyTimezone: false }),
|
|
46
|
-
workingHours
|
|
47
|
-
)
|
|
48
|
-
).toBe(3600)
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
it('Should return 7200 seconds diffence', () => {
|
|
52
|
-
const sla = new SlaDates(3600)
|
|
53
|
-
|
|
54
|
-
expect(
|
|
55
|
-
sla.getDifferenceInSeconds(
|
|
56
|
-
timeAsDayjs('2023-10-12T09:19:29.224+00:00', { applyTimezone: false }),
|
|
57
|
-
timeAsDayjs('2023-10-12T11:19:29.224+00:00', { applyTimezone: false }),
|
|
58
|
-
workingHours
|
|
59
|
-
)
|
|
60
|
-
).toBe(0)
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
it('Should return 7200 seconds diffence', () => {
|
|
64
|
-
const sla = new SlaDates(3600)
|
|
65
|
-
|
|
66
|
-
expect(
|
|
67
|
-
sla.getDifferenceInSeconds(
|
|
68
|
-
timeAsDayjs('2023-07-21T17:00:00.000+00:00', { applyTimezone: false }),
|
|
69
|
-
timeAsDayjs('2023-07-24T10:00:00.000+00:00', { applyTimezone: false }),
|
|
70
|
-
workingHours
|
|
71
|
-
)
|
|
72
|
-
).toBe(7200)
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
it('Should return 64800 seconds diffence', () => {
|
|
76
|
-
const sla = new SlaDates(3600)
|
|
77
|
-
|
|
78
|
-
expect(
|
|
79
|
-
sla.getDifferenceInSeconds(
|
|
80
|
-
timeAsDayjs('2023-07-21T09:00:00.000+00:00', { applyTimezone: false }),
|
|
81
|
-
timeAsDayjs('2023-07-24T18:00:00.000+00:00', { applyTimezone: false }),
|
|
82
|
-
workingHours
|
|
83
|
-
)
|
|
84
|
-
).toBe(64800)
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
it('Should return 43200 seconds diffence', () => {
|
|
88
|
-
const sla = new SlaDates(3600)
|
|
89
|
-
|
|
90
|
-
expect(
|
|
91
|
-
sla.getDifferenceInSeconds(
|
|
92
|
-
timeAsDayjs('2023-07-21T09:00:00.000+00:00', { applyTimezone: false }),
|
|
93
|
-
timeAsDayjs('2023-07-24T12:00:00.000+00:00', { applyTimezone: false }),
|
|
94
|
-
workingHours
|
|
95
|
-
)
|
|
96
|
-
).toBe(43200)
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
it('Should return 1800 seconds diffence', () => {
|
|
100
|
-
const sla = new SlaDates(3600)
|
|
101
|
-
|
|
102
|
-
expect(
|
|
103
|
-
sla.getDifferenceInSeconds(
|
|
104
|
-
timeAsDayjs('2023-07-24T07:00:00.000+00:00', { applyTimezone: false }),
|
|
105
|
-
timeAsDayjs('2023-07-24T09:30:00.000+00:00', { applyTimezone: false }),
|
|
106
|
-
workingHours
|
|
107
|
-
)
|
|
108
|
-
).toBe(1800)
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
it('Should return 3600 seconds diffence', () => {
|
|
112
|
-
const sla = new SlaDates(3600)
|
|
113
|
-
|
|
114
|
-
expect(
|
|
115
|
-
sla.getDifferenceInSeconds(
|
|
116
|
-
timeAsDayjs('2023-07-24T22:00:00.000+00:00', { applyTimezone: false }),
|
|
117
|
-
timeAsDayjs('2023-07-25T10:00:00.000+00:00', { applyTimezone: false }),
|
|
118
|
-
workingHours
|
|
119
|
-
)
|
|
120
|
-
).toBe(3600)
|
|
121
|
-
})
|
|
122
|
-
})
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode, useEffect } from 'react'
|
|
2
|
-
import { I18nextProvider } from 'react-i18next'
|
|
3
|
-
import defaultI18n from '../i18n'
|
|
4
|
-
|
|
5
|
-
interface ChatProviderProps {
|
|
6
|
-
children: ReactNode
|
|
7
|
-
locale?: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function ChatProvider ({ children, locale }: ChatProviderProps) {
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
if (locale) {
|
|
13
|
-
defaultI18n.changeLanguage(locale)
|
|
14
|
-
}
|
|
15
|
-
}, [locale])
|
|
16
|
-
|
|
17
|
-
return <I18nextProvider i18n={defaultI18n}>{children}</I18nextProvider>
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default ChatProvider
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import dayjs, { ConfigType, Dayjs } from 'dayjs'
|
|
2
|
-
import dayjsBR from 'dayjs/locale/pt-br'
|
|
3
|
-
import utc from 'dayjs/plugin/utc'
|
|
4
|
-
import timezone from 'dayjs/plugin/timezone'
|
|
5
|
-
import isToday from 'dayjs/plugin/isToday'
|
|
6
|
-
const serverTz = 'America/Sao_Paulo'
|
|
7
|
-
|
|
8
|
-
dayjs.extend(utc)
|
|
9
|
-
dayjs.extend(timezone)
|
|
10
|
-
dayjs.extend(isToday)
|
|
11
|
-
dayjs.locale(dayjsBR)
|
|
12
|
-
|
|
13
|
-
export const timeAsDayjs = (
|
|
14
|
-
value: ConfigType = new Date(),
|
|
15
|
-
options?: { server?: boolean; applyTimezone?: boolean }
|
|
16
|
-
): Dayjs => {
|
|
17
|
-
const server = options?.server
|
|
18
|
-
const applyTimezone = options?.applyTimezone
|
|
19
|
-
|
|
20
|
-
let timezone = dayjs.tz.guess()
|
|
21
|
-
if (!(applyTimezone ?? true)) timezone = 'GMT'
|
|
22
|
-
else if (server ?? false) timezone = serverTz
|
|
23
|
-
|
|
24
|
-
return dayjs.tz(value, timezone)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const time = (
|
|
28
|
-
value: ConfigType = new Date(),
|
|
29
|
-
options?: { server?: boolean; applyTimezone?: boolean }
|
|
30
|
-
): Date => {
|
|
31
|
-
const server = options?.server
|
|
32
|
-
const applyTimezone = options?.applyTimezone
|
|
33
|
-
let aux: Dayjs
|
|
34
|
-
|
|
35
|
-
if (!(applyTimezone ?? true))
|
|
36
|
-
aux = dayjs.tz(value, 'GMT') // Set applyTimezone to false when timezone is applied incorrectly (usually when working with JSDate and timestamps)
|
|
37
|
-
else if (server ?? false) aux = dayjs.tz(value, serverTz)
|
|
38
|
-
else aux = dayjs.tz(value, dayjs.tz.guess())
|
|
39
|
-
|
|
40
|
-
return new Date(
|
|
41
|
-
Date.UTC(
|
|
42
|
-
aux.year(),
|
|
43
|
-
aux.month(),
|
|
44
|
-
aux.date(),
|
|
45
|
-
aux.hour(),
|
|
46
|
-
aux.minute(),
|
|
47
|
-
aux.second(),
|
|
48
|
-
aux.millisecond()
|
|
49
|
-
)
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export class SlaDates {
|
|
54
|
-
public seconds: number | null
|
|
55
|
-
|
|
56
|
-
constructor (seconds: number) {
|
|
57
|
-
this.seconds = seconds
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
private holidays = {
|
|
61
|
-
2023: ['09-07', '10-12', '10-17', '11-02', '11-15', '11-20', '12-25'],
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private isWorkingDay (date: Dayjs) {
|
|
65
|
-
const dayOfWeek = date.day()
|
|
66
|
-
return dayOfWeek >= 1 && dayOfWeek <= 5 // Monday to Friday (1 to 5)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private isWorkingHour (date: Dayjs) {
|
|
70
|
-
const hour = date.hour()
|
|
71
|
-
return hour >= 9 && hour <= 18 // Between 9 AM and 5 PM (inclusive)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public isWeekendOrHoliday (date: Dayjs | Date | string): boolean {
|
|
75
|
-
const weekDay = timeAsDayjs(date, { applyTimezone: false }).day()
|
|
76
|
-
if ([6, 0].includes(weekDay)) return true
|
|
77
|
-
|
|
78
|
-
const formatedDate = timeAsDayjs(date).format('MM-DD')
|
|
79
|
-
const isHollyday = this.holidays[2023].includes(formatedDate)
|
|
80
|
-
return isHollyday
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private isHoliday (date: Dayjs) {
|
|
84
|
-
const formatedDate = timeAsDayjs(date, { applyTimezone: false }).format(
|
|
85
|
-
'MM-DD'
|
|
86
|
-
)
|
|
87
|
-
const isHollyday = this.holidays[2023].includes(formatedDate)
|
|
88
|
-
return isHollyday
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public canUpdateClock (date: Dayjs) {
|
|
92
|
-
const isWorking = this.isWorkingDay(date) && this.isWorkingHour(date)
|
|
93
|
-
return !this.isWeekendOrHoliday(date) && isWorking
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
public getDiffInSeconds (
|
|
97
|
-
startDate: dayjs.Dayjs,
|
|
98
|
-
endDate: dayjs.Dayjs
|
|
99
|
-
): number {
|
|
100
|
-
const diffInSeconds = endDate.diff(startDate, 'second')
|
|
101
|
-
return diffInSeconds
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
calculateWorkingTime (
|
|
105
|
-
startDate: Dayjs,
|
|
106
|
-
endDate: Dayjs,
|
|
107
|
-
workingHours: { start: number; end: number }
|
|
108
|
-
) {
|
|
109
|
-
let current = startDate.clone()
|
|
110
|
-
let workingTime = 0
|
|
111
|
-
|
|
112
|
-
while (current.isBefore(endDate)) {
|
|
113
|
-
// Skip weekends (Saturday and Sunday) and Holydays
|
|
114
|
-
|
|
115
|
-
if (this.isWorkingDay(current) && !this.isHoliday(current)) {
|
|
116
|
-
const startOfDay = current
|
|
117
|
-
.clone()
|
|
118
|
-
.startOf('day')
|
|
119
|
-
.add(workingHours.start, 'hour')
|
|
120
|
-
const endOfDay = current
|
|
121
|
-
.clone()
|
|
122
|
-
.startOf('day')
|
|
123
|
-
.add(workingHours.end, 'hour')
|
|
124
|
-
|
|
125
|
-
if (current.isBefore(startOfDay)) {
|
|
126
|
-
// If current time is before the start of working hours, move to the start of working hours
|
|
127
|
-
current = startOfDay.clone()
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (current.isAfter(endOfDay)) {
|
|
131
|
-
current = current.clone().add(1, 'day').startOf('day')
|
|
132
|
-
} else if (endDate.isAfter(endOfDay)) {
|
|
133
|
-
// If end date is after the end of working hours, add a full working day
|
|
134
|
-
|
|
135
|
-
workingTime += Math.abs(endOfDay.clone().diff(current, 'second'))
|
|
136
|
-
current = current
|
|
137
|
-
.clone()
|
|
138
|
-
.add(1, 'day')
|
|
139
|
-
.startOf('day')
|
|
140
|
-
.add(workingHours.start, 'hour')
|
|
141
|
-
} else {
|
|
142
|
-
// Calculate working time for the last day (end date)
|
|
143
|
-
workingTime += Math.abs(endDate.clone().diff(current, 'second'))
|
|
144
|
-
|
|
145
|
-
break
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
// Move to the next day
|
|
149
|
-
current = current.clone().add(1, 'day').startOf('day')
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return workingTime
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Function to calculate the difference in seconds between two dates considering working hours
|
|
157
|
-
getDifferenceInSeconds (
|
|
158
|
-
startDate: Dayjs,
|
|
159
|
-
endDate: Dayjs,
|
|
160
|
-
workingHours: { start: number; end: number }
|
|
161
|
-
) {
|
|
162
|
-
if (endDate.isBefore(startDate)) {
|
|
163
|
-
throw new Error('End date should be after the start date.')
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const workingTimeInSeconds = this.calculateWorkingTime(
|
|
167
|
-
startDate,
|
|
168
|
-
endDate,
|
|
169
|
-
workingHours
|
|
170
|
-
)
|
|
171
|
-
return workingTimeInSeconds
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
static secondsInHours (currentSeconds: number) {
|
|
175
|
-
const hours = Math.floor(currentSeconds / 3600)
|
|
176
|
-
const minutes = Math.floor((currentSeconds % 3600) / 60)
|
|
177
|
-
const seconds = currentSeconds % 60
|
|
178
|
-
return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
static getColorsByTime (seconds: number) {
|
|
182
|
-
const hours = seconds / 3600
|
|
183
|
-
if (hours <= 2) {
|
|
184
|
-
return '#00CF7B'
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (hours >= 2 && hours < 3) {
|
|
188
|
-
return '#FF9838'
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (hours >= 3 && hours < 4) {
|
|
192
|
-
return '#DD4E4E'
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return '#151919'
|
|
196
|
-
}
|
|
197
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import useTheme from '../../hooks/useThemes'
|
|
3
|
-
|
|
4
|
-
interface INewChatButton {
|
|
5
|
-
removeActiveItem: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void
|
|
6
|
-
messegerView: 'empty' | 'messages' | 'newChat'
|
|
7
|
-
chatButtons: {
|
|
8
|
-
label: string
|
|
9
|
-
onClick: () => void
|
|
10
|
-
type: string
|
|
11
|
-
canSee: boolean
|
|
12
|
-
disabled?: boolean
|
|
13
|
-
}[]
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function ChatButtons ({ chatButtons, removeActiveItem }: INewChatButton) {
|
|
17
|
-
const { theme } = useTheme()
|
|
18
|
-
|
|
19
|
-
const getButtonType = (type: string, disabled?: boolean) => {
|
|
20
|
-
if (type === 'primary')
|
|
21
|
-
return {
|
|
22
|
-
background: disabled ? theme?.buttonsDisabled : theme?.buttonPrimary,
|
|
23
|
-
color: theme?.buttonPrimaryText,
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (type === 'outlined')
|
|
27
|
-
return {
|
|
28
|
-
background: 'transparent',
|
|
29
|
-
color: theme?.asideFontColor,
|
|
30
|
-
border: `${theme?.asideFontColor} 1px solid`,
|
|
31
|
-
}
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<>
|
|
37
|
-
{chatButtons.map((button) => {
|
|
38
|
-
return (
|
|
39
|
-
button.canSee && (
|
|
40
|
-
<>
|
|
41
|
-
<button
|
|
42
|
-
key={`button-${button.label}`}
|
|
43
|
-
className={
|
|
44
|
-
button.disabled
|
|
45
|
-
? 'messenger__chat-button messenger__chat-button--disabled'
|
|
46
|
-
: 'messenger__chat-button'
|
|
47
|
-
}
|
|
48
|
-
onClick={(event) => {
|
|
49
|
-
button.onClick()
|
|
50
|
-
removeActiveItem(event)
|
|
51
|
-
}}
|
|
52
|
-
style={getButtonType(button.type, button.disabled)}
|
|
53
|
-
>
|
|
54
|
-
{button.label}
|
|
55
|
-
</button>
|
|
56
|
-
</>
|
|
57
|
-
)
|
|
58
|
-
)
|
|
59
|
-
})}
|
|
60
|
-
</>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export default ChatButtons
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
.chat-tabs {
|
|
2
|
-
display: flex;
|
|
3
|
-
justify-content: center;
|
|
4
|
-
align-items: center;
|
|
5
|
-
&__button {
|
|
6
|
-
background: transparent;
|
|
7
|
-
border: none;
|
|
8
|
-
border-bottom: 1px solid transparent;
|
|
9
|
-
cursor: pointer;
|
|
10
|
-
padding: 0.5rem 1rem;
|
|
11
|
-
margin-bottom: 0.5rem;
|
|
12
|
-
|
|
13
|
-
&--active {
|
|
14
|
-
border-bottom: 1px solid var(--secondary-color);
|
|
15
|
-
transition: 0.5s;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import useTheme from '../../hooks/useThemes'
|
|
2
|
-
import { activeItem } from '../../views/MessengerListItem'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
|
|
5
|
-
interface IProps {
|
|
6
|
-
handleChangeTickets: (tab: string) => void
|
|
7
|
-
chatListTabs: { value: string; label: string }[]
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function ChatTabs ({ handleChangeTickets, chatListTabs }: IProps) {
|
|
11
|
-
const { theme } = useTheme()
|
|
12
|
-
return (
|
|
13
|
-
<div className='chat-tabs' style={{ color: theme.asideFontColor }}>
|
|
14
|
-
{chatListTabs.map((tab, index) => {
|
|
15
|
-
return (
|
|
16
|
-
<button
|
|
17
|
-
key={`chatListTab-${index}`}
|
|
18
|
-
className={`chat-tabs__button ${index === 0 && 'chat-tabs__button--active'}`}
|
|
19
|
-
onClick={(e) => {
|
|
20
|
-
handleChangeTickets(tab.value)
|
|
21
|
-
activeItem(e, 'chat-tabs__button', 'chat-tabs__button--active')
|
|
22
|
-
}}
|
|
23
|
-
>
|
|
24
|
-
{tab.label}
|
|
25
|
-
</button>
|
|
26
|
-
)
|
|
27
|
-
})}
|
|
28
|
-
</div>
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export default ChatTabs
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
.messenger {
|
|
2
|
-
&__messages-row--sender {
|
|
3
|
-
display: flex;
|
|
4
|
-
justify-content: flex-end;
|
|
5
|
-
margin: 10px 0;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
&__messages-sender {
|
|
9
|
-
max-width: 80%;
|
|
10
|
-
padding: 10px;
|
|
11
|
-
border-radius: 8px;
|
|
12
|
-
font-family: 'Arial', sans-serif;
|
|
13
|
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
&__file-card {
|
|
17
|
-
display: flex;
|
|
18
|
-
align-items: center;
|
|
19
|
-
background: rgba(0, 0, 0, 0.1);
|
|
20
|
-
border-radius: 8px;
|
|
21
|
-
padding: 10px;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
&__file-icon {
|
|
25
|
-
flex-shrink: 0;
|
|
26
|
-
width: 40px;
|
|
27
|
-
height: 40px;
|
|
28
|
-
display: flex;
|
|
29
|
-
align-items: center;
|
|
30
|
-
justify-content: center;
|
|
31
|
-
border-radius: 4px;
|
|
32
|
-
margin-right: 10px;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
&__file-details {
|
|
36
|
-
flex-grow: 1;
|
|
37
|
-
margin-right: 10px;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
&__file-name {
|
|
41
|
-
font-weight: bold;
|
|
42
|
-
font-size: 14px;
|
|
43
|
-
margin: 0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&__file-info {
|
|
47
|
-
font-size: 12px;
|
|
48
|
-
color: rgba(255, 255, 255, 0.8);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
&__file-download {
|
|
52
|
-
font-size: 12px;
|
|
53
|
-
text-decoration: none;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
&__file-download:hover {
|
|
57
|
-
text-decoration: underline;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
&__message--bottom {
|
|
61
|
-
display: flex;
|
|
62
|
-
justify-content: space-between;
|
|
63
|
-
align-items: center;
|
|
64
|
-
margin-top: 5px;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
&__message--date {
|
|
68
|
-
font-size: 12px;
|
|
69
|
-
color: rgba(255, 255, 255, 0.8);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import DownloadMinimalistIcon from '../../icons/DownloadMinimalistIcon'
|
|
3
|
-
import { IMessagesBalloon } from 'types'
|
|
4
|
-
import RenderFileIcon from '../RenderFileIcon/RenderFileIcon'
|
|
5
|
-
|
|
6
|
-
export function formatFileSize (size = 0) {
|
|
7
|
-
if (size % 1 === 0) {
|
|
8
|
-
return `${size.toFixed(0)} MB`
|
|
9
|
-
}
|
|
10
|
-
return `${size.toFixed(2)} MB`
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function DocMessage ({ file }: IMessagesBalloon) {
|
|
14
|
-
const fileType = file?.location?.split('.').pop()?.toUpperCase()
|
|
15
|
-
const fileName = file && file.originalname
|
|
16
|
-
const filePages = file && file.pages
|
|
17
|
-
const fileSize = file && formatFileSize(file?.size)
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<div className='messenger__messages-row--sender'>
|
|
21
|
-
<span>
|
|
22
|
-
{
|
|
23
|
-
<div className='messenger__file-card'>
|
|
24
|
-
<div className='messenger__file-icon'>
|
|
25
|
-
<RenderFileIcon fileType={file?.mimetype} />
|
|
26
|
-
</div>
|
|
27
|
-
<div className='messenger__file-details'>
|
|
28
|
-
<p className='messenger__file-name'>{fileName}</p>
|
|
29
|
-
<p className='messenger__file-info'>
|
|
30
|
-
{filePages && filePages + ' página(s) •'} {fileSize} •{' '}
|
|
31
|
-
{fileType}
|
|
32
|
-
</p>
|
|
33
|
-
</div>
|
|
34
|
-
<a
|
|
35
|
-
href={file?.location}
|
|
36
|
-
target='_blank'
|
|
37
|
-
rel='noopener noreferrer'
|
|
38
|
-
className='messenger__file-download'
|
|
39
|
-
style={{ color: 'blue' }}
|
|
40
|
-
>
|
|
41
|
-
<DownloadMinimalistIcon width='24' height='24' color='white' />
|
|
42
|
-
</a>
|
|
43
|
-
</div>
|
|
44
|
-
}
|
|
45
|
-
</span>
|
|
46
|
-
</div>
|
|
47
|
-
)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export default DocMessage
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
.images-container {
|
|
2
|
-
width: 100%;
|
|
3
|
-
height: 90%;
|
|
4
|
-
border: 2px solid @secondary-bg-color-chat;
|
|
5
|
-
background-color: @component-background;
|
|
6
|
-
border-bottom: none;
|
|
7
|
-
border-radius: 0 @border-radius 0 0;
|
|
8
|
-
@media @tab-md {
|
|
9
|
-
border-radius: @border-radius @border-radius 0 0 !important;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
&__close {
|
|
13
|
-
width: 100%;
|
|
14
|
-
position: relative;
|
|
15
|
-
margin-top: 15px;
|
|
16
|
-
display: flex;
|
|
17
|
-
justify-content: flex-end;
|
|
18
|
-
align-items: center;
|
|
19
|
-
|
|
20
|
-
&--icon {
|
|
21
|
-
width: 32px;
|
|
22
|
-
height: 32px;
|
|
23
|
-
cursor: pointer;
|
|
24
|
-
background-color: transparent;
|
|
25
|
-
outline: none;
|
|
26
|
-
border: none;
|
|
27
|
-
|
|
28
|
-
&:hover {
|
|
29
|
-
opacity: 75%;
|
|
30
|
-
transition: 200ms;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
&::before,
|
|
34
|
-
&::after {
|
|
35
|
-
position: absolute;
|
|
36
|
-
right: 25px;
|
|
37
|
-
top: 0;
|
|
38
|
-
content: ' ';
|
|
39
|
-
height: 33px;
|
|
40
|
-
width: 2px;
|
|
41
|
-
background-color: red;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
&:after {
|
|
45
|
-
transform: rotate(45deg);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
&:before {
|
|
49
|
-
transform: rotate(-45deg);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
&__container {
|
|
55
|
-
width: 100%;
|
|
56
|
-
height: 100%;
|
|
57
|
-
|
|
58
|
-
display: flex;
|
|
59
|
-
align-items: center;
|
|
60
|
-
justify-content: center;
|
|
61
|
-
color: @title-form-color;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
&__image {
|
|
65
|
-
display: flex;
|
|
66
|
-
flex-direction: column;
|
|
67
|
-
align-items: center;
|
|
68
|
-
width: 100%;
|
|
69
|
-
padding: 0 10px;
|
|
70
|
-
max-width: 700px;
|
|
71
|
-
max-height: 300px;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
&__title-img {
|
|
75
|
-
width: 100%;
|
|
76
|
-
text-align: center;
|
|
77
|
-
word-wrap: break-word;
|
|
78
|
-
}
|
|
79
|
-
}
|