Enhance piyangoKatilimciService by adding online draw creation logic and user feedback. Introduce isCreatingOnlineDraw state to prevent multiple submissions and integrate toast notifications for successful draw completion, improving user experience and process clarity.
This commit is contained in:
@ -4,6 +4,8 @@ import { usePiyangoStore } from '../stores/piyangoStore'
|
||||
import { usePiyangoKatilimciStore } from '../stores/piyangoKatilimciStore'
|
||||
import { usePiyangoKatilimciValidationStore } from '../validation/piyangoKatilimciValidationStore'
|
||||
import { useUsersStore } from '@/stores/usersStore'
|
||||
import { ref } from 'vue'
|
||||
import { useToastStore } from '@/components/global/toastStore'
|
||||
|
||||
export const usePiyangoKatilimciService = defineStore('piyangoKatilimciService', () => {
|
||||
const dataStore = useDataStore()
|
||||
@ -11,6 +13,8 @@ export const usePiyangoKatilimciService = defineStore('piyangoKatilimciService',
|
||||
const piyangoKatilimciStore = usePiyangoKatilimciStore()
|
||||
const piyangoKatilimciValidationStore = usePiyangoKatilimciValidationStore()
|
||||
const usersStore = useUsersStore()
|
||||
const toastStore = useToastStore()
|
||||
const isCreatingOnlineDraw = ref(false)
|
||||
|
||||
const SaveKatilimciUser = async () => {
|
||||
if (piyangoKatilimciValidationStore.UserFormCheck()) {
|
||||
@ -49,10 +53,30 @@ export const usePiyangoKatilimciService = defineStore('piyangoKatilimciService',
|
||||
}
|
||||
|
||||
const CreateOnlineDraw = async () => {
|
||||
if (usersStore.isPanelUser) {
|
||||
let dt = await dataStore.dataGet(
|
||||
'Cekilis/CekilisDuzenle/' + piyangoStore.selectedLottery
|
||||
)
|
||||
if (!usersStore.isPanelUser || piyangoStore.selectedLottery === null || isCreatingOnlineDraw.value) {
|
||||
return false
|
||||
}
|
||||
|
||||
isCreatingOnlineDraw.value = true
|
||||
|
||||
try {
|
||||
const dt = await dataStore.dataGet('Cekilis/CekilisDuzenle/' + piyangoStore.selectedLottery)
|
||||
|
||||
if (dt !== 'errorfalse') {
|
||||
const lotteryData = await dataStore.dataGet('Cekilis/durum-sorgu/' + piyangoStore.selectedLottery)
|
||||
|
||||
if (lotteryData && lotteryData !== 'errorfalse') {
|
||||
piyangoStore.SetLotteryControlData(lotteryData)
|
||||
}
|
||||
|
||||
piyangoKatilimciStore.refreshPiyangoKatilimciList = true
|
||||
toastStore.AddToast('Online çekiliş tamamlandı.', 'ok', 4000)
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
} finally {
|
||||
isCreatingOnlineDraw.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,6 +145,7 @@ export const usePiyangoKatilimciService = defineStore('piyangoKatilimciService',
|
||||
return {
|
||||
SaveKatilimciUser,
|
||||
CreateOnlineDraw,
|
||||
isCreatingOnlineDraw,
|
||||
KatilimciData,
|
||||
KatilimciFileUpload,
|
||||
GetUploadJobs,
|
||||
|
||||
Reference in New Issue
Block a user