Преглед на файлове

feat: :sparkles: feat(agendamento-sob-medida) foi implementado a função de aceitar proposta

foi criado a função do cliente aceitar a proposta do prestador

fase:dev | origin:escopo

Co-authored-by: Copilot <copilot@github.com>
kayo henrique преди 1 ден
родител
ревизия
8daf70b58e
променени са 3 файла, в които са добавени 44 реда и са изтрити 3 реда
  1. 5 0
      src/api/customSchedules.js
  2. 19 1
      src/helpers/utils.js
  3. 20 2
      src/pages/dashboard/components/DashboardClientProposals.vue

+ 5 - 0
src/api/customSchedules.js

@@ -3,4 +3,9 @@ import api from 'src/api'
 export const createCustomSchedule = async (payload) => {
   const { data } = await api.post('/custom-schedule', payload)
   return data
+}
+
+export const acceptProposal = async (proposalId) => {
+  const response = await api.post(`/custom-schedule/${proposalId}/accept`)
+  return response.data
 }

+ 19 - 1
src/helpers/utils.js

@@ -314,6 +314,23 @@ const calculateDailyPrices = (dailyPrice8h) => {
   };
 };
 
+
+const chooseprice = (periodType, daily_price_8h) => {
+  let alldaily_prices = calculateDailyPrices(daily_price_8h);
+  switch (periodType) {
+    case "8":
+      return daily_price_8h
+    case "6":
+      return alldaily_prices.daily_price_6h
+    case "4":
+      return alldaily_prices.daily_price_4h
+    case "2":
+      return alldaily_prices.daily_price_2h
+    default:
+      return 0
+  }
+}
+
 export {
   formatDateDMYtoYMD,
   formatDateYMDtoDMY,
@@ -331,5 +348,6 @@ export {
   detectCardBrand,
   validateCardExpiration,
   formatAddress,
-  calculateDailyPrices
+  calculateDailyPrices,
+  chooseprice
 };

+ 20 - 2
src/pages/dashboard/components/DashboardClientProposals.vue

@@ -41,7 +41,7 @@
 
           <!-- PREÇO -->
           <div class="price">
-            {{ item.total_amount }}
+            {{ 'R$ ' + chooseprice(item.period_type, item.daily_price_8h) }}
           </div>
 
           <!-- LABEL -->
@@ -52,7 +52,7 @@
           <!-- BOTÕES -->
           <div class="actions">
             <q-btn label="recusar" flat class="btn-reject" />
-            <q-btn label="aceitar" class="btn-accept" />
+            <q-btn label="aceitar" class="btn-accept"  @click="() => handleAcceptProposal(item.id)" />
           </div>
 
         </div>
@@ -65,12 +65,30 @@
 </template>
 
 <script setup>
+import { acceptProposal } from 'src/api/customSchedules'
+import { chooseprice } from 'src/helpers/utils'
+
 defineProps({
   data: {
     type: Array,
     default: () => []
   }
 })
+
+
+const handleAcceptProposal = async (proposalId) => {
+  // isLoading.value = true
+  try {
+    await acceptProposal(proposalId)
+    
+    // emit('refreshData')
+    // onDialogOK()
+  } catch (error) {
+    console.log(error);
+  } finally {
+    // isLoading.value = false
+  }
+}
 </script>
 
 <style scoped lang="scss">