Skip to content

Commit 1ccd17a

Browse files
feat(organisms): indicadores en eventos tipo clases (#779)
1 parent 72d62b8 commit 1ccd17a

10 files changed

Lines changed: 108 additions & 5 deletions

File tree

src/atoms/Icons/Remote.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Base, BaseProps } from './Base'
2+
3+
export function Remote(props: BaseProps): JSX.Element {
4+
return (
5+
<Base {...props} w="16px" h="16px" viewBox="0 0 16 16" title="remote">
6+
<path
7+
d="M15 11V4C15 2.864 14.136 2 13 2H3C1.864 2 1 2.864 1 4V11H0V12C0 13.105 0.895 14 2 14H14C15.105 14 16 13.105 16 12V11H15ZM3 4H13V11H3V4Z"
8+
fill="currentColor"
9+
/>
10+
</Base>
11+
)
12+
}
13+
14+
Remote.displayName = 'Remote'

src/atoms/Icons/Time.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Base, BaseProps } from './Base'
2+
3+
export function Time(props: BaseProps): JSX.Element {
4+
return (
5+
<Base {...props} w="16px" h="16px" viewBox="0 0 16 16" title="Time">
6+
<path
7+
fill="currentColor"
8+
d="M8 0C3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm4 9H7V4h2v3h3v2z"
9+
/>
10+
</Base>
11+
)
12+
}
13+
14+
Time.displayName = 'Time'

src/atoms/Icons/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export * from './GoBack'
1111
export * from './Multimedia'
1212
export * from './Loader'
1313
export * from './Profile'
14+
export * from './Remote'
1415
export * from './Schedule'
16+
export * from './Time'
1517
export * from './TinyAlertInfo'
1618
export * from './TinyAlertError'
1719
export * from './TinyAlertWarning'

src/documentation/pages/Organisms/CalendarDropdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ const events = [
271271
start: '2027-01-01T02:59:00.000Z',
272272
end: '2027-01-01T03:59:00.000Z',
273273
duration_in_minutes: 60,
274-
type: 'answers-schedule-deadline',
274+
type: 'cv-events',
275275
id_resource: 853909,
276276
associated_resource: {
277277
id: 1,
@@ -299,7 +299,7 @@ const events = [
299299
start: '2027-01-01T02:59:00.000Z',
300300
end: '2027-01-01T03:59:00.000Z',
301301
duration_in_minutes: 60,
302-
type: 'answers-schedule-deadline',
302+
type: 'in-person',
303303
id_resource: 848781,
304304
associated_resource: {
305305
id: 1,

src/documentation/pages/Organisms/EventsList.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export const EventsListPage = (): JSX.Element => {
8080
type="in-person"
8181
showCourse
8282
courseName="[Pruebas TI] - Herramientas para la Gestión Estratégica de Procesos"
83+
duration={40}
8384
/>
8485
</Box>
8586

@@ -123,6 +124,7 @@ interface IEventList {
123124
color?: string // Color del curso asociado
124125
day: string // Día de la semana
125126
date: string // Fecha
127+
duration_in_minutes?: number // Duración del evento en minutos
126128
time: string // Hora
127129
name: string // Nombre del evento
128130
hasNotification?: boolean // Indica si el evento tiene notificación

src/molecules/Buttons/BtnTertiary.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
Multimedia,
1212
AcademicRecord,
1313
Download,
14+
Time,
15+
Remote,
1416
} from '@/atoms/Icons'
1517

1618
type XOR<T, U> = T | U extends object
@@ -31,6 +33,8 @@ export interface propsTertiaryBtn {
3133
| 'multimedia'
3234
| 'record'
3335
| 'download'
36+
| 'time'
37+
| 'remote'
3438
| 'noIcon'
3539
m?: string
3640
onClick?: (e: React.MouseEvent<HTMLElement>) => void
@@ -90,6 +94,8 @@ export function BtnTertiary({
9094
multimedia: <Multimedia color={colorIcon} />,
9195
password: <Password color={colorIcon} />,
9296
record: <AcademicRecord color={colorIcon} />,
97+
time: <Time color={colorIcon} />,
98+
remote: <Remote color={colorIcon} />,
9399
noIcon: <></>,
94100
}
95101

src/organisms/Calendar/Dropdown/CalendarDropdown/Components/EventsGroup.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export const EventsGroup = ({
6969
courseName={event.course.name}
7070
day={event.formatedDate.day}
7171
date={event.formatedDate.date}
72+
duration={event.duration_in_minutes}
7273
time={event.formatedDate.time}
7374
color={
7475
event.course_id && colors?.[event.course_id]

src/organisms/Calendar/Dropdown/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface Event {
1818
associated_resource: AssociatedResource
1919
course: Course
2020
course_id: number
21+
duration_in_minutes?: number
2122
end: string
2223
start: string
2324
formatedDate: FormattedDate

src/organisms/Calendar/EventsList/EventsList.test.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { ChakraProvider } from '@chakra-ui/react'
22
import { render, RenderResult, screen } from '@testing-library/react'
33
import userEvent from '@testing-library/user-event'
4+
import { ComponentProps } from 'react'
45

56
import { EventsList } from './EventsList'
67

7-
const renderComponent = (onClick?: () => void): RenderResult =>
8+
const renderComponent = (
9+
onClick?: () => void,
10+
props?: Partial<ComponentProps<typeof EventsList>>
11+
): RenderResult =>
812
render(
913
<ChakraProvider>
1014
<EventsList
@@ -18,6 +22,7 @@ const renderComponent = (onClick?: () => void): RenderResult =>
1822
text="Curso"
1923
time="19:00 hrs."
2024
type="in-person"
25+
{...props}
2126
/>
2227
</ChakraProvider>
2328
)
@@ -39,4 +44,24 @@ describe('EventsList', () => {
3944

4045
expect(screen.getByText('Evento demo')).toBeInTheDocument()
4146
})
47+
48+
it('renders duration for online or in-person events with positive minutes', () => {
49+
const { container } = renderComponent(undefined, { duration: 40 })
50+
51+
expect(screen.getByText('Link clase online')).toBeInTheDocument()
52+
expect(container).toHaveTextContent(/40\s*min/)
53+
})
54+
55+
it('does not render duration when minutes are zero', () => {
56+
renderComponent(undefined, { duration: 0 })
57+
58+
expect(screen.queryByText('Duración:')).not.toBeInTheDocument()
59+
})
60+
61+
it('does not render course text for cv-events', () => {
62+
renderComponent(undefined, { type: 'cv-events' })
63+
64+
expect(screen.queryByText('Curso:')).not.toBeInTheDocument()
65+
expect(screen.getByText('Curso demo')).toBeInTheDocument()
66+
})
4267
})

src/organisms/Calendar/EventsList/EventsList.tsx

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Remote, Time } from '@/atoms/Icons'
12
import { Box } from '@chakra-ui/react'
23
import { vars } from '@theme'
34

@@ -8,6 +9,7 @@ export interface IEventList {
89
courseName?: string
910
day: string
1011
date: string
12+
duration?: number
1113
name: string
1214
hasNotification?: boolean
1315
onClick?: () => void
@@ -24,6 +26,7 @@ export const EventsList = ({
2426
color,
2527
day,
2628
date,
29+
duration,
2730
name,
2831
hasNotification,
2932
onClick,
@@ -38,6 +41,9 @@ export const EventsList = ({
3841
const hoverBg = vars('colors-neutral-cultured2') ?? '#F8F8F8'
3942
const isClickable = Boolean(onClick)
4043

44+
const showEventDuration =
45+
['online', 'in-person'].includes(type) && duration !== undefined && duration > 0
46+
4147
const initOrEnd = [
4248
'end-course',
4349
'init-course',
@@ -55,11 +61,20 @@ export const EventsList = ({
5561
const detailTextStyle = {
5662
color: vars('colors-neutral-gray') ?? '#808080',
5763
fontSize: '14px',
58-
display: 'inline',
64+
alignItems: 'center',
65+
display: 'flex',
5966
gap: '4px',
6067
lineHeight: 'normal',
6168
}
6269

70+
const eventIconStyle = {
71+
alignItems: 'center',
72+
display: 'inline-flex',
73+
height: '24px',
74+
justifyContent: 'center',
75+
minWidth: '16px',
76+
}
77+
6378
return (
6479
<Box
6580
className="eventsList"
@@ -116,7 +131,30 @@ export const EventsList = ({
116131

117132
{showCourse && !initOrEnd && (
118133
<Box as="span" sx={detailTextStyle}>
119-
<strong>{text ? `${text}:` : 'Curso:'}</strong> {courseName}
134+
{type === 'cv-events' ? <></> : <strong>{text ? `${text}:` : 'Curso:'}</strong>}{' '}
135+
{courseName}
136+
</Box>
137+
)}
138+
139+
{showEventDuration && (
140+
<Box display="flex" flexDirection="row" gap="8px" flexWrap="wrap">
141+
<Box
142+
as="span"
143+
sx={detailTextStyle}
144+
paddingRight="8px"
145+
borderRight={`1px solid ${vars('colors-neutral-platinum')}`}
146+
>
147+
<Box as="span" sx={eventIconStyle}>
148+
<Remote color={vars('colors-main-ziggurat')} />
149+
</Box>
150+
Link clase online
151+
</Box>
152+
<Box as="span" sx={detailTextStyle}>
153+
<Box as="span" sx={eventIconStyle}>
154+
<Time color={vars('colors-main-ziggurat')} />
155+
</Box>
156+
{duration} min
157+
</Box>
120158
</Box>
121159
)}
122160

0 commit comments

Comments
 (0)