// src/stores/payment.js import { defineStore } from 'pinia'; export const usePaymentStore = defineStore('payment', { state: () => ({ currentStep: 1, patientInfo: { name: '', amount: '', expiry: '', // Tidak ada di API, bisa dihapus atau diisi null }, qrData: null, // Properti baru untuk menyimpan data QRIS dari API }), actions: { nextStep() { this.currentStep++; }, prevStep() { this.currentStep--; }, reset() { this.currentStep = 1; this.patientInfo = { name: '', amount: '', expiry: '', }; this.qrData = null; // Reset data QR }, // Action baru untuk menerima dan memproses data dari backend updatePayment(apiResponse) { // Ambil objek data pertama dari array 'data' const apiData = apiResponse.data[0]; // Perbarui state dengan data yang sesuai this.qrData = apiData; this.patientInfo = { name: apiData.display_name, amount: apiData.display_amount, }; // Ganti step secara otomatis this.currentStep = 2; }, }, });