Skip to content

Commit

Permalink
MaiaのAdminフロントエンドと同期を取る (#2185)
Browse files Browse the repository at this point in the history
* consumerでしか使わない不要な処理が残っている箇所をadminから削除

* vee-validateとyupで管理するnameとdescriptionの名称を変更
  • Loading branch information
KentaHizume authored Dec 26, 2024
1 parent 930cc16 commit ce162d0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ export async function fetchCategories(): Promise<
GetCatalogCategoriesResponse[]
> {
const response = await catalogCategoriesApi.getCatalogCategories();
const categories = response.data;
categories.unshift({ id: 0, name: 'すべて' });
return categories;
return response.data;
}

/**
Expand All @@ -33,9 +31,7 @@ export async function fetchCategories(): Promise<
*/
export async function fetchBrands(): Promise<GetCatalogBrandsResponse[]> {
const response = await catalogBrandsApi.getCatalogBrands();
const brands = response.data;
brands.unshift({ id: 0, name: 'すべて' });
return brands;
return response.data;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export const validationItems = {
*/
export const catalogItemSchema: TypedSchema = toTypedSchema(
yup.object({
name: yup
itemName: yup
.string()
.required('アイテム名は必須です。')
.max(256, '256文字以下で入力してください。'),
description: yup
itemDescription: yup
.string()
.required('説明は必須です。')
.max(1024, '1024文字以下で入力してください。'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ const customErrorHandler = useCustomErrorHandler();
const { errors, values, meta, defineField } = useForm({
validationSchema: catalogItemSchema,
initialValues: {
name: 'テスト用アイテム',
description: 'テスト用アイテムです。',
itemName: 'テスト用アイテム',
itemDescription: 'テスト用アイテムです。',
price: 1980,
productCode: 'T001',
},
});
const [name] = defineField('name');
const [description] = defineField('description');
const [itemName] = defineField('itemName');
const [itemDescription] = defineField('itemDescription');
const [price] = defineField('price');
const [productCode] = defineField('productCode');
Expand Down Expand Up @@ -71,8 +71,8 @@ const showAddNotice = ref(false);
const AddItem = async () => {
try {
await postCatalogItem(
values.name,
values.description,
values.itemName,
values.itemDescription,
values.price,
values.productCode,
selectedCategoryId.value,
Expand Down Expand Up @@ -130,22 +130,24 @@ onMounted(async () => {
<label for="item-name" class="mb-2 block font-bold">アイテム名</label>
<input
id="item-name"
v-model="name"
v-model="itemName"
type="text"
name="item-name"
class="w-full border border-gray-300 px-4 py-2"
/>
<p class="px-2 py-2 text-base text-red-800">{{ errors.name }}</p>
<p class="px-2 py-2 text-base text-red-800">{{ errors.itemName }}</p>
</div>
<div class="mb-4">
<label for="description" class="mb-2 block font-bold">説明</label>
<label for="item-description" class="mb-2 block font-bold">説明</label>
<textarea
id="description"
v-model="description"
name="description"
id="item-description"
v-model="itemDescription"
name="item-description"
class="w-full border border-gray-300 px-4 py-2"
></textarea>
<p class="px-2 py-2 text-base text-red-800">{{ errors.description }}</p>
<p class="px-2 py-2 text-base text-red-800">
{{ errors.itemDescription }}
</p>
</div>
<div class="mb-4">
<label for="unit-price" class="mb-2 block font-bold">単価</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ const { errors, values, meta, defineField, setValues } = useForm({
validationSchema: catalogItemSchema,
});
const [name] = defineField('name');
const [description] = defineField('description');
const [itemName] = defineField('itemName');
const [itemDescription] = defineField('itemDescription');
const [price] = defineField('price');
const [productCode] = defineField('productCode');
Expand Down Expand Up @@ -194,8 +194,8 @@ const initItemAsync = async (itemId: number) => {
await getCategoriesAndBrands();
await getItem(itemId);
setValues({
name: currentItemState.value.name,
description: currentItemState.value.description,
itemName: currentItemState.value.name,
itemDescription: currentItemState.value.description,
price: currentItemState.value.price,
productCode: currentItemState.value.productCode,
});
Expand Down Expand Up @@ -265,8 +265,8 @@ const updateItemAsync = async () => {
try {
await updateCatalogItem(
editingItemState.value.id,
values.name,
values.description,
values.itemName,
values.itemDescription,
values.price,
values.productCode,
editingItemState.value.categoryId,
Expand Down Expand Up @@ -464,23 +464,25 @@ const updateItemAsync = async () => {
>
<input
id="item-name"
v-model="name"
v-model="itemName"
type="text"
name="item-name"
class="w-full border border-gray-300 px-4 py-2"
/>
<p class="px-1 py-1 text-base text-red-800">{{ errors.name }}</p>
<p class="px-1 py-1 text-base text-red-800">
{{ errors.itemName }}
</p>
</div>
<div class="mb-4">
<label for="description" class="mb-2 block font-bold">説明</label>
<textarea
id="description"
v-model="description"
name="description"
id="item-description"
v-model="itemDescription"
name="item-description"
class="w-full border border-gray-300 px-4 py-2"
></textarea>
<p class="px-1 py-1 text-base text-red-800">
{{ errors.description }}
{{ errors.itemDescription }}
</p>
</div>
<div class="mb-4">
Expand Down

0 comments on commit ce162d0

Please sign in to comment.