4141 </div >
4242 </template >
4343 </div >
44+
4445 <template v-if =" categories ?.length > 0 " >
4546 <div >
4647 <label for =" category" class =" px-2" >Category</label >
5354 </select >
5455 </div >
5556 </template >
57+
5658 <template v-if =" tags ?.length > 0 " >
5759 <div >
5860 <label for =" tags" class =" px-2" >Tags</label >
6769 <div >
6870 <UploadFile sub-title =" Only .torrent files allowed. BitTorrent v2 files are NOT supported." accept =" .torrent" @on-change =" setFile" />
6971 </div >
72+
73+ <!-- Checkbox for Terms and Conditions Agreement -->
74+ <div >
75+ <label for =" agree-to-terms" class =" px-2" >Agreement</label >
76+ <div class =" mt-1" >
77+ <input v-model =" agreeToTerms" name =" agree-to-terms" type =" checkbox" class =" max-w-5" data-cy =" upload-form-agree-terms" >
78+ <span class =" px-2" >I have read the <NuxtLink to =" /terms" target =" _blank" >{{ contentUploadAgreement }}</NuxtLink >.</span >
79+ </div >
80+ </div >
81+
7082 <template v-if =" user ?.username " >
7183 <TorrustButton
7284 label =" submit"
7385 data-cy =" upload-form-submit"
74- :disabled =" !formValid() || uploading"
86+ :disabled =" !formValid() || !agreeToTerms || uploading"
7587 @click =" submitForm"
7688 />
7789 </template >
90+
7891 <template v-else >
7992 <div class =" relative flex justify-center text-sm" >
8093 <NuxtLink to =" /signin" >
@@ -101,7 +114,7 @@ import {
101114 useTags ,
102115 useUser
103116} from " #imports" ;
104- import { useCategories } from " ~/composables/states" ;
117+ import { useCategories , useSettings } from " ~/composables/states" ;
105118
106119type FormUploadTorrent = {
107120 title: string ;
@@ -111,11 +124,13 @@ type FormUploadTorrent = {
111124 torrentFile: any ;
112125}
113126
127+ const settings = useSettings ();
114128const categories = useCategories ();
115129const tags = useTags ();
116130const user = useUser ();
117131const rest = useRestApi ();
118132
133+ const agreeToTerms: Ref <boolean > = ref (false );
119134const uploading: Ref <boolean > = ref (false );
120135const descriptionView = ref (" edit" );
121136const form: Ref <FormUploadTorrent > = ref ({
@@ -125,12 +140,23 @@ const form: Ref<FormUploadTorrent> = ref({
125140 tags: [],
126141 torrentFile: " "
127142});
143+ const contentUploadAgreement = ref (" " );
128144
129145onMounted (() => {
130146 getCategories ();
131147 getTags ();
132148});
133149
150+ watch (
151+ () => settings .value ,
152+ (newSettings ) => {
153+ if (newSettings ?.website ?.terms ?.upload ?.content_upload_agreement ) {
154+ contentUploadAgreement .value = newSettings .website .terms .page .title ;
155+ }
156+ },
157+ { immediate: true }
158+ );
159+
134160function formValid () {
135161 return form .value .title && form .value .category && form .value .torrentFile ;
136162}
0 commit comments