<template>
    <NavBar title="建议反馈" />

    <view class="content flex-col gap-4">
        <wd-textarea v-model="desc" placeholder="请填写建议反馈" />

        <wd-button block @click="submit">提交</wd-button>
    </view>

    <wd-toast />
</template>


<script setup lang="ts">
import NavBar from '@/components/NavBar.vue'
import { createSuggestion } from "@/api/modules/suggestion"
import { ref } from 'vue'
import { useToast } from '@/uni_modules/wot-design-uni'


const desc = ref('')
const toast = useToast()


const submit = async () => {
    if (!desc.value) {
        toast.error('请填写建议反馈')
        return
    }
    
    await createSuggestion(
        desc.value
    ).then(res => {
        if (res.data) {
            toast.success('提交成功')
            desc.value = ''
        } else {
            toast.error('提交失败')
        }
    })
}

</script>

<style scoped lang="scss">
.content {
    width: calc(100% - 64rpx);
    padding: 32rpx;
}
</style>
