feat: use withDefaults for Reactions
This commit is contained in:
parent
2f6338484b
commit
d6c3b5a9a1
@ -13,27 +13,25 @@ import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside'
|
|||||||
import {useAuthStore} from '@/stores/auth'
|
import {useAuthStore} from '@/stores/auth'
|
||||||
import {useColorScheme} from '@/composables/useColorScheme'
|
import {useColorScheme} from '@/composables/useColorScheme'
|
||||||
|
|
||||||
const {
|
const props = withDefaults(defineProps<{
|
||||||
entityKind,
|
|
||||||
entityId,
|
|
||||||
disabled = false,
|
|
||||||
} = defineProps<{
|
|
||||||
entityKind: ReactionKind,
|
entityKind: ReactionKind,
|
||||||
entityId: number,
|
entityId: number,
|
||||||
disabled?: boolean,
|
disabled?: boolean,
|
||||||
}>()
|
}>(), {
|
||||||
|
disabled: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
const model = defineModel<IReactionPerEntity>()
|
||||||
|
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
const {t} = useI18n()
|
const {t} = useI18n()
|
||||||
const reactionService = new ReactionService()
|
const reactionService = new ReactionService()
|
||||||
const {isDark} = useColorScheme()
|
const {isDark} = useColorScheme()
|
||||||
|
|
||||||
const model = defineModel<IReactionPerEntity>()
|
|
||||||
|
|
||||||
async function addReaction(value: string) {
|
async function addReaction(value: string) {
|
||||||
const reaction = new ReactionModel({
|
const reaction = new ReactionModel({
|
||||||
id: entityId,
|
id: props.entityId,
|
||||||
kind: entityKind,
|
kind: props.entityKind,
|
||||||
value,
|
value,
|
||||||
})
|
})
|
||||||
await reactionService.create(reaction)
|
await reactionService.create(reaction)
|
||||||
@ -52,8 +50,8 @@ async function addReaction(value: string) {
|
|||||||
|
|
||||||
async function removeReaction(value: string) {
|
async function removeReaction(value: string) {
|
||||||
const reaction = new ReactionModel({
|
const reaction = new ReactionModel({
|
||||||
id: entityId,
|
id: props.entityId,
|
||||||
kind: entityKind,
|
kind: props.entityKind,
|
||||||
value,
|
value,
|
||||||
})
|
})
|
||||||
await reactionService.delete(reaction)
|
await reactionService.delete(reaction)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user