Skip to content

Commit

Permalink
chore!: old tables removed (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmbanan666 authored Dec 19, 2024
1 parent f72ebb7 commit 5fd09fb
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 339 deletions.
95 changes: 0 additions & 95 deletions apps/website/app/pages/character/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,76 +107,9 @@
Пока нет владельцев
</p>
</section>

<section class="posts-block">
<h2>Пользовательские посты</h2>
<p class="description">
Это могут быть истории или новая информация о характере и судьбе персонажа.
</p>

<div class="feed">
<div v-if="profileData" class="add-post">
<div class="content">
<div class="action">
Добавить новый пост
</div>

<div class="form-control">
<textarea v-model="postText" name="text" placeholder="Пиши, не стесняйся. Максимум 1500 символов" rows="4" maxlength="1500" />
</div>

<button class="submit-button" :disabled="!isReadyToPost" @click="addPost">
<div>Отправить сообщение</div>
<div class="price">
Стоимость: 5 Маны <img src="~/assets/img/icons/mana/64.png" alt="" width="22" height="22">
</div>
</button>

<div class="bonus">
+ 5 очков "Рассказчика"
</div>
<div class="bonus">
+ 1 очко "Рассказчика" за каждый Лайк
</div>
</div>
</div>

<p v-if="!posts?.length" class="empty">
Пока нет постов
</p>

<div v-for="post in posts" :key="post.id" class="post">
<img src="/units/twitchy/128.png" alt="" class="avatar">
<div class="content">
<div class="info">
<div class="desc">
<NuxtLink :to="localePath(`/p/${post.profile.userName}`)">
{{ post.profile.userName }}
</NuxtLink> добавил(а) новую заметку
</div>
<time>
{{ useLocaleTimeAgo(new Date(post.createdAt)) }}
</time>
</div>
<div class="message">
{{ post.text }}

<div class="likes-block">
<button :data-liked="post.likes.some(l => l.profileId === profileData?.id)" @click="addLike(post.id)">
<ThumbsUp :size="30" />
{{ post.rating }}
</button>
</div>
</div>
</div>
</div>
</div>
</section>
</template>

<script setup lang="ts">
import { ThumbsUp } from 'lucide-vue-next'
definePageMeta({
validate: async (route) => {
const { error } = await useFetch(`/api/character/${route.params.id}`)
Expand All @@ -188,21 +121,16 @@ const localePath = useLocalePath()
const route = useRoute()
const { data: character } = await useFetch(`/api/character/${route.params.id}`)
const { data: topEditions } = await useFetch(`/api/character/${route.params.id}/top`)
const { data: posts } = await useFetch(`/api/character/${route.params.id}/post`)
const { user } = useUserSession()
const { data: profileData } = await useFetch(`/api/profile/userName/${user.value?.userName}`)
const twitchyId = 'staoqh419yy3k22cbtm9wquc'
const alreadyHaveCharacter = profileData.value?.characterEditions.find((e) => e.characterId === character.value?.id)
const coins = profileData.value?.coins ?? 0
const mana = profileData.value?.mana ?? 0
const price = character.value?.price ?? 0
const isEnoughCoins = profileData ? coins >= price : false
const postText = ref('')
const isReadyToPost = computed(() => postText.value.length > 10 && mana >= 5)
async function activateCharacter() {
const { data } = await useFetch(`/api/character/${route.params.id}/activate`, {
method: 'POST',
Expand All @@ -222,29 +150,6 @@ async function unlockCharacter() {
location.reload()
}
}
async function addLike(postId: string) {
const { data } = await useFetch(`/api/post/${postId}/like`, {
method: 'POST',
})
if (data.value) {
location.reload()
}
}
async function addPost() {
const { data } = await useFetch(`/api/character/${route.params.id}/post`, {
method: 'POST',
body: {
text: postText.value,
},
})
if (data.value) {
location.reload()
}
}
</script>

<style scoped>
Expand Down
107 changes: 38 additions & 69 deletions apps/website/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@ datasource db {
}

model Profile {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
twitchId String @map("twitch_id")
userName String @map("user_name")
isStreamer Boolean @default(false)
coupons Int @default(0)
coins Int @default(0)
mana Int @default(0)
level Int @default(1)
points Int @default(0)
patronPoints Int @default(0) @map("patron_points")
trophyHunterPoints Int @default(0) @map("trophy_hunter_points")
rangerPoints Int @default(0) @map("ranger_points")
storytellerPoints Int @default(0) @map("storyteller_points")
collectorPoints Int @default(0) @map("collector_points")
activeEditionId String @map("active_edition_id")
telegramProfileId String? @unique @map("telegram_profile_id")
telegramProfile TelegramProfile? @relation(fields: [telegramProfileId], references: [id])
posts Post[]
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
twitchId String @map("twitch_id")
userName String @map("user_name")
isStreamer Boolean @default(false)
coupons Int @default(0)
coins Int @default(0)
mana Int @default(0)
level Int @default(1)
points Int @default(0)
patronPoints Int @default(0) @map("patron_points")
trophyHunterPoints Int @default(0) @map("trophy_hunter_points")
rangerPoints Int @default(0) @map("ranger_points")
storytellerPoints Int @default(0) @map("storyteller_points")
collectorPoints Int @default(0) @map("collector_points")
activeEditionId String @map("active_edition_id")
telegramProfileId String? @unique @map("telegram_profile_id")
telegramProfile TelegramProfile? @relation(fields: [telegramProfileId], references: [id])
quests Quest[]
questEditions QuestEdition[]
twitchTokens TwitchToken[]
characters Character[]
characterEditions CharacterEdition[]
transactions Transaction[]
trophyEditions TrophyEdition[]
itemEditions InventoryItemEdition[]
@@map("profile")
}
Expand Down Expand Up @@ -150,35 +150,30 @@ model Skill {
@@map("skill")
}

model Inventory {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
objectId String @map("object_id")
items InventoryItem[]
@@map("inventory")
}

model InventoryItem {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
inventoryId String @map("inventory_id")
inventory Inventory @relation(fields: [inventoryId], references: [id])
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
type String
amount Int @default(1)
durability Int @default(100)
name String
description String
editions InventoryItemEdition[]
@@map("inventory_item")
}

model ChatCommand {
id String @id
action String
command String
@@map("chat_command")
model InventoryItemEdition {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
amount Int @default(0)
durability Int @default(100)
itemId String @map("item_id")
item InventoryItem @relation(fields: [itemId], references: [id])
profileId String @map("profile_id")
profile Profile @relation(fields: [profileId], references: [id])
@@map("inventory_item_edition")
}

model Character {
Expand Down Expand Up @@ -217,32 +212,6 @@ model CharacterEdition {
@@map("character_edition")
}

model Post {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
profileId String @map("profile_id")
profile Profile @relation(fields: [profileId], references: [id])
characterId String @map("character_id")
type String
text String
rating Int @default(0)
likes Like[]
@@map("post")
}

model Like {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
profileId String @map("profile_id")
postId String @map("post_id")
post Post @relation(fields: [postId], references: [id])
@@map("like")
}

model Coupon {
id String @id
createdAt DateTime @default(now()) @map("created_at")
Expand Down
20 changes: 0 additions & 20 deletions apps/website/server/api/character/[id]/post/index.get.ts

This file was deleted.

52 changes: 0 additions & 52 deletions apps/website/server/api/character/[id]/post/index.post.ts

This file was deleted.

24 changes: 0 additions & 24 deletions apps/website/server/api/game/inventory/[id].get.ts

This file was deleted.

Loading

0 comments on commit 5fd09fb

Please sign in to comment.