1313 'blur-none pointer-events-auto': !hideBids
1414 }"
1515 >
16+ <!-- Sin bids -->
17+ <div v-if =" displayBids.length === 0" class =" text-center text-gray-500 dark:text-gray-400 py-6" >
18+ No bids yet. 🕊️
19+ </div >
1620 <div
17- v-for =" bid in bids "
21+ v-for =" bid in displayBids "
1822 :key =" bid.id"
1923 class =" flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-800 rounded-lg shadow-sm"
2024 >
3135 {{ bid.name }}
3236 </p >
3337 <p class =" text-sm text-gray-500 dark:text-gray-400" >
34- {{ bid.amount }} USDT
38+ {{ bid.amount }} ICP
3539 </p >
3640 </div >
3741
7983 {{ selectedBid.name }}
8084 </h6 >
8185 <p class =" text-lg font-bold text-emerald-600" >
82- {{ selectedBid.amount }} USDT
86+ {{ selectedBid.amount }} ICP
8387 </p >
8488 </div >
8589 </div >
137141
138142<script setup>
139143import { ref , computed , onMounted } from ' vue'
140- import { useRoute } from ' vue-router'
141- import logo1 from ' @/assets/images/company/facebook-logo.png'
142- import logo2 from ' @/assets/images/company/google-logo.png'
143- import logo3 from ' @/assets/images/company/android.png'
144- import logo4 from ' @/assets/images/company/lenovo-logo.png'
145- import logo5 from ' @/assets/images/company/spotify.png'
146- import logo6 from ' @/assets/images/company/linkedin.png'
147- import logo7 from ' @/assets/images/company/circle-logo.png'
148- import logo8 from ' @/assets/images/company/skype.png'
149- import logo9 from ' @/assets/images/company/snapchat.png'
150- import logo10 from ' @/assets/images/company/shree-logo.png'
151- import logo11 from ' @/assets/images/company/telegram.png'
152- import logo12 from ' @/assets/images/company/whatsapp.png'
144+ import { Principal } from ' @dfinity/principal'
145+
146+ const session = useSessionStore ()
147+
148+ // Estados del modal
149+ const isAcceptModalOpen = ref (false )
150+ const selectedBid = ref (null )
151+
152+ const id = ref (' ' )
153+ const data = ref (null )
153154
154- const route = useRoute ()
155155
156156// Props del componente
157157const props = defineProps ({
158+ task: {
159+ type: Array ,
160+ default : () => []
161+ },
162+ bids: {
163+ type: Array ,
164+ default : () => []
165+ },
158166 hideBids: {
159167 type: Boolean ,
160168 default: true
@@ -180,21 +188,18 @@ const blurClass = computed(() => {
180188 return ` blur-${ props .blurIntensity } `
181189})
182190
183- // Estados del modal
184- const isAcceptModalOpen = ref (false )
185- const selectedBid = ref (null )
186191
187- const id = ref (' ' )
188- const data = ref (null )
192+ const displayBids = computed (() => {
193+ return props .bids .map (([principal , offer ], index ) => {
194+ return {
195+ id: principal .toText (),
196+ image: ' https://api.dicebear.com/7.x/identicon/svg?seed=' + principal .toText (),
197+ name: principal .toText ().slice (0 , 10 ) + ' ...' ,
198+ amount: Number (offer .amount ) / 1000000
199+ }
200+ })
201+ })
189202
190- const bids = ref ([
191- { id: 1 , image: logo6, name: ' John Doe' , amount: 150 },
192- { id: 2 , image: logo7, name: ' Jane Smith' , amount: 200 },
193- { id: 3 , image: logo8, name: ' Carlos Pérez' , amount: 175 },
194- { id: 4 , image: logo6, name: ' Luis Gómez' , amount: 180 },
195- { id: 5 , image: logo7, name: ' Ana López' , amount: 220 },
196- { id: 6 , image: logo8, name: ' Zoe Rivera' , amount: 250 },
197- ])
198203
199204// Función para abrir el modal de aceptar
200205const openAcceptModal = (bid ) => {
@@ -210,163 +215,20 @@ const handleAcceptBid = async () => {
210215 try {
211216 console .log (' Accepting bid:' , selectedBid .value )
212217
213- // Aquí llamarías a tu API
214- // await session.backend.acceptBid (selectedBid.value.id, route.params .id)
218+ const taskId = BigInt ( props . task [ 0 ] ? . task ? . id )
219+ const bidderPrincipal = Principal . fromText (selectedBid .value .id )
215220
216- // Remover el bid aceptado y todos los demás (simulando rechazo automático)
217- const acceptedBid = selectedBid .value
218- bids .value = bids .value .filter (bid => bid .id === acceptedBid .id )
221+ await session .backend .acceptOffer (taskId, bidderPrincipal)
219222
220- // Cerrar modal
221223 isAcceptModalOpen .value = false
222224 selectedBid .value = null
223225
224- // Mostrar mensaje de éxito
225226 console .log (' Bid accepted successfully!' )
226-
227- // Aquí podrías mostrar un toast de éxito
228- // toast.add({ title: 'Bid accepted successfully!', color: 'success' })
229-
230227 } catch (error) {
231228 console .error (' Error accepting bid:' , error)
232- // Mostrar mensaje de error
233- // toast.add({ title: 'Error accepting bid', color: 'error' })
234229 }
235230}
236231
237- const datas = [
238- {
239- id: 1 ,
240- image: logo1,
241- name: ' Facebook' ,
242- day: ' 2 days ago' ,
243- type: ' Full Time' ,
244- job: ' Web Designer / Developer' ,
245- country: ' Australia' ,
246- vacancy: ' 21 applied' ,
247- vacancy2: ' of 40 vacancy'
248- },
249- {
250- id: 2 ,
251- image: logo2,
252- name: ' Google' ,
253- day: ' 2 days ago' ,
254- type: ' Part Time' ,
255- job: ' Marketing Director' ,
256- country: ' USA' ,
257- vacancy: ' 21 applied' ,
258- vacancy2: ' of 40 vacancy'
259- },
260- {
261- id: 3 ,
262- image: logo3,
263- name: ' Android' ,
264- day: ' 2 days ago' ,
265- type: ' Remote' ,
266- job: ' Application Developer' ,
267- country: ' China' ,
268- vacancy: ' 21 applied' ,
269- vacancy2: ' of 40 vacancy'
270- },
271- {
272- id: 4 ,
273- image: logo4,
274- name: ' Lenovo' ,
275- day: ' 2 days ago' ,
276- type: ' WFH' ,
277- job: ' Senior Product Designer' ,
278- country: ' Dubai' ,
279- vacancy: ' 21 applied' ,
280- vacancy2: ' of 40 vacancy'
281- },
282- {
283- id: 5 ,
284- image: logo5,
285- name: ' Spotify' ,
286- day: ' 2 days ago' ,
287- type: ' Full Time' ,
288- job: ' C++ Developer' ,
289- country: ' India' ,
290- vacancy: ' 21 applied' ,
291- vacancy2: ' of 40 vacancy'
292- },
293- {
294- id: 6 ,
295- image: logo6,
296- name: ' Linkedin' ,
297- day: ' 2 days ago' ,
298- type: ' Remote' ,
299- job: ' Php Developer' ,
300- country: ' Pakistan' ,
301- vacancy: ' 21 applied' ,
302- vacancy2: ' of 40 vacancy'
303- },
304- {
305- id: 7 ,
306- image: logo7,
307- name: ' Circle CI' ,
308- job: ' Web Designer / Developer' ,
309- title: ' Looking for an experienced Web Designer for an our company.' ,
310- type: ' Full Time' ,
311- salary: ' $4,000 - $4,500' ,
312- location: ' Australia'
313- },
314- {
315- id: 8 ,
316- image: logo8,
317- name: ' Skype' ,
318- job: ' Marketing Director' ,
319- title: ' Looking for an experienced Web Designer for an our company.' ,
320- type: ' Full Time' ,
321- salary: ' $4,000 - $4,500' ,
322- location: ' Australia'
323- },
324- {
325- id: 9 ,
326- image: logo9,
327- name: ' Snapchat' ,
328- job: ' Application Developer' ,
329- title: ' Looking for an experienced Web Designer for an our company.' ,
330- type: ' Full Time' ,
331- salary: ' $4,000 - $4,500' ,
332- location: ' Australia'
333- },
334- {
335- id: 10 ,
336- image: logo10,
337- name: ' Shreethemes' ,
338- job: ' Senior Product Designer' ,
339- title: ' Looking for an experienced Web Designer for an our company.' ,
340- type: ' Full Time' ,
341- salary: ' $4,000 - $4,500' ,
342- location: ' Australia'
343- },
344- {
345- id: 11 ,
346- image: logo11,
347- name: ' Telegram' ,
348- job: ' C++ Developer' ,
349- title: ' Looking for an experienced Web Designer for an our company.' ,
350- type: ' Full Time' ,
351- salary: ' $4,000 - $4,500' ,
352- location: ' Australia'
353- },
354- {
355- id: 12 ,
356- image: logo12,
357- name: ' Whatsapp' ,
358- job: ' Php Developer' ,
359- title: ' Looking for an experienced Web Designer for an our company.' ,
360- type: ' Full Time' ,
361- salary: ' $4,000 - $4,500' ,
362- location: ' Australia'
363- }
364- ]
365-
366- onMounted (() => {
367- id .value = route .params .id
368- data .value = datas .find (item => item .id === parseInt (id .value ))
369- })
370232< / script>
371233
372234< style lang= " scss" scoped>< / style>
0 commit comments