-
Notifications
You must be signed in to change notification settings - Fork 0
Clap-191 요청 생성 API 연결 #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8516955
:sparkles: [feat] : 폼데이터 요청 api 형식 분리
Minkyu0424 cc92a7a
:recycle: [refactor] : prop대신 직접 가져오기, 파일 초기값 배열로
Minkyu0424 68a7bac
:recycle: [refactor] : 1,2차 카테고리 타입 선언 및 위치 변경
Minkyu0424 c9f2382
:sparkles: [feat] : 카테고리용 드롭다운 개별 생성
Minkyu0424 19e044f
:sparkles: [feat] : 1, 2차 카테고리 조회 api 연결
Minkyu0424 9481f92
:sparkles: [feat] : 요청 생성 api 연결
Minkyu0424 c435e5d
:sparkles: [feat] : 정보 누락시 경고 텍스트 출력
Minkyu0424 a2865d9
:sparkles: [feat] : 요청 완료 후 모달 및 라우팅
Minkyu0424 bc55be4
:twisted_rightwards_arrows: [fix] : conflict resolved
Minkyu0424 cf42db1
:recycle: [refactor] : axios instance 객체 분리해서 import
Minkyu0424 6f14671
:recycle: [refactor] : 카테고리 드롭다운 placeholder없이, input placeholder 상수화 취소
Minkyu0424 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { axiosInstance } from '../utils/axios' | ||
|
|
||
| export const getMainCategory = async () => { | ||
| const response = await axiosInstance.get('/api/main-category') | ||
| return response.data | ||
| } | ||
|
|
||
| export const getSubCategory = async () => { | ||
| const response = await axiosInstance.get('/api/sub-category') | ||
| return response.data | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { formDataAxiosInstance } from '@/utils/axios' | ||
|
|
||
| export const postTaskRequest = async (formdata: FormData) => { | ||
| const response = await formDataAxiosInstance.post('/api/tasks', formdata) | ||
| return response.data | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| <template> | ||
| <div> | ||
| <div class="flex text-xs gap-x-1 mb-2"> | ||
| <p class="text-body font-bold">{{ labelName }}</p> | ||
| <p | ||
| v-if="!isLabel" | ||
| class="text-red-1"> | ||
| * | ||
| </p> | ||
| <p | ||
| v-if="isInvalidateState === 'category'" | ||
| class="text-red-1"> | ||
| 카테고리를 선택해주세요 | ||
| </p> | ||
| </div> | ||
| <div class="relative flex text-base"> | ||
| <div | ||
| class="flex w-full h-11 items-center rounded p-4 bg-white border border-border-1 cursor-pointer text-black" | ||
| @click="toggleDropdown"> | ||
| <p :class="{ 'text-disabled': !modelValue?.name }"> | ||
| {{ modelValue?.name ?? labelName + '를 선택해주세요' }} | ||
| </p> | ||
| <CommonIcons | ||
| :name="dropdownIcon" | ||
| :class="['ml-auto', { 'rotate-180': dropdownOpen }]" /> | ||
| </div> | ||
| <div | ||
| v-if="dropdownOpen" | ||
| class="absolute w-full h-40 overflow-y-auto top-[52px] flex flex-col gap-2 p-2 bg-white rounded z-10 shadow border-t border-t-border-2 text-black"> | ||
| <div | ||
| v-for="option in options" | ||
| :key="option.id" | ||
| class="w-full flex items-center h-11 p-2 rounded hover:bg-background-2 cursor-pointer" | ||
| @click="selectOption(option)"> | ||
| {{ option.name }} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script lang="ts" setup> | ||
| import { dropdownIcon } from '@/constants/iconPath' | ||
| import type { CategoryDropdownProps, MainCategoryTypes, SubCategoryTypes } from '@/types/common' | ||
| import { computed, ref } from 'vue' | ||
| import CommonIcons from '../common/CommonIcons.vue' | ||
|
|
||
| const { options, labelName, modelValue, isLabel, isDisabled, isInvalidate } = | ||
| defineProps<CategoryDropdownProps>() | ||
|
|
||
| const isInvalidateState = computed(() => isInvalidate) | ||
|
|
||
| const emit = defineEmits(['update:modelValue']) | ||
| const dropdownOpen = ref(false) | ||
|
|
||
| const toggleDropdown = () => { | ||
| if (isDisabled) return | ||
| dropdownOpen.value = !dropdownOpen.value | ||
| } | ||
|
|
||
| const selectOption = (option: MainCategoryTypes | SubCategoryTypes) => { | ||
| emit('update:modelValue', option) | ||
| dropdownOpen.value = false | ||
| } | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,69 +1,120 @@ | ||
| <template> | ||
| <div class="w-full flex flex-col gap-y-6"> | ||
| <RequestTaskDropdown | ||
| <CategoryDropDown | ||
| v-model="category1" | ||
| :options="DUMMY_REQUEST_TASK_CATEGORIES" | ||
| :options="mainCategoryArr" | ||
| :label-name="'1차 카테고리'" | ||
| :placeholderText="'1차 카테고리를 선택해주세요'" /> | ||
| <RequestTaskDropdown | ||
| :isInvalidate="isInvalidate" | ||
| :isDisabled="false" /> | ||
| <CategoryDropDown | ||
| v-model="category2" | ||
| :options="DUMMY_REQUEST_TASK_CATEGORIES" | ||
| :options="afterSubCategoryArr" | ||
| :label-name="'2차 카테고리'" | ||
| :placeholderText="'2차 카테고리를 선택해주세요'" /> | ||
| :is-invalidate="isInvalidate" | ||
| :isDisabled="!category1" /> | ||
| <RequestTaskInput | ||
| v-model="title" | ||
| :placeholderText="TITLE_PLACEHOLDER" | ||
| :label-name="'제목'" /> | ||
| :placeholderText="'제목을 입력해주세요'" | ||
| :label-name="'제목'" | ||
| :is-invalidate="isInvalidate" /> | ||
| <RequestTaskTextArea | ||
| v-model="description" | ||
| :placeholderText="EXPLANATION_PLACEHOLDER" /> | ||
| :placeholderText="'부가 정보를 입력해주세요'" /> | ||
| <RequestTaskFileInput v-model="file" /> | ||
| <FormButtonContainer | ||
| :handleCancel="handleCancel" | ||
| :handleSubmit="handleSubmit" | ||
| cancelText="취소" | ||
| submitText="요청" /> | ||
| <ModalView | ||
| :isOpen="isModalVisible" | ||
| :type="'successType'" | ||
| @close="handleCancel"> | ||
| <template #header>작업이 요청되었습니다</template> | ||
| </ModalView> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script lang="ts" setup> | ||
| import { EXPLANATION_PLACEHOLDER, TITLE_PLACEHOLDER } from '@/constants/user' | ||
| import { DUMMY_REQUEST_TASK_CATEGORIES } from '@/datas/taskdetail' | ||
| import { ref } from 'vue' | ||
| import { getMainCategory, getSubCategory } from '@/api/common' | ||
| import { postTaskRequest } from '@/api/user' | ||
| import type { MainCategoryTypes, SubCategoryTypes } from '@/types/common' | ||
| import { onMounted, ref, watch } from 'vue' | ||
| import { useRouter } from 'vue-router' | ||
| import FormButtonContainer from '../common/FormButtonContainer.vue' | ||
| import RequestTaskDropdown from './RequestTaskDropdown.vue' | ||
| import ModalView from '../ModalView.vue' | ||
| import CategoryDropDown from './CategoryDropDown.vue' | ||
| import RequestTaskFileInput from './RequestTaskFileInput.vue' | ||
| import RequestTaskInput from './RequestTaskInput.vue' | ||
| import RequestTaskTextArea from './RequestTaskTextArea.vue' | ||
| import { useRouter } from 'vue-router' | ||
|
|
||
| const category1 = ref('1차 카테고리를 선택해주세요') | ||
| const category2 = ref('2차 카테고리를 선택해주세요') | ||
| const category1 = ref<MainCategoryTypes | null>(null) | ||
| const category2 = ref<MainCategoryTypes | null>(null) | ||
|
|
||
| const title = ref('') | ||
| const description = ref('') | ||
| const file = ref(null as File[] | null) | ||
| const isInvalidate = ref('') | ||
| const isModalVisible = ref(false) | ||
|
|
||
| const mainCategoryArr = ref<MainCategoryTypes[]>([]) | ||
| const subCategoryArr = ref<SubCategoryTypes[]>([]) | ||
| const afterSubCategoryArr = ref<SubCategoryTypes[]>([]) | ||
|
|
||
| onMounted(async () => { | ||
| mainCategoryArr.value = await getMainCategory() | ||
| subCategoryArr.value = await getSubCategory() | ||
| afterSubCategoryArr.value = await getSubCategory() | ||
| }) | ||
|
|
||
| watch(category1, async newValue => { | ||
| category2.value = null | ||
| afterSubCategoryArr.value = subCategoryArr.value.filter( | ||
| subCategory => subCategory.mainCategoryId === newValue?.id | ||
| ) | ||
| }) | ||
|
|
||
| const router = useRouter() | ||
|
|
||
| const handleCancel = () => { | ||
| category1.value = '' | ||
| category2.value = '' | ||
| category1.value = null | ||
| category2.value = null | ||
| title.value = '' | ||
| description.value = '' | ||
| file.value = null | ||
| file.value = [] | ||
| router.back() | ||
| } | ||
|
|
||
| const handleSubmit = () => { | ||
| const handleSubmit = async () => { | ||
| if (!category1.value || !category2.value) { | ||
| isInvalidate.value = 'category' | ||
| console.log(isInvalidate.value, '변경됨') | ||
| return | ||
| } else if (!title.value) { | ||
| isInvalidate.value = 'input' | ||
| return | ||
| } | ||
| const formData = new FormData() | ||
| formData.append('category1', category1.value) | ||
| formData.append('category2', category2.value) | ||
| formData.append('title', title.value) | ||
| formData.append('description', description.value) | ||
| if (file.value) { | ||
| file.value.forEach(f => { | ||
| formData.append('file', f) | ||
| }) | ||
| const taskInfo = { | ||
| categoryId: category2.value.id, | ||
| title: title.value, | ||
| description: description.value | ||
| } | ||
|
|
||
| const jsonTaskInfo = JSON.stringify(taskInfo) | ||
| const newBlob = new Blob([jsonTaskInfo], { type: 'application/json' }) | ||
|
|
||
| formData.append('taskInfo', newBlob) | ||
|
|
||
| if (file.value && file.value.length > 0) { | ||
| file.value.forEach(f => formData.append('attachment', f)) | ||
| } | ||
| try { | ||
| const res = await postTaskRequest(formData) | ||
| isModalVisible.value = true | ||
| console.error('요청 성공:', res) | ||
| } catch (error) { | ||
| console.error('요청 실패:', error) | ||
| } | ||
| console.log(Object.fromEntries(formData)) | ||
| } | ||
| </script> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
더미 데이터는 삭제하고 있으신 걸까요?
사용되지 않을 더미 데이터는 확인 후 삭제 부탁드립니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아직 1,2차 카테고리를 사용하는 페이지들에 전부 반영하지 않아서 (요청 승인) 해당 파트를 진행하며 마지막으로 지우려합니다!