Skip to content

Commit

Permalink
fixup! fixup! wip Use ESlint
Browse files Browse the repository at this point in the history
  • Loading branch information
azuki774 committed Sep 9, 2024
1 parent eb61dc2 commit 46304cf
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 232 deletions.
20 changes: 10 additions & 10 deletions components/History.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script setup lang="ts">
import type { Record } from "@/interfaces"
<script setup lang='ts'>
import type { Record } from '@/interfaces'
const config = useRuntimeConfig() // nuxt.config.ts に書いてあるコンフィグを読み出す
const recordList = ref<Record[]>()
const asyncData = await useFetch(
"/api/history",
'/api/history',
{
key: `/api/history`,
}
Expand All @@ -23,15 +23,15 @@ if (data != undefined) { // 取得済の場合のみ
recordList.value = data
async function showDeleteDialog(id: number): Promise<void> {
const userResponse: boolean = confirm("このデータを削除しますか")
const userResponse: boolean = confirm('このデータを削除しますか')
if (userResponse == true) {
console.log('delete: id=' + id)
const asyncDataBtn = await useAsyncData(
`record`,
(): Promise<any> => {
const param = { 'id': id }
const paramStr = "?id=" + param['id']
const localurl = "/api/deleteRecord" + paramStr
const paramStr = '?id=' + param['id']
const localurl = '/api/deleteRecord' + paramStr
const response = $fetch(localurl)
return response
}
Expand All @@ -44,8 +44,8 @@ async function showDeleteDialog(id: number): Promise<void> {
</script>

<template>
<div class="container-sm">
<table class="table table-striped table-sm">
<div class='container-sm'>
<table class='table table-striped table-sm'>
<thead>
<tr>
<th>ID</th>
Expand All @@ -57,13 +57,13 @@ async function showDeleteDialog(id: number): Promise<void> {
</tr>
</thead>
<tbody>
<tr v-for="record in recordList">
<tr v-for='record in recordList'>
<td>{{ record.id }}</td>
<td>{{ record.category_name }}</td>
<td>{{ record.price }}</td>
<td>{{ record.datetime }}</td>
<td>{{ record.memo }}</td>
<td><button class="btn btn-secondary" @click="showDeleteDialog(record.id)">削除</button></td>
<td><button class='btn btn-secondary' @click='showDeleteDialog(record.id)'>削除</button></td>
</tr>
</tbody>
</table>
Expand Down
34 changes: 17 additions & 17 deletions components/PostRecord.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup lang="ts">
import type { Category } from "@/interfaces"
<script setup lang='ts'>
import type { Category } from '@/interfaces'
const config = useRuntimeConfig() // nuxt.config.ts に書いてあるコンフィグを読み出す
const selector = ref<any>()
const categoryList = ref<Category[]>()
const asyncData = await useFetch(
"/api/getCategories",
'/api/getCategories',
{
key: `/api/getCategories`,
}
Expand All @@ -17,8 +17,8 @@ if (data != undefined) { // 取得済の場合のみ
for (let d of data) {
// 100, category_name -> 100:category_name という表示に
// ただし加工済の場合は skip
if (d.category_name[3] != ":") {
d.category_name = d.category_id + ":" + d.category_name
if (d.category_name[3] != ':') {
d.category_name = d.category_id + ':' + d.category_name
}
}
}
Expand All @@ -33,9 +33,9 @@ const postButton = async (): Promise<void> => {
`record`,
(): Promise<any> => {
const send_category_id = selector.value.slice(0, 3) // 210-食費→210
const param = { 'price': priceBox.value, 'category_id': send_category_id }
const paramStr = "?price=" + param['price'] + "&category_id=" + param['category_id']
const localurl = "/api/postRecord" + paramStr
const param = { price: priceBox.value, category_id: send_category_id }
const paramStr = '?price=' + param['price'] + '&category_id=' + param['category_id']
const localurl = '/api/postRecord' + paramStr
const response = $fetch(localurl)
return response
}
Expand All @@ -46,23 +46,23 @@ const postButton = async (): Promise<void> => {
</script>

<template>
<div class="container text-center">
<div class="row justify-content-center">
<div class="col-2">
<select v-model="selector" class="form-select">
<option v-for="category in categoryList" :key="category.category_id">
<div class='container text-center'>
<div class='row justify-content-center'>
<div class='col-2'>
<select v-model='selector' class='form-select'>
<option v-for='category in categoryList' :key='category.category_id'>
{{ category.category_name }}
</option>
</select>
</div>

<div class="col-2 mb-3">
<input v-model="priceBox" type="number" placeholder="Value" />
<div class='col-2 mb-3'>
<input v-model='priceBox' type='number' placeholder='Value' />
</div>
</div>

<div class="d-grid col-2 mx-auto">
<button class="btn btn-primary" @click="postButton" name="postButton" type="submit">Post</button>
<div class='d-grid col-2 mx-auto'>
<button class='btn btn-primary' @click='postButton' name='postButton' type='submit'>Post</button>
</div>

</div>
Expand Down
28 changes: 14 additions & 14 deletions interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
export interface Record {
id: number;
category_id: number;
category_name: string;
datetime: string;
from: string;
type: string;
price: number;
memo: string;
id: number
category_id: number
category_name: string
datetime: string
from: string
type: string
price: number
memo: string
}

export interface Category {
category_id: number;
category_name: string;
category_id: number
category_name: string
}

export interface SummaryOne {
category_id: number;
category_name: string;
price: number[]; // 4,5,6,7,8,9,10,11,12,1,2,3月の額
total: number;
category_id: number
category_name: string
price: number[] // 4,5,6,7,8,9,10,11,12,1,2,3月の額
total: number
}
10 changes: 5 additions & 5 deletions pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script setup lang="ts">
<script setup lang='ts'>
import type Year from './summary/[year].vue'
const today = new Date()
Expand All @@ -9,25 +9,25 @@ let thisYear = today.getFullYear()
<template>
<h1>mawinter-front</h1>
<section>
<p text-alignment="center">
<p text-alignment='center'>
<h2>登録</h2>
<PostRecord />
</p>

<div class="summary_link">
<div class='summary_link'>
<NuxtLink v-bind:to="{name: 'summary-year', params: {year: thisYear}}">
サマリー表示
</NuxtLink>
</div>

<p text-alignment="center">
<p text-alignment='center'>
<h2>直近履歴</h2>
<History />
</p>
</section>
</template>

<style lang="css">
<style lang='css'>
h2 {
text-align: center;
margin-left: auto;
Expand Down
Loading

0 comments on commit 46304cf

Please sign in to comment.