package cms import "tm/pkg/response" // CMSForm represents the form for creating/updating the CMS type CMSForm struct { Key string `json:"key" valid:"required,length(2|100)" example:"SW-001"` Language string `json:"language" valid:"optional,length(2|100)" example:"en"` CompanyName string `json:"company_name" valid:"optional,length(2|100)" example:"Opplens"` Country string `json:"country" valid:"optional,length(3|3)" example:"SWE"` Type CMSType `json:"type" valid:"optional,in(company|organization)" example:"company"` Hero heroSectionForm `json:"hero" valid:"optional"` Chart chartSectionForm `json:"chart" valid:"optional"` Features cardSectionForm `json:"features" valid:"optional"` Challenges cardSectionForm `json:"challenges" valid:"optional"` Advantages cardSectionForm `json:"advantages" valid:"optional"` Contact contactSectionForm `json:"contact" valid:"optional"` Footer footerSectionForm `json:"footer" valid:"optional"` } // heroSectionForm represents the form for creating/updating the hero section type heroSectionForm struct { Title string `json:"title" valid:"optional,length(2|100)" example:"Hero Title"` Description string `json:"description" valid:"optional,length(2|1000)" example:"Hero Description"` ButtonText string `json:"button_text" valid:"optional,length(2|100)" example:"Button Text"` ButtonLink string `json:"button_link" valid:"optional,url" example:"https://example.com"` GifFile string `json:"gif_file" valid:"optional,url" example:"https://example.com/gif.gif"` } // chartSectionForm represents the form for creating/updating the chart section type chartSectionForm struct { Title string `json:"title" valid:"optional,length(2|100)" example:"Chart Title"` MissedAmount string `json:"missed_amount" valid:"optional,length(2|100)" example:"Missed Amount"` Data []chartPointForm `json:"data" valid:"optional"` } // chartPointForm represents the form for creating/updating a chart point type chartPointForm struct { Key string `json:"key" valid:"optional,length(2|100)" example:"Key"` Value int `json:"value" valid:"optional,range(0|1000000)" example:"1000000"` } // cardSectionForm represents the form for creating/updating the card section type cardSectionForm struct { Title string `json:"title" valid:"optional,length(2|100)" example:"Card Title"` Description string `json:"description" valid:"optional,length(2|1000)" example:"Card Description"` Cards []cardForm `json:"cards" valid:"optional"` } // cardForm represents the form for creating/updating a card type cardForm struct { Icon string `json:"icon" valid:"optional,url" example:"https://example.com/icon.png"` Title string `json:"title" valid:"optional,length(2|100)" example:"Card Title"` Description string `json:"description" valid:"optional,length(2|1000)" example:"Card Description"` } // contactSectionForm represents the form for creating/updating the contact section type contactSectionForm struct { Title string `json:"title" valid:"optional,length(2|100)" example:"Contact Title"` Description string `json:"description" valid:"optional,length(2|1000)" example:"Contact Description"` SubmitButtonText string `json:"submit_button_text" valid:"optional,length(2|100)" example:"Submit Button Text"` Fields []formFieldForm `json:"fields" valid:"optional"` } // formFieldForm represents the form for creating/updating a form field type formFieldForm struct { Name string `json:"name" valid:"optional,length(2|100)" example:"Name"` Label string `json:"label" valid:"optional,length(2|100)" example:"Label"` Placeholder string `json:"placeholder" valid:"optional,length(2|100)" example:"Placeholder"` Required bool `json:"required" valid:"optional" example:"true"` } // footerSectionForm represents the form for creating/updating the footer section type footerSectionForm struct { Email string `json:"email" valid:"optional,email" example:"info@example.com"` Phone string `json:"phone" valid:"optional,length(10|20)" example:"+1234567890"` Location string `json:"location" valid:"optional,length(2|100)" example:"Location"` Tagline string `json:"tagline" valid:"optional,length(2|100)" example:"Tagline"` Copyright string `json:"copyright" valid:"optional,length(2|100)" example:"Copyright"` } // SearchCMSForm represents the form for searching CMS entries type SearchCMSForm struct { Search *string `query:"q" valid:"optional"` Key *string `query:"key" valid:"optional,length(2|100)"` } // CMSResponse represents the CMS data sent in API responses type CMSResponse struct { ID string `json:"id"` Key string `json:"key"` Language string `json:"language"` CompanyName string `json:"company_name"` Country string `json:"country"` Type CMSType `json:"type"` Hero heroSection `json:"hero"` Chart chartSection `json:"chart"` Features cardSection `json:"features"` Challenges cardSection `json:"challenges"` Advantages cardSection `json:"advantages"` Contact contactSection `json:"contact"` Footer footerSection `json:"footer"` CreatedAt int64 `json:"created_at"` UpdatedAt int64 `json:"updated_at"` } // CMSListResponse represents the response for listing CMS entries type CMSListResponse struct { CMS []*CMSResponse `json:"cms"` Meta *response.Meta `json:"-"` } // ToResponse converts CMS to CMSResponse func (c *CMS) ToResponse() *CMSResponse { return &CMSResponse{ ID: c.GetID(), Key: c.Key, Language: c.Language, CompanyName: c.CompanyName, Country: c.Country, Type: c.Type, Hero: c.Hero, Chart: c.Chart, Features: c.Features, Challenges: c.Challenges, Advantages: c.Advantages, Contact: c.Contact, Footer: c.Footer, CreatedAt: c.GetCreatedAt(), UpdatedAt: c.GetUpdatedAt(), } }