Skip to content

Commit a2269b9

Browse files
committed
✨ [feat] : CSV로 회원 추가 및 revalidate 연결
1 parent a77403d commit a2269b9

File tree

4 files changed

+61
-10
lines changed

4 files changed

+61
-10
lines changed

src/api/admin.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { NewLabelTypes, UserRegistrationApiProps } from '@/types/admin'
22
import type { LabelDataTypes } from '@/types/common'
3-
import { axiosInstance } from '@/utils/axios'
3+
import { axiosInstance, formDataAxiosInstance } from '@/utils/axios'
44

55
export const deleteLabelAdmin = async (id: number) => {
66
const response = await axiosInstance.delete(`/api/managements/labels/${id}`)
@@ -34,3 +34,8 @@ export const getDepartmentsAdmin = async () => {
3434
const response = await axiosInstance.get('/api/managements/departments')
3535
return response.data
3636
}
37+
38+
export const addMemberAdminByCsv = async (formdata: FormData) => {
39+
const response = await formDataAxiosInstance.post('/api/managements/members/upload', formdata)
40+
return response.data
41+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<template>
2+
<input
3+
class="hidden"
4+
type="file"
5+
id="file"
6+
accept=".csv"
7+
@change="handleFileUpload" />
8+
<label
9+
for="file"
10+
class="cursor-pointer flex items-center gap-1 text-xs font-bold text-primary1">
11+
<CommonIcons
12+
:name="plusIcon"
13+
:style="{ fill: '#7879EB' }" />
14+
파일로 일괄 추가
15+
</label>
16+
<ModalView
17+
:isOpen="isModalVisible"
18+
:type="'successType'"
19+
@close="handleCancel">
20+
<template #header> 회원이 추가되었습니다 </template>
21+
</ModalView>
22+
</template>
23+
24+
<script setup lang="ts">
25+
import { addMemberAdminByCsv } from '@/api/admin'
26+
import { plusIcon } from '@/constants/iconPath'
27+
import { useMemberManagementParamsStore } from '@/stores/params'
28+
import { useQueryClient } from '@tanstack/vue-query'
29+
import { ref } from 'vue'
30+
import CommonIcons from '../common/CommonIcons.vue'
31+
import ModalView from '../ModalView.vue'
32+
33+
const queryClient = useQueryClient()
34+
const isModalVisible = ref(false)
35+
const { params } = useMemberManagementParamsStore()
36+
37+
const handleFileUpload = async (event: Event) => {
38+
const target = event.target as HTMLInputElement
39+
const file = target.files?.[0]
40+
if (!file) return
41+
const formData = new FormData()
42+
formData.append('file', file)
43+
await addMemberAdminByCsv(formData)
44+
queryClient.invalidateQueries({ queryKey: ['member', { ...params }] })
45+
isModalVisible.value = true
46+
target.value = ''
47+
}
48+
49+
const handleCancel = () => {
50+
isModalVisible.value = false
51+
}
52+
</script>

src/components/request-task/RequestTaskInput.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<input
1212
class="w-full h-11 border border-border-1 px-4 focus:outline-none text-black rounded"
1313
:value="modelValue"
14-
:disabled="isEdit || isDisbled"
14+
:disabled="isEdit"
1515
@input="updateValue(($event.target as HTMLInputElement).value)"
1616
:placeholder="placeholderText" />
1717
<p

src/views/MemberManagement.vue

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22
<div class="list-view">
33
<TitleBar title="회원 관리">
44
<template #button>
5-
<button
6-
class="flex items-center gap-1 text-xs font-bold text-primary1"
7-
@click="() => {}">
8-
<CommonIcons
9-
:name="plusIcon"
10-
:style="{ fill: '#7879EB' }" />
11-
파일로 일괄 추가
12-
</button>
5+
<MemberManagementAddByCsv />
136
<button
147
class="flex items-center gap-1 text-xs font-bold text-primary1"
158
@click="createNewMember">
@@ -29,6 +22,7 @@
2922

3023
<script setup lang="ts">
3124
import CommonIcons from '@/components/common/CommonIcons.vue'
25+
import MemberManagementAddByCsv from '@/components/member-management/MemberManagementAddByCsv.vue'
3226
import MemberManagementFilterBar from '@/components/member-management/MemberManagementFilterBar.vue'
3327
import MemberManagementList from '@/components/member-management/MemberManagementList.vue'
3428
import TitleBar from '@/components/TitleBar.vue'

0 commit comments

Comments
 (0)