2024-04-08 16:59:42 +07:00
|
|
|
package homeview
|
|
|
|
|
2024-04-08 21:50:52 +07:00
|
|
|
import "github.com/tigorlazuardi/redmage/views/components"
|
|
|
|
import "github.com/tigorlazuardi/redmage/views"
|
2024-04-28 22:00:56 +07:00
|
|
|
import "github.com/tigorlazuardi/redmage/views/utils"
|
|
|
|
import "time"
|
2024-04-09 16:09:08 +07:00
|
|
|
|
|
|
|
templ Home(c *views.Context, data Data) {
|
2024-04-08 21:50:52 +07:00
|
|
|
@components.Doctype() {
|
2024-04-09 21:49:23 +07:00
|
|
|
@components.Head(c, components.HeadTitle("Redmage - Home"))
|
2024-04-09 16:09:08 +07:00
|
|
|
@components.Body(c) {
|
|
|
|
@components.Container() {
|
|
|
|
if data.Error != nil {
|
|
|
|
@components.ErrorToast(data.Error.Error())
|
|
|
|
} else {
|
|
|
|
@home(c, data)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-04-08 21:50:52 +07:00
|
|
|
}
|
2024-04-08 16:59:42 +07:00
|
|
|
}
|
2024-04-09 16:09:08 +07:00
|
|
|
|
2024-04-27 22:07:20 +07:00
|
|
|
templ home(_ *views.Context, data Data) {
|
2024-04-09 16:09:08 +07:00
|
|
|
<div class="prose">
|
2024-04-27 22:07:20 +07:00
|
|
|
<section class="mb-4 mx-auto">
|
2024-04-09 21:49:23 +07:00
|
|
|
<h1>Recently Added</h1>
|
2024-04-28 22:00:56 +07:00
|
|
|
for _, deviceMapValue := range data.RecentlyAddedImages {
|
|
|
|
<h2>{ deviceMapValue.device.Name }</h2>
|
|
|
|
for _, subreddit := range deviceMapValue.subreddits {
|
|
|
|
<h4>{ subreddit.subreddit.Name }</h4>
|
|
|
|
@RecentlyAddedImageList(subreddit.images, 0)
|
|
|
|
}
|
|
|
|
}
|
2024-04-09 21:49:23 +07:00
|
|
|
</section>
|
|
|
|
<section>
|
|
|
|
<h1>Subreddits</h1>
|
|
|
|
for _, subreddit := range data.SubredditsList.Data {
|
2024-04-28 22:00:56 +07:00
|
|
|
<h3>{ subreddit.Name } - { utils.NextScheduleTime(subreddit.Schedule).Format(time.RubyDate) }</h3>
|
2024-04-09 21:49:23 +07:00
|
|
|
}
|
|
|
|
</section>
|
2024-04-09 16:09:08 +07:00
|
|
|
</div>
|
|
|
|
}
|