@@ -6,9 +6,11 @@ use axum::{
66 routing:: get,
77} ;
88use log:: { error, info} ;
9+ use maud:: { Markup , html} ;
910
1011use crate :: {
11- model:: { JobId , Limit } ,
12+ jobs:: job_card,
13+ model:: { Job , JobId , Limit } ,
1214 repository:: JobRepo ,
1315} ;
1416pub fn router ( ) -> Router {
@@ -21,10 +23,10 @@ pub fn router() -> Router {
2123pub async fn get_jobs ( repo : Extension < JobRepo > , limit : Query < Limit > ) -> impl IntoResponse {
2224 let limit: Limit = * limit;
2325 match repo. get_page ( limit) . await {
24- Ok ( _jobs ) => (
26+ Ok ( jobs ) => (
2527 StatusCode :: OK ,
2628 // todo return new view
27- Ok ( "" ) ,
29+ Ok ( html ! ( ( jobs_view ( jobs ) ) ) ) ,
2830 ) ,
2931 Err ( err) => {
3032 error ! ( "Failed to get a page of jobs: {err}\n {:?}" , err. source( ) ) ;
@@ -33,6 +35,21 @@ pub async fn get_jobs(repo: Extension<JobRepo>, limit: Query<Limit>) -> impl Int
3335 }
3436}
3537
38+ pub fn jobs_view ( jobs : Vec < Job > ) -> Markup {
39+ html ! {
40+ @for job in jobs{
41+ ( job_card( job. title( ) , job. preface( ) , vec![ html!{
42+ div class="badge badge-accent" {
43+ "On-site"
44+ }
45+ } ] , job. description( ) , html!{
46+ a class="btn btn-secondary btn-sm bg-base" href=( job. uri( ) ) {
47+ "Apply"
48+ } } ) )
49+ }
50+ }
51+ }
52+
3653pub async fn get_job ( repo : Extension < JobRepo > , job_id : Path < JobId > ) -> impl IntoResponse {
3754 info ! ( "Got job {}?" , * job_id) ;
3855 match repo. get_one ( * job_id) . await {
0 commit comments