|
1 | 1 | import React, { useEffect, useState } from "react";
|
2 | 2 | import "./certificate.css";
|
| 3 | +import opensignLogo from "../../assests/open-sign-logo.png"; |
3 | 4 |
|
4 |
| -import { Page, Text, View, Document, StyleSheet } from "@react-pdf/renderer"; |
| 5 | +import { |
| 6 | + Page, |
| 7 | + Text, |
| 8 | + View, |
| 9 | + Document, |
| 10 | + StyleSheet, |
| 11 | + Image |
| 12 | +} from "@react-pdf/renderer"; |
5 | 13 |
|
6 | 14 | function Certificate({ pdfData }) {
|
7 | 15 | const [isMultiSigners, setIsMultiSigners] = useState();
|
@@ -49,70 +57,34 @@ function Certificate({ pdfData }) {
|
49 | 57 | fontSize: "11px",
|
50 | 58 | marginBottom: "10px",
|
51 | 59 | color: "gray"
|
| 60 | + }, |
| 61 | + image: { |
| 62 | + width: "71px", |
| 63 | + height: "17px" |
52 | 64 | }
|
53 | 65 | });
|
54 | 66 |
|
55 | 67 | const generatedDate = () => {
|
56 | 68 | const newDate = new Date();
|
57 |
| - const localExpireDate = newDate.toLocaleDateString("en-US", { |
58 |
| - day: "numeric", |
59 |
| - month: "long", |
60 |
| - year: "numeric" |
61 |
| - }); |
62 |
| - |
63 |
| - var currentOffset = newDate.getTimezoneOffset(); |
64 |
| - |
65 |
| - var ISTOffset = 330; // IST offset UTC +5:30 |
66 |
| - |
67 |
| - var ISTTime = new Date( |
68 |
| - newDate.getTime() + (ISTOffset + currentOffset) * 60000 |
69 |
| - ); |
70 |
| - |
71 |
| - // ISTTime now represents the time in IST coordinates |
72 |
| - |
73 |
| - var hoursIST = ISTTime.getHours(); |
74 |
| - var minutesIST = ISTTime.getMinutes(); |
| 69 | + const utcTime = newDate.toUTCString(); |
75 | 70 |
|
76 | 71 | return (
|
77 | 72 | <Text
|
78 | 73 | style={{
|
79 |
| - textAlign: "right", |
80 | 74 | color: "gray",
|
81 |
| - fontSize: "10px", |
82 |
| - marginBottom: "30px" |
| 75 | + fontSize: "10px" |
83 | 76 | }}
|
84 | 77 | >
|
85 |
| - Generated On {localExpireDate} {hoursIST}:{minutesIST} IST |
| 78 | + Generated On {utcTime} |
86 | 79 | </Text>
|
87 | 80 | );
|
88 | 81 | };
|
89 | 82 | const changeCompletedDate = () => {
|
90 | 83 | const completedOn = pdfData[0].updatedAt;
|
91 | 84 | const newDate = new Date(completedOn);
|
92 |
| - const localExpireDate = newDate.toLocaleDateString("en-US", { |
93 |
| - day: "numeric", |
94 |
| - month: "long", |
95 |
| - year: "numeric" |
96 |
| - }); |
97 |
| - |
98 |
| - var currentOffset = newDate.getTimezoneOffset(); |
| 85 | + const utcTime = newDate.toUTCString(); |
99 | 86 |
|
100 |
| - var ISTOffset = 330; // IST offset UTC +5:30 |
101 |
| - |
102 |
| - var ISTTime = new Date( |
103 |
| - newDate.getTime() + (ISTOffset + currentOffset) * 60000 |
104 |
| - ); |
105 |
| - |
106 |
| - // ISTTime now represents the time in IST coordinates |
107 |
| - |
108 |
| - var hoursIST = ISTTime.getHours(); |
109 |
| - var minutesIST = ISTTime.getMinutes(); |
110 |
| - |
111 |
| - return ( |
112 |
| - <Text style={styles.textStyle2}> |
113 |
| - {localExpireDate} {hoursIST}:{minutesIST} IST |
114 |
| - </Text> |
115 |
| - ); |
| 87 | + return <Text style={styles.textStyle2}>{utcTime}</Text>; |
116 | 88 | };
|
117 | 89 |
|
118 | 90 | const signerName = (data) => {
|
@@ -143,7 +115,19 @@ function Certificate({ pdfData }) {
|
143 | 115 | {/** Page defines a single page of content. */}
|
144 | 116 | <Page size="A4" style={styles.page}>
|
145 | 117 | <View style={styles.section1}>
|
146 |
| - {generatedDate()} |
| 118 | + <View |
| 119 | + style={{ |
| 120 | + display: "flex", |
| 121 | + flexDirection: "row", |
| 122 | + justifyContent: "space-between", |
| 123 | + alignItems: "center", |
| 124 | + marginBottom: "30px" |
| 125 | + }} |
| 126 | + > |
| 127 | + <Image src={opensignLogo} style={styles.image} /> |
| 128 | + {generatedDate()} |
| 129 | + </View> |
| 130 | + |
147 | 131 | <View style={{ justifyContent: "center" }}>
|
148 | 132 | <Text
|
149 | 133 | style={{
|
@@ -182,7 +166,9 @@ function Certificate({ pdfData }) {
|
182 | 166 | </Text>
|
183 | 167 | <Text style={styles.textStyle}>
|
184 | 168 | Organization :
|
185 |
| - <Text style={styles.textStyle2}>__</Text> |
| 169 | + <Text style={styles.textStyle2}> |
| 170 | + {pdfData[0].ExtUserPtr.Company} |
| 171 | + </Text> |
186 | 172 | </Text>
|
187 | 173 | <Text style={styles.textStyle}>
|
188 | 174 | Completed on : {changeCompletedDate()}
|
|
0 commit comments