-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnection.go
166 lines (144 loc) · 4.55 KB
/
connection.go
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package main
import (
"log"
"net/http"
)
func handleFormSubmission(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "Invalid request method", http.StatusMethodNotAllowed)
return
}
err := r.ParseForm()
if err != nil {
log.Printf("Error parsing form: %v", err)
http.Error(w, "Error parsing form", http.StatusBadRequest)
return
}
templateType := r.FormValue("templateType")
if !isTemplateAvailable(templateType) {
http.Error(w, "Selected template is not available. Please choose another.", http.StatusBadRequest)
return
}
FirstName := r.FormValue("FirstName")
LastName := r.FormValue("LastName")
Email := r.FormValue("Email")
Phone := r.FormValue("Phone")
Website := r.FormValue("PersonalWebsite")
Address := r.FormValue("Address")
Profile := r.FormValue("Profile")
userData := UserData{
FirstName: FirstName,
LastName: LastName,
Email: Email,
Phone: Phone,
Website: Website,
Location: Address,
Profile: Profile,
}
// Handle multiple experience entries
companies := r.Form["Company"]
positions := r.Form["Position"]
startDates := r.Form["Experience-StartDate"]
endDates := r.Form["Experience-EndDate"]
highlights := r.Form["Highlights"]
for i := range companies {
exp := Experience{
Company: companies[i],
Position: positions[i],
StartDate: startDates[i],
EndDate: endDates[i],
Highlights: []string{highlights[i]}, // Handle multiple highlights similarly
}
userData.Experience = append(userData.Experience, exp)
}
// Handle multiple education entries similarly
Institutions := r.Form["Institution"]
Degree := r.Form["Area"]
StudyType := r.Form["StudyType"]
StartDates := r.Form["Education-StartDate"]
EndDates := r.Form["Education-EndDate"]
GPA := r.Form["GPA"]
for i := range Institutions {
edu := Education{
Institution: Institutions[i],
Area: Degree[i],
StudyType: StudyType[i],
StartDate: StartDates[i],
EndDate: EndDates[i],
GPA: GPA[i],
}
userData.Education = append(userData.Education, edu)
}
// Handle multiple skill entries similarly
Skills := r.Form["Skill"]
Levels := r.Form["Level"]
Keywords := r.Form["Keywords"]
for i := range Skills {
skill := Skill{
Name: Skills[i],
Level: Levels[i],
Keywords: []string{Keywords[i]}, // Handle multiple keywords similarly
}
userData.Skills = append(userData.Skills, skill)
}
// Handle multiple project entries similarly
Projects := r.Form["projectName"]
Descriptions := r.Form["projectDescription"]
Links := r.Form["projectLink"]
ProjectStartDates := r.Form["Project-StartDate"]
ProjectEndDates := r.Form["Project-EndDate"]
for i := range Projects {
project := Project{
Name: Projects[i],
Description: Descriptions[i],
Link: Links[i],
StartDate: ProjectStartDates[i],
EndDate: ProjectEndDates[i],
}
userData.Projects = append(userData.Projects, project)
}
// Handle multiple award entries similarly
Awards := r.Form["awardName"]
AwardDates := r.Form["awardDate"]
AwardLinks := r.Form["awardLink"]
AwardSummaries := r.Form["summary"]
for i := range Awards {
award := Award{
Title: Awards[i],
Date: AwardDates[i],
Awarder: AwardLinks[i],
Summary: AwardSummaries[i],
}
userData.Awards = append(userData.Awards, award)
}
// Handle multiple certificate entries similarly
Certificates := r.Form["certificationName"]
CertificateDates := r.Form["certificationDate"]
CertificateLicenses := r.Form["certificationLink"]
for i := range Certificates {
certificate := Certificate{
Title: Certificates[i],
Date: CertificateDates[i],
License: CertificateLicenses[i],
}
userData.Certificates = append(userData.Certificates, certificate)
}
// Handle multiple language entries similarly
Languages := r.Form["Language"]
Fluencies := r.Form["Fluency"]
for i := range Languages {
language := Language{
Language: Languages[i],
Fluency: Fluencies[i],
}
userData.Languages = append(userData.Languages, language)
}
log.Printf("Received user data: %+v", userData)
// Call previewResumeTemplate to generate HTML preview
err = previewResumeTemplate(&userData, templateType, w)
if err != nil {
log.Printf("Error generating template: %v", err)
http.Error(w, "Error generating template", http.StatusInternalServerError)
return
}
}