1
+ /* eslint-disable jsx-a11y/alt-text */
2
+ /* eslint-disable @next/next/no-img-element */
1
3
"use client"
2
4
3
5
import React , { useState } from "react"
4
6
import { Student } from "@prisma/client"
5
7
import fmt from "date-fns/format"
6
8
import { MousePointerSquareDashed } from "lucide-react"
9
+ import satori from "satori"
7
10
import { z } from "zod"
8
11
9
12
import { tcIssueFormSchema } from "@/lib/validations/student"
10
13
import { Avatar , AvatarFallback , AvatarImage } from "@/components/ui/avatar"
11
14
import { Separator } from "@/components/ui/separator"
12
15
13
16
import StudentForm from "./details-form"
17
+ import { generatePdf } from "./pdf-generation"
14
18
import SearchUser from "./search-user"
15
19
16
20
function TCPage ( ) {
17
21
const [ selected , setselected ] = useState < Student > ( )
18
- const onSubmit = ( data : z . infer < typeof tcIssueFormSchema > ) => { }
22
+ const onSubmit = async ( data : z . infer < typeof tcIssueFormSchema > ) => {
23
+ const geistRegular = await (
24
+ await fetch ( "/fonts/Geist-Regular.otf" )
25
+ ) . arrayBuffer ( )
26
+ const geistMedium = await (
27
+ await fetch ( "/fonts/Geist-Medium.otf" )
28
+ ) . arrayBuffer ( )
29
+
30
+ const geistBold = await ( await fetch ( "/fonts/Geist-Bold.otf" ) ) . arrayBuffer ( )
31
+
32
+ const svg = await satori ( TCFormat ( ) , {
33
+ height : 841.89 ,
34
+ width : 595.28 ,
35
+ fonts : [
36
+ {
37
+ name : "Geist" ,
38
+ data : geistRegular ,
39
+ weight : 400 ,
40
+ style : "normal" ,
41
+ } ,
42
+ {
43
+ name : "Geist" ,
44
+ data : geistMedium ,
45
+ weight : 500 ,
46
+ style : "normal" ,
47
+ } ,
48
+ {
49
+ name : "Geist" ,
50
+ data : geistBold ,
51
+ weight : 800 ,
52
+ style : "normal" ,
53
+ } ,
54
+ ] ,
55
+ } )
56
+ generatePdf ( svg , 595.28 , 841.89 , ( url ) => {
57
+ window . open ( url , "_blank" )
58
+ } )
59
+ }
19
60
return (
20
61
< div className = "p-5" >
21
62
< SearchUser value = { selected } setValue = { setselected } />
@@ -68,7 +109,7 @@ function TCPage() {
68
109
</ div >
69
110
</ div >
70
111
< Separator />
71
- < div className = "mt-3" >
112
+ < div className = "mt-3 " >
72
113
< StudentForm id = { selected . id } onSubmit = { onSubmit } />
73
114
</ div >
74
115
</ >
@@ -83,3 +124,217 @@ function TCPage() {
83
124
}
84
125
85
126
export default TCPage
127
+
128
+ export const TCFormat = ( ) => {
129
+ const fontScale = 0.8
130
+ return (
131
+ < div
132
+ style = { {
133
+ height : "100%" ,
134
+ width : "100%" ,
135
+ display : "flex" ,
136
+ flexDirection : "column" ,
137
+ alignItems : "center" ,
138
+ justifyContent : "flex-start" ,
139
+ fontFamily : "Geist" ,
140
+ backgroundColor : "#fff" ,
141
+ fontSize : fontScale * 12 ,
142
+ paddingTop : 20 ,
143
+ fontWeight : 500 ,
144
+ } }
145
+ >
146
+ < img
147
+ width = { 100 }
148
+ src = { "/images/govt-logo.png" }
149
+ style = { {
150
+ maxWidth : "80%" ,
151
+ } }
152
+ />
153
+
154
+ < div
155
+ style = { {
156
+ display : "flex" ,
157
+ flexDirection : "column" ,
158
+ alignItems : "center" ,
159
+ fontSize : fontScale * 10 ,
160
+ textTransform : "uppercase" ,
161
+ } }
162
+ >
163
+ < div > Government of Kerala</ div >
164
+ < div > Department of Technical Education</ div >
165
+ </ div >
166
+ < div
167
+ style = { {
168
+ fontSize : fontScale * 16 ,
169
+ fontWeight : 800 ,
170
+ textTransform : "uppercase" ,
171
+ } }
172
+ >
173
+ Govt. Polytechnic College, Perinthalmanna
174
+ </ div >
175
+ < div > Angadipuram, Malappuram Dist, Kerala State - 679321</ div >
176
+ < div > Phone: 04933 227253, Email: polypmna@gptcperinthalmanna.in</ div >
177
+
178
+ < div
179
+ style = { {
180
+ marginTop : 8 ,
181
+ textDecorationLine : "underline" ,
182
+ fontSize : fontScale * 16 ,
183
+ fontWeight : 800 ,
184
+ textTransform : "uppercase" ,
185
+ } }
186
+ >
187
+ TRANSFER CERTIFICATE
188
+ </ div >
189
+
190
+ < div
191
+ style = { {
192
+ marginTop : 0 ,
193
+ display : "flex" ,
194
+ flexDirection : "row" ,
195
+ width : "100%" ,
196
+ justifyContent : "space-between" ,
197
+ paddingLeft : 20 ,
198
+ paddingRight : 20 ,
199
+ } }
200
+ >
201
+ < div
202
+ style = { {
203
+ marginTop : 0 ,
204
+ borderWidth : 1 ,
205
+ paddingLeft : 10 ,
206
+ paddingRight : 10 ,
207
+ padding : 5 ,
208
+ fontSize : fontScale * 14 ,
209
+ borderColor : "#000" ,
210
+ fontWeight : 600 ,
211
+ } }
212
+ >
213
+ TC No. 178/22-23
214
+ </ div >
215
+ < div
216
+ style = { {
217
+ marginTop : 0 ,
218
+ borderWidth : 1 ,
219
+ paddingLeft : 10 ,
220
+ paddingRight : 10 ,
221
+ padding : 5 ,
222
+ fontSize : fontScale * 14 ,
223
+ borderColor : "#000" ,
224
+ fontWeight : 600 ,
225
+ } }
226
+ >
227
+ Admission No. 11948
228
+ </ div >
229
+ </ div >
230
+ < div
231
+ style = { {
232
+ display : "flex" ,
233
+ flexDirection : "column" ,
234
+ width : "100%" ,
235
+ padding : 20 ,
236
+ } }
237
+ >
238
+ { /* Repeat this block */ }
239
+ < div
240
+ style = { {
241
+ display : "flex" ,
242
+ flexDirection : "row" ,
243
+ width : "100%" ,
244
+ justifyContent : "space-between" ,
245
+ } }
246
+ >
247
+ < div > Name of Pupil ( in block letters)</ div >
248
+ < div
249
+ style = { {
250
+ display : "flex" ,
251
+ flexDirection : "row" ,
252
+ width : "50%" ,
253
+ justifyContent : "flex-start" ,
254
+ } }
255
+ >
256
+ < div style = { { marginRight : 20 } } > : </ div >
257
+ < div > AMAL KRISHNAN. P</ div >
258
+ </ div >
259
+ </ div >
260
+ </ div >
261
+ { /* Repeat this block */ }
262
+ < div
263
+ style = { {
264
+ display : "flex" ,
265
+ flexDirection : "row" ,
266
+ width : "100%" ,
267
+ justifyContent : "flex-end" ,
268
+ padding : 20 ,
269
+ } }
270
+ >
271
+ < div
272
+ style = { {
273
+ display : "flex" ,
274
+ flexDirection : "row" ,
275
+ justifyContent : "flex-start" ,
276
+ } }
277
+ >
278
+ < div > Signature of the Head of institution with seal</ div >
279
+ </ div >
280
+ </ div >
281
+ < div
282
+ style = { {
283
+ marginTop : 20 ,
284
+ borderTopWidth : 1 ,
285
+ borderColor : "#eee" ,
286
+ width : "100%" ,
287
+ paddingTop : 20 ,
288
+ display : "flex" ,
289
+ flexDirection : "column" ,
290
+ alignItems : "center" ,
291
+ fontSize : fontScale * 12 ,
292
+ } }
293
+ >
294
+ < div
295
+ style = { {
296
+ textDecorationLine : "underline" ,
297
+ fontSize : fontScale * 16 ,
298
+ fontWeight : 800 ,
299
+ marginBottom : 10 ,
300
+ textTransform : "uppercase" ,
301
+ textAlign : "center" ,
302
+ } }
303
+ >
304
+ Course and Conduct Certificate
305
+ </ div >
306
+ < div > This is to certify that Sri./Kum.</ div >
307
+ < div
308
+ style = { {
309
+ fontWeight : 800 ,
310
+ } }
311
+ >
312
+ AMAL KRISHNAN
313
+ </ div >
314
+ < div > was as bonafide student of this institution</ div >
315
+ < div > from 25/07/2019 to 28/06/2022.</ div >
316
+ < div > She/He completed the prescribed course of studies for the</ div >
317
+ < div > Diplama Examination in Electronics Engg.</ div >
318
+ < div > His/Her Conduct and Character are Good.</ div >
319
+
320
+ < div
321
+ style = { {
322
+ display : "flex" ,
323
+ flexDirection : "row" ,
324
+ justifyContent : "space-between" ,
325
+ width : "100%" ,
326
+ padding : 20 ,
327
+ alignItems : "flex-end" ,
328
+ } }
329
+ >
330
+ < div style = { { display : "flex" , flexDirection : "column" } } >
331
+ < div > Date: 12/04/2013</ div >
332
+ < div > Place: Perinthalmanna</ div >
333
+ </ div >
334
+
335
+ < div > Signature of the Head of institution with seal</ div >
336
+ </ div >
337
+ </ div >
338
+ </ div >
339
+ )
340
+ }
0 commit comments