| 
									
										
										
										
											2021-12-04 14:18:46 -09:00
										 |  |  | <template> | 
					
						
							|  |  |  |   <v-data-table | 
					
						
							|  |  |  |     item-key="id" | 
					
						
							|  |  |  |     :headers="headers" | 
					
						
							|  |  |  |     :items="exports" | 
					
						
							|  |  |  |     :items-per-page="15" | 
					
						
							|  |  |  |     class="elevation-0" | 
					
						
							|  |  |  |     @click:row="downloadData" | 
					
						
							|  |  |  |   > | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     <template #[`item.expires`]="{ item }"> | 
					
						
							| 
									
										
										
										
											2021-12-04 14:18:46 -09:00
										 |  |  |       {{ getTimeToExpire(item.expires) }} | 
					
						
							|  |  |  |     </template> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     <template #[`item.actions`]="{ item }"> | 
					
						
							|  |  |  |       <BaseButton | 
					
						
							|  |  |  |         download | 
					
						
							|  |  |  |         size="small" | 
					
						
							|  |  |  |         :download-url="`/api/recipes/bulk-actions/export/download?path=${item.path}`" | 
					
						
							|  |  |  |       /> | 
					
						
							| 
									
										
										
										
											2021-12-04 14:18:46 -09:00
										 |  |  |     </template> | 
					
						
							|  |  |  |   </v-data-table> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <script lang="ts"> | 
					
						
							|  |  |  | import { parseISO, formatDistanceToNow } from "date-fns"; | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | import type { GroupDataExport } from "~/lib/api/types/group"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default defineNuxtComponent({ | 
					
						
							| 
									
										
										
										
											2021-12-04 14:18:46 -09:00
										 |  |  |   props: { | 
					
						
							|  |  |  |     exports: { | 
					
						
							|  |  |  |       type: Array as () => GroupDataExport[], | 
					
						
							|  |  |  |       required: true, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   setup() { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     const i18n = useI18n(); | 
					
						
							| 
									
										
										
										
											2022-08-10 07:12:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-04 14:18:46 -09:00
										 |  |  |     const headers = [ | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       { title: i18n.t("export.export"), value: "name" }, | 
					
						
							|  |  |  |       { title: i18n.t("export.file-name"), value: "filename" }, | 
					
						
							|  |  |  |       { title: i18n.t("export.size"), value: "size" }, | 
					
						
							|  |  |  |       { title: i18n.t("export.link-expires"), value: "expires" }, | 
					
						
							|  |  |  |       { title: "", value: "actions" }, | 
					
						
							| 
									
										
										
										
											2021-12-04 14:18:46 -09:00
										 |  |  |     ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function getTimeToExpire(timeString: string) { | 
					
						
							|  |  |  |       const expiresAt = parseISO(timeString); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       return formatDistanceToNow(expiresAt, { | 
					
						
							|  |  |  |         addSuffix: false, | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function downloadData(_: any) { | 
					
						
							|  |  |  |       console.log("Downloading data..."); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       downloadData, | 
					
						
							|  |  |  |       headers, | 
					
						
							|  |  |  |       getTimeToExpire, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | </script> |