File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
src/routes/settings/(nav)/assistants/[assistantId] Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -197,4 +197,29 @@ export const actions: Actions = {
197197
198198 return { from : "unfeature" , ok : true , message : "Assistant unfeatured" } ;
199199 } ,
200+
201+ feature : async ( { params, locals } ) => {
202+ if ( ! locals . user ?. isAdmin ) {
203+ return fail ( 403 , { error : true , message : "Permission denied" } ) ;
204+ }
205+
206+ const assistant = await collections . assistants . findOne ( {
207+ _id : new ObjectId ( params . assistantId ) ,
208+ } ) ;
209+
210+ if ( ! assistant ) {
211+ return fail ( 404 , { error : true , message : "Assistant not found" } ) ;
212+ }
213+
214+ const result = await collections . assistants . updateOne (
215+ { _id : assistant . _id } ,
216+ { $set : { featured : true } }
217+ ) ;
218+
219+ if ( result . modifiedCount === 0 ) {
220+ return fail ( 500 , { error : true , message : "Failed to feature assistant" } ) ;
221+ }
222+
223+ return { from : "feature" , ok : true , message : "Assistant featured" } ;
224+ } ,
200225} ;
Original file line number Diff line number Diff line change 1111 import CarbonCopy from " ~icons/carbon/copy-file" ;
1212 import CarbonFlag from " ~icons/carbon/flag" ;
1313 import CarbonLink from " ~icons/carbon/link" ;
14+ import CarbonStar from " ~icons/carbon/star" ;
1415 import CopyToClipBoardBtn from " $lib/components/CopyToClipBoardBtn.svelte" ;
1516 import ReportModal from " ./ReportModal.svelte" ;
1617 import IconInternet from " $lib/components/icons/IconInternet.svelte" ;
154155 <CarbonTrash class =" mr-1.5 inline text-xs" />Un-feature</button
155156 >
156157 </form >
158+ {:else }
159+ <form method =" POST" action =" ?/feature" use:enhance >
160+ <button type =" submit" class =" flex items-center text-green-600 underline" >
161+ <CarbonStar class =" mr-1.5 inline text-xs" />Feature</button
162+ >
163+ </form >
157164 {/if }
158165 {/if }
159166 </div >
You can’t perform that action at this time.
0 commit comments