/
AttendancePaidButton.tsx
44 lines (40 loc) · 1.5 KB
/
AttendancePaidButton.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { faUsdCircle } from "@fortawesome/pro-solid-svg-icons"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import * as React from "react"
import AttendanceService from "../api/services/attendance"
import "./AttendancePaidButton.css"
import UncontrolledTooltipWrapper from "./UncontrolledTooltipWrapper"
type Props = {
paid: boolean
attendanceId: number
funcRefresh: () => void
}
/** Komponenta zobrazující tlačítko pro platbu klienta za danou lekci. */
const AttendancePaidButton: React.FC<Props> = props => {
function onClick(): void {
const newPaid = !props.paid
const id = props.attendanceId
const data = { id, paid: newPaid }
AttendanceService.patch(data).then(() => props.funcRefresh())
}
const className = "AttendancePaidButton " + (props.paid ? "text-success" : "text-danger")
const title = "Označit lekci jako " + (props.paid ? "NE" : "") + "ZAPLACENOU"
return (
<>
<FontAwesomeIcon
id={"AttendancePaidButton_" + props.attendanceId}
icon={faUsdCircle}
size="2x"
className={className}
onClick={onClick}
data-qa="lecture_attendance_paid"
/>
<UncontrolledTooltipWrapper
placement="right"
target={"AttendancePaidButton_" + props.attendanceId}>
{title}
</UncontrolledTooltipWrapper>
</>
)
}
export default AttendancePaidButton