feat: 쿠폰등록
This commit is contained in:
111
layers/stores/useCouponStore.ts
Normal file
111
layers/stores/useCouponStore.ts
Normal file
@@ -0,0 +1,111 @@
|
||||
import type { WorldInfo, CharacterInfo } from '#layers/types/api/gameLinkedData'
|
||||
|
||||
export const useCouponStore = defineStore('couponStore', () => {
|
||||
// Refs
|
||||
const couponNo = ref('')
|
||||
const worldList = ref<Array<WorldInfo>>([] as Array<WorldInfo>)
|
||||
const memberNo = ref<number>(0)
|
||||
const guid = ref<number>(0)
|
||||
const selectCharacter = ref(null as CharacterInfo | null)
|
||||
const nickName = ref('')
|
||||
const selectWorld = ref({} as WorldInfo)
|
||||
|
||||
// Computed
|
||||
const isSelectCharacter = computed(() => {
|
||||
return (
|
||||
selectCharacter.value !== null &&
|
||||
selectCharacter.value.character_id !== null &&
|
||||
selectCharacter.value.character_id !== ''
|
||||
)
|
||||
})
|
||||
|
||||
/**
|
||||
* 월드 목록 업데이트 함수입니다.
|
||||
* @param {Array<WorldInfo>} newWorldList - 월드 목록
|
||||
*/
|
||||
const updateWorldList = (newWorldList: Array<WorldInfo>) => {
|
||||
worldList.value = newWorldList
|
||||
}
|
||||
|
||||
/**
|
||||
* 멤버번호 업데이트 함수입니다.
|
||||
* @param {number} newMemberNo - 멤버번호
|
||||
*/
|
||||
const updateMemberNo = (newMemberNo: number) => {
|
||||
memberNo.value = newMemberNo
|
||||
}
|
||||
|
||||
/**
|
||||
* GUID 업데이트 함수입니다.
|
||||
* @param {number} newGuid - GUID
|
||||
*/
|
||||
const updateGuid = (newGuid: number) => {
|
||||
guid.value = newGuid
|
||||
}
|
||||
|
||||
/**
|
||||
* 쿠폰 번호 업데이트 함수입니다.
|
||||
* @param {string} newCouponNo - 쿠폰 번호
|
||||
*/
|
||||
const updateCouponNo = (newCouponNo: string) => {
|
||||
couponNo.value = newCouponNo
|
||||
}
|
||||
|
||||
/**
|
||||
* 선택한 캐릭터 업데이트 함수입니다.
|
||||
* @param {CharacterInfo | null} newCharacter - 선택한 캐릭터 (null인 경우 초기화)
|
||||
*/
|
||||
const updateSelectCharacter = (newCharacter: CharacterInfo | null) => {
|
||||
selectCharacter.value = newCharacter
|
||||
}
|
||||
|
||||
/**
|
||||
* 닉네임 업데이트 함수입니다.
|
||||
* @param {string} newNickname - 닉네임
|
||||
*/
|
||||
const updateNickname = (newNickname: string) => {
|
||||
nickName.value = newNickname
|
||||
}
|
||||
|
||||
/**
|
||||
* 선택한 월드 업데이트 함수입니다.
|
||||
* @param {WorldInfo} newWorld - 선택한 월드
|
||||
*/
|
||||
const updateSelectWorld = (newWorld: WorldInfo) => {
|
||||
selectWorld.value = newWorld
|
||||
}
|
||||
|
||||
/**
|
||||
* 쿠폰 번호 빈값 여부 검증 함수입니다.
|
||||
* 빈값인 경우 true, 빈값이 아닌 경우 false를 반환합니다.
|
||||
* @param {string} value - 쿠폰 번호
|
||||
* @returns
|
||||
*/
|
||||
const isEmptyCouponNo = (value: string) => {
|
||||
if (value === '') {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
couponNo,
|
||||
worldList,
|
||||
memberNo,
|
||||
guid,
|
||||
selectCharacter,
|
||||
nickName,
|
||||
selectWorld,
|
||||
isSelectCharacter,
|
||||
|
||||
updateWorldList,
|
||||
updateMemberNo,
|
||||
updateGuid,
|
||||
updateSelectCharacter,
|
||||
updateNickname,
|
||||
updateSelectWorld,
|
||||
updateCouponNo,
|
||||
isEmptyCouponNo,
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user