diff --git a/assets/hanan/employee-medical-analytic.html b/assets/hanan/employee-medical-analytic.html index 4c0b470..6ee4077 100644 --- a/assets/hanan/employee-medical-analytic.html +++ b/assets/hanan/employee-medical-analytic.html @@ -139,18 +139,26 @@ License: You must have a valid license purchased only from themeforest(the above height: 40px; } - /* batas */ .items-content { padding: 24px; margin-bottom: 24px; } - .container { - padding: 24px; + .content-page { + padding-top: 24px; + padding-left: 24px; + padding-right: 24px; + padding-bottom: 24px; } .item-foto { width: 32px; height: 32px; } + .heading { + padding-top: 40px; + } + .card:hover { + background-color: rgba(197, 200, 211, 0.5); + } @@ -184,7 +192,7 @@ License: You must have a valid license purchased only from themeforest(the above -
+
@@ -208,8 +216,8 @@ License: You must have a valid license purchased only from themeforest(the above @@ -219,48 +227,94 @@ License: You must have a valid license purchased only from themeforest(the above
-
-
-
-
-

MCU Calon Karyawan

-
-
- Tanggal Pelaksanaan -
-
- 01/04/2024 - 06/04/2024 + + + -
-
-
-

MCU Calon Karyawan

-
-
- Tanggal Pelaksanaan -
- + + -
diff --git a/cmd/main.go b/cmd/main.go index 0258924..1ebb77a 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -62,6 +62,14 @@ func main() { lphs := handlers.NewLandingPageHandler(lps) handlers.SetupRoutesLandingPage(app, lphs) + eStore, err := db.NewEmployeeStore(dbName) + if err != nil { + app.Logger.Fatalf("failed to create store: %s", err) + } + el := services.NewServicesEmployee(services.Employee{}, eStore) + ehs := handlers.NewEmployeeHandler(el) + handlers.SetupRoutesEmployee(app, ehs) + app.Logger.Fatal(app.Start(":5000")) } diff --git a/handlers/employee.handler.go b/handlers/employee.handler.go new file mode 100644 index 0000000..971c31a --- /dev/null +++ b/handlers/employee.handler.go @@ -0,0 +1,42 @@ +package handlers + +import ( + "fmt" + + "github.com/a-h/templ" + "github.com/emarifer/go-templ-project-structure/services" + "github.com/emarifer/go-templ-project-structure/views/employee" + "github.com/labstack/echo/v4" +) + +type EmployeeService interface { + GetEmployeeService() ([]services.EmployeeService, error) +} + +func NewEmployeeHandler(us EmployeeService) *EmployeeHandler { + return &EmployeeHandler{ + EmployeeService: us, + } +} + +type EmployeeHandler struct { + EmployeeService EmployeeService +} + +func (eh *EmployeeHandler) ShowEmployee(c echo.Context) error { + udata, err := eh.EmployeeService.GetEmployeeService() + if err != nil { + // fmt.Println(err) + return err + } + + fmt.Printf("%+v\n", udata) + e := employee.ShowEmployee("Employee", employee.MainEmployee(employee.ListCardService(udata)), employee.CssEmployee(), employee.JsEmployee()) + return eh.View(c, e) +} + +func (eh *EmployeeHandler) View(c echo.Context, cmp templ.Component) error { + c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML) + + return cmp.Render(c.Request().Context(), c.Response().Writer) +} diff --git a/handlers/routes.go b/handlers/routes.go index 180cbe5..d9a137b 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -23,6 +23,10 @@ func SetupRoutesLandingPage(app *echo.Echo, h *LandingPageHandler) { Lp := app.Group("/landing_page") Lp.GET("/", h.ShowLandingPage) } +func SetupRoutesEmployee(app *echo.Echo, e *EmployeeHandler) { + employee := app.Group("/employee") + employee.GET("/", e.ShowEmployee) +} func SetupRoutesProject(app *echo.Echo) { } diff --git a/services/employee.services.go b/services/employee.services.go new file mode 100644 index 0000000..63cec64 --- /dev/null +++ b/services/employee.services.go @@ -0,0 +1,71 @@ +package services + +import ( + "time" + + "github.com/emarifer/go-templ-project-structure/db" +) + +func NewServicesEmployee(u Employee, uStore db.EmployeeStore) *ServicesEmployee { + + return &ServicesEmployee{ + Employee: u, + EmployeeStore: uStore, + } +} + +type Employee struct { + ID int `json:"id"` + Employeename string `json:"Employeename"` + Email string `json:"email"` + CreatedAt time.Time `json:"created_at,omitempty"` +} + +type EmployeeService struct { + EmployeeID int `json:"EmployeeID"` + EmployeeTitle string `json:"EmployeeTitle"` + EmployeeDescription string `json:"EmployeeDescription"` + EmployeeStartDate string `json:"EmployeeStartDate"` + EmployeeEndDate string `json:"EmployeeEndDate"` +} + +type ServicesEmployee struct { + Employee Employee + EmployeeStore db.EmployeeStore +} + +func (se *ServicesEmployee) GetEmployeeService() ([]EmployeeService, error) { + + data := []EmployeeService{ + { + EmployeeID: 1, + EmployeeTitle: "MCU Calon Karyawan", + EmployeeDescription: "Tanggal Pelaksanaan", + EmployeeStartDate: "01/04/2024", + EmployeeEndDate: "06/04/2024", + }, + { + EmployeeID: 2, + EmployeeTitle: "MCU Karyawan", + EmployeeDescription: "Tanggal Pelaksanaan", + EmployeeStartDate: "01/04/2024", + EmployeeEndDate: "06/04/2024", + }, + { + EmployeeID: 1, + EmployeeTitle: "MCU Eselon 1", + EmployeeDescription: "Tanggal Pelaksanaan", + EmployeeStartDate: "01/04/2024", + EmployeeEndDate: "06/04/2024", + }, + { + EmployeeID: 1, + EmployeeTitle: "MCU Eselon 2", + EmployeeDescription: "Tanggal Pelaksanaan", + EmployeeStartDate: "01/04/2024", + EmployeeEndDate: "06/04/2024", + }, + } + + return data, nil +} diff --git a/views/employee/employee.templ b/views/employee/employee.templ index 5ebfd73..80f81e8 100644 --- a/views/employee/employee.templ +++ b/views/employee/employee.templ @@ -4,7 +4,7 @@ import ( "github.com/emarifer/go-templ-project-structure/views/layout" ) -templ MainEmployee() { +templ MainEmployee(cardServiceComponent templ.Component) {
-
-
- -
- PT. Sadhana Abiyasa Sampoerna -
- - - - -
-
- - - Filter - - -
-
+ @HeadingEmployee("PT. Sadhana Abiyasa Sampoerna")
-
-
-
-
-

MCU Calon Karyawan

-
-
- Tanggal Pelaksanaan -
-
- 01/04/2024 - 06/04/2024 -
-
-
-
-
-
-

MCU Calon Karyawan

-
-
- Tanggal Pelaksanaan -
-
- 01/04/2024 - 06/04/2024 -
-
-
-
-
-
-

MCU Calon Karyawan

-
-
- Tanggal Pelaksanaan -
-
- 01/04/2024 - 06/04/2024 -
-
-
+
+ + @cardServiceComponent +
@@ -145,21 +82,32 @@ templ CssEmployee() { height: 40px; } - /* batas */ .items-content { padding: 24px; margin-bottom: 24px; } - .container { - padding: 24px; + .content-page { + padding-top: 24px; + padding-left: 24px; + padding-right: 24px; + padding-bottom: 24px; } .item-foto { width: 32px; height: 32px; } + .heading { + padding-top: 40px; + } + .card:hover { + background-color: rgba(197, 200, 211, 0.5); + } } +templ JsEmployee() { +} + templ ShowEmployee(title string, cmp templ.Component, css templ.Component, js templ.Component) { @layout.PlaygroundLayout(title, css, js) { @cmp diff --git a/views/employee/employee_templ.go b/views/employee/employee_templ.go index 75d5b0a..f91b28c 100644 --- a/views/employee/employee_templ.go +++ b/views/employee/employee_templ.go @@ -14,7 +14,7 @@ import ( "github.com/emarifer/go-templ-project-structure/views/layout" ) -func MainEmployee() templ.Component { +func MainEmployee(cardServiceComponent templ.Component) templ.Component { return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) if !templ_7745c5c3_IsBuffer { @@ -27,7 +27,23 @@ func MainEmployee() templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

MCU Calon Karyawan

Tanggal Pelaksanaan
01/04/2024 - 06/04/2024

MCU Calon Karyawan

Tanggal Pelaksanaan
01/04/2024 - 06/04/2024

MCU Calon Karyawan

Tanggal Pelaksanaan
01/04/2024 - 06/04/2024
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = HeadingEmployee("PT. Sadhana Abiyasa Sampoerna").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cardServiceComponent.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -51,7 +67,7 @@ func CssEmployee() templ.Component { templ_7745c5c3_Var2 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -62,6 +78,26 @@ func CssEmployee() templ.Component { }) } +func JsEmployee() templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var3 := templ.GetChildren(ctx) + if templ_7745c5c3_Var3 == nil { + templ_7745c5c3_Var3 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + func ShowEmployee(title string, cmp templ.Component, css templ.Component, js templ.Component) templ.Component { return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) @@ -70,12 +106,12 @@ func ShowEmployee(title string, cmp templ.Component, css templ.Component, js tem defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var3 := templ.GetChildren(ctx) - if templ_7745c5c3_Var3 == nil { - templ_7745c5c3_Var3 = templ.NopComponent + templ_7745c5c3_Var4 := templ.GetChildren(ctx) + if templ_7745c5c3_Var4 == nil { + templ_7745c5c3_Var4 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var4 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var5 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) if !templ_7745c5c3_IsBuffer { templ_7745c5c3_Buffer = templ.GetBuffer() @@ -90,7 +126,7 @@ func ShowEmployee(title string, cmp templ.Component, css templ.Component, js tem } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.PlaygroundLayout(title, css, js).Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = layout.PlaygroundLayout(title, css, js).Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/employee/employeecomponent.templ b/views/employee/employeecomponent.templ new file mode 100644 index 0000000..aa44900 --- /dev/null +++ b/views/employee/employeecomponent.templ @@ -0,0 +1,60 @@ +package employee + +import ( + "github.com/emarifer/go-templ-project-structure/services" +) + +templ CardService(title string, description string, startdate string, enddate string) { + +
+
+
+

{ title }

+
+
+ { description } +
+
+ { startdate } - { enddate } +
+
+
+
+} + +templ ListCardService(cardData []services.EmployeeService) { + for _, d := range cardData { + @CardService(d.EmployeeTitle, d.EmployeeDescription, d.EmployeeStartDate, d.EmployeeEndDate) + } +} + +templ HeadingEmployee(title string) { +
+
+ +
+ { title } +
+ + + + +
+
+ + + Filter + + +
+
+} diff --git a/views/employee/employeecomponent_templ.go b/views/employee/employeecomponent_templ.go new file mode 100644 index 0000000..ae708a5 --- /dev/null +++ b/views/employee/employeecomponent_templ.go @@ -0,0 +1,154 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package employee + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import "context" +import "io" +import "bytes" + +import ( + "github.com/emarifer/go-templ-project-structure/services" +) + +func CardService(title string, description string, startdate string, enddate string) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var2 string + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\employee\employeecomponent.templ`, Line: 12, Col: 35} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var3 string + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(description) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\employee\employeecomponent.templ`, Line: 15, Col: 61} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var4 string + templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(startdate) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\employee\employeecomponent.templ`, Line: 18, Col: 59} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" - ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var5 string + templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(enddate) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\employee\employeecomponent.templ`, Line: 18, Col: 73} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func ListCardService(cardData []services.EmployeeService) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var6 := templ.GetChildren(ctx) + if templ_7745c5c3_Var6 == nil { + templ_7745c5c3_Var6 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + for _, d := range cardData { + templ_7745c5c3_Err = CardService(d.EmployeeTitle, d.EmployeeDescription, d.EmployeeStartDate, d.EmployeeEndDate).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func HeadingEmployee(title string) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var7 := templ.GetChildren(ctx) + if templ_7745c5c3_Var7 == nil { + templ_7745c5c3_Var7 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var8 string + templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(title) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\employee\employeecomponent.templ`, Line: 36, Col: 11} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +}