feat: add project icon picker component and integrate with project management
- Implemented ProjectIconPicker component for selecting project icons. - Created ProjectIcon component to display selected icons. - Updated calendar page to remove unused PageHeading component. - Modified growth page to enhance UI and improve text clarity. - Refactored index page to include project icons and improve layout. - Added mine page for user profile management with avatar selection. - Introduced projects-sort page for managing project order with drag-and-drop functionality. - Enhanced projects page to allow icon selection when adding or editing projects. - Updated record page to streamline user experience and improve form actions. - Adjusted practice service to support project icon management. - Added tests for project saving functionality to ensure correct handling of icons. - Updated global type definitions to support SVG and PNG imports.
This commit is contained in:
@@ -36,6 +36,7 @@ func NewAppHandler(pool *pgxpool.Pool, verifier IdentityVerifier, now func() tim
|
||||
mux.HandleFunc("POST /v1/session", a.login)
|
||||
mux.HandleFunc("GET /v1/projects", a.auth(a.projects))
|
||||
mux.HandleFunc("POST /v1/projects", a.auth(a.saveProject))
|
||||
mux.HandleFunc("PUT /v1/projects/order", a.auth(a.reorderProjects))
|
||||
mux.HandleFunc("PUT /v1/projects/{id}", a.auth(a.saveProject))
|
||||
mux.HandleFunc("DELETE /v1/projects/{id}", a.auth(a.removeProject))
|
||||
mux.HandleFunc("GET /v1/records", a.auth(a.records))
|
||||
@@ -139,14 +140,28 @@ func (a *app) projects(w http.ResponseWriter, r *http.Request, user string) erro
|
||||
}
|
||||
return err
|
||||
}
|
||||
func (a *app) saveProject(w http.ResponseWriter, r *http.Request, user string) error {
|
||||
func (a *app) reorderProjects(w http.ResponseWriter, r *http.Request, user string) error {
|
||||
var input struct {
|
||||
Name string `json:"name"`
|
||||
ProjectIDs []string `json:"projectIds"`
|
||||
}
|
||||
if err := decode(w, r, &input); err != nil {
|
||||
return err
|
||||
}
|
||||
p, err := a.store.SaveProject(r.Context(), user, r.PathValue("id"), input.Name)
|
||||
if err := a.store.ReorderProjects(r.Context(), user, input.ProjectIDs); err != nil {
|
||||
return err
|
||||
}
|
||||
respond(w, 200, map[string]string{"action": "reordered"})
|
||||
return nil
|
||||
}
|
||||
func (a *app) saveProject(w http.ResponseWriter, r *http.Request, user string) error {
|
||||
var input struct {
|
||||
Name string `json:"name"`
|
||||
IconID *string `json:"iconId"`
|
||||
}
|
||||
if err := decode(w, r, &input); err != nil {
|
||||
return err
|
||||
}
|
||||
p, err := a.store.SaveProject(r.Context(), user, r.PathValue("id"), input.Name, input.IconID)
|
||||
if err == nil {
|
||||
respond(w, 200, p)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user