Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
survey
Commits
4e9e2ee0
Commit
4e9e2ee0
authored
Jul 22, 2022
by
Jiwon Yoon
Browse files
copy clipboard, 버그 수정
parent
0f920a13
Changes
8
Hide whitespace changes
Inline
Side-by-side
frontend/src/commons/SurveyForm.tsx
View file @
4e9e2ee0
...
@@ -75,13 +75,13 @@ export const SurveyForm = () => {
...
@@ -75,13 +75,13 @@ export const SurveyForm = () => {
try
{
try
{
const
formData
=
new
FormData
();
const
formData
=
new
FormData
();
formData
.
append
(
"
surveyId
"
,
answerSurvey
.
current
.
_id
);
formData
.
append
(
"
surveyId
"
,
answerSurvey
.
current
.
_id
);
formData
.
append
(
"
guestId
"
,
""
);
formData
.
append
(
"
guestId
"
,
"
quest1
"
);
formData
.
append
(
"
answers
"
,
JSON
.
stringify
(
answers
));
formData
.
append
(
"
answers
"
,
JSON
.
stringify
(
answers
));
files
.
map
((
f
)
=>
{
files
.
map
((
f
)
=>
{
formData
.
append
(
"
uploadFiles
"
,
f
.
file
);
formData
.
append
(
"
uploadFiles
"
,
f
.
file
);
});
});
const
newAnswer
:
AnswerType
=
await
answerApi
.
saveAnswers
(
formData
);
const
newAnswer
:
AnswerType
=
await
answerApi
.
saveAnswers
(
formData
);
//
console.log(newAnswer);
console
.
log
(
newAnswer
);
setSuccess
(
true
);
setSuccess
(
true
);
setError
(
""
);
setError
(
""
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
frontend/src/icons/copy.png
0 → 100644
View file @
4e9e2ee0
184 Bytes
frontend/src/profile/MySurveyCard.tsx
View file @
4e9e2ee0
...
@@ -3,6 +3,7 @@ import { useNavigate } from "react-router-dom";
...
@@ -3,6 +3,7 @@ import { useNavigate } from "react-router-dom";
import
{
surveyApi
}
from
"
../apis
"
;
import
{
surveyApi
}
from
"
../apis
"
;
import
{
SurveyType
}
from
"
../types
"
;
import
{
SurveyType
}
from
"
../types
"
;
import
{
catchErrors
}
from
"
../helpers
"
;
import
{
catchErrors
}
from
"
../helpers
"
;
import
CopyImg
from
"
../icons/copy.png
"
;
type
Props
=
{
type
Props
=
{
data
:
SurveyType
;
data
:
SurveyType
;
...
@@ -17,6 +18,7 @@ export const MySurveyCard = ({ data }: Props) => {
...
@@ -17,6 +18,7 @@ export const MySurveyCard = ({ data }: Props) => {
const
editSurvey
=
()
=>
{
const
editSurvey
=
()
=>
{
navigate
(
`/surveys/edit/
${
data
.
_id
}
`
,
{
navigate
(
`/surveys/edit/
${
data
.
_id
}
`
,
{
replace
:
true
,
replace
:
true
,
state
:
{
save
:
true
},
});
});
};
};
...
@@ -26,6 +28,11 @@ export const MySurveyCard = ({ data }: Props) => {
...
@@ -26,6 +28,11 @@ export const MySurveyCard = ({ data }: Props) => {
});
});
};
};
const
copyLink
=
()
=>
{
navigator
.
clipboard
.
writeText
(
`http://localhost:8080/surveys/
${
data
.
_id
}
`
);
alert
(
"
설문조사의 링크가 클립보드에 저장되었습니다.
"
);
};
async
function
deleteSurvey
()
{
async
function
deleteSurvey
()
{
try
{
try
{
if
(
data
.
_id
)
{
if
(
data
.
_id
)
{
...
@@ -53,7 +60,7 @@ export const MySurveyCard = ({ data }: Props) => {
...
@@ -53,7 +60,7 @@ export const MySurveyCard = ({ data }: Props) => {
</
div
>
</
div
>
<
div
className
=
"flex flex-col px-5 py-3"
>
<
div
className
=
"flex flex-col px-5 py-3"
>
<
div
className
=
"h-12"
>
<
div
className
=
"h-12"
>
<
button
type
=
"button"
onClick
=
{
go
Survey
}
>
<
button
type
=
"button"
onClick
=
{
edit
Survey
}
>
<
p
className
=
"font-bold"
>
<
p
className
=
"font-bold"
>
{
data
.
title
?
data
.
title
:
"
제목없는 설문조사
"
}
{
data
.
title
?
data
.
title
:
"
제목없는 설문조사
"
}
</
p
>
</
p
>
...
@@ -63,12 +70,9 @@ export const MySurveyCard = ({ data }: Props) => {
...
@@ -63,12 +70,9 @@ export const MySurveyCard = ({ data }: Props) => {
</
p
>
</
p
>
</
div
>
</
div
>
<
div
className
=
"flex justify-end pt-1"
>
<
div
className
=
"flex justify-end pt-1"
>
<
button
<
label
className
=
"pt-1"
>
링크복사
</
label
>
type
=
"button"
<
button
className
=
""
onClick
=
{
copyLink
}
>
className
=
"bg-themeColor rounded text-white py-1 px-1.5 mr-1"
<
img
src
=
{
CopyImg
}
alt
=
"copy"
></
img
>
onClick
=
{
editSurvey
}
>
수정
</
button
>
</
button
>
<
button
<
button
type
=
"button"
type
=
"button"
...
...
frontend/src/questions/Question.tsx
View file @
4e9e2ee0
...
@@ -13,6 +13,7 @@ type Props = {
...
@@ -13,6 +13,7 @@ type Props = {
element
:
BasicQuestionType
;
element
:
BasicQuestionType
;
handleQuestion
:
(
id
:
string
)
=>
void
;
handleQuestion
:
(
id
:
string
)
=>
void
;
deleteQuestion
:
(
id
:
string
)
=>
void
;
deleteQuestion
:
(
id
:
string
)
=>
void
;
isSave
:
boolean
;
};
};
const
typeDropDown
=
new
Map
([
const
typeDropDown
=
new
Map
([
...
@@ -30,8 +31,9 @@ export const Question = ({
...
@@ -30,8 +31,9 @@ export const Question = ({
element
,
element
,
handleQuestion
,
handleQuestion
,
deleteQuestion
,
deleteQuestion
,
isSave
,
}:
Props
)
=>
{
}:
Props
)
=>
{
const
[
save
,
setSave
]
=
useState
(
tru
e
);
const
[
save
,
setSave
]
=
useState
(
isSav
e
);
async
function
handleEditComplete
()
{
async
function
handleEditComplete
()
{
try
{
try
{
const
newQuestion
:
BasicQuestionType
=
await
questionApi
.
updateQuestion
(
const
newQuestion
:
BasicQuestionType
=
await
questionApi
.
updateQuestion
(
...
...
frontend/src/survey/EditSurvey.tsx
View file @
4e9e2ee0
import
React
,
{
FormEvent
,
useEffect
,
useState
}
from
"
react
"
;
import
React
,
{
FormEvent
,
useEffect
,
useState
}
from
"
react
"
;
import
{
useParams
}
from
"
react-router-dom
"
;
import
{
useParams
,
useLocation
}
from
"
react-router-dom
"
;
import
{
questionApi
,
surveyApi
}
from
"
../apis
"
;
import
{
questionApi
,
surveyApi
}
from
"
../apis
"
;
import
{
SpinnerIcon
}
from
"
../icons
"
;
import
{
SpinnerIcon
}
from
"
../icons
"
;
import
{
Question
}
from
"
../questions
"
;
import
{
Question
}
from
"
../questions
"
;
...
@@ -8,6 +8,12 @@ import { catchErrors } from "../helpers";
...
@@ -8,6 +8,12 @@ import { catchErrors } from "../helpers";
export
const
EditSurvey
=
()
=>
{
export
const
EditSurvey
=
()
=>
{
let
{
surveyId
}
=
useParams
<
{
surveyId
:
string
}
>
();
let
{
surveyId
}
=
useParams
<
{
surveyId
:
string
}
>
();
interface
CustomizedState
{
save
:
boolean
;
}
const
location
=
useLocation
();
const
state
=
location
.
state
as
CustomizedState
;
useEffect
(()
=>
{
useEffect
(()
=>
{
getSurvey
();
getSurvey
();
},
[
surveyId
]);
},
[
surveyId
]);
...
@@ -100,6 +106,7 @@ export const EditSurvey = () => {
...
@@ -100,6 +106,7 @@ export const EditSurvey = () => {
const
questions
=
survey
.
questions
;
const
questions
=
survey
.
questions
;
console
.
log
(
questions
);
console
.
log
(
questions
);
console
.
log
(
state
);
return
(
return
(
<>
<>
{
error
?
alert
(
error
)
:
<></>
}
{
error
?
alert
(
error
)
:
<></>
}
...
@@ -130,6 +137,7 @@ export const EditSurvey = () => {
...
@@ -130,6 +137,7 @@ export const EditSurvey = () => {
{
questions
.
map
((
question
)
=>
(
{
questions
.
map
((
question
)
=>
(
<
Question
<
Question
element
=
{
question
}
element
=
{
question
}
isSave
=
{
state
?
true
:
false
}
handleQuestion
=
{
handleQuestion
}
handleQuestion
=
{
handleQuestion
}
deleteQuestion
=
{
deleteQuestion
}
deleteQuestion
=
{
deleteQuestion
}
/>
/>
...
...
frontend/src/types/custom.d.ts
0 → 100644
View file @
4e9e2ee0
declare
module
"
*.svg
"
{
const
content
:
any
;
export
default
content
;
}
declare
module
"
*.png
"
{
const
value
:
any
;
export
=
value
;
}
frontend/tsconfig.json
View file @
4e9e2ee0
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
//
"baseUrl"
:
"./"
,
/*
Specify
the
base
directory
to
resolve
non-relative
module
names.
*/
//
"baseUrl"
:
"./"
,
/*
Specify
the
base
directory
to
resolve
non-relative
module
names.
*/
//
"paths"
:
{},
/*
Specify
a
set
of
entries
that
re-map
imports
to
additional
lookup
locations.
*/
//
"paths"
:
{},
/*
Specify
a
set
of
entries
that
re-map
imports
to
additional
lookup
locations.
*/
//
"rootDirs"
:
[],
/*
Allow
multiple
folders
to
be
treated
as
one
when
resolving
modules.
*/
//
"rootDirs"
:
[],
/*
Allow
multiple
folders
to
be
treated
as
one
when
resolving
modules.
*/
//
"typeRoots"
:
[],
/*
Specify
multiple
folders
that
act
like
'./node_modules/@types'.
*/
"typeRoots"
:
[
"./src/types"
],
/*
Specify
multiple
folders
that
act
like
'./node_modules/@types'.
*/
//
"types"
:
[],
/*
Specify
type
package
names
to
be
included
without
being
referenced
in
a
source
file.
*/
//
"types"
:
[],
/*
Specify
type
package
names
to
be
included
without
being
referenced
in
a
source
file.
*/
//
"allowUmdGlobalAccess"
:
true
,
/*
Allow
accessing
UMD
globals
from
modules.
*/
//
"allowUmdGlobalAccess"
:
true
,
/*
Allow
accessing
UMD
globals
from
modules.
*/
//
"moduleSuffixes"
:
[],
/*
List
of
file
name
suffixes
to
search
when
resolving
a
module.
*/
//
"moduleSuffixes"
:
[],
/*
List
of
file
name
suffixes
to
search
when
resolving
a
module.
*/
...
...
src/controllers/answer.controller.ts
View file @
4e9e2ee0
...
@@ -34,6 +34,7 @@ export const createAnswers = asyncWrap(async (reqExp, res) => {
...
@@ -34,6 +34,7 @@ export const createAnswers = asyncWrap(async (reqExp, res) => {
}
}
}
}
// 3) Answer DB 만들기(map을 돌려서 하나씩 추가시켜야 함)
// 3) Answer DB 만들기(map을 돌려서 하나씩 추가시켜야 함)
console
.
log
(
"
원래 answer
"
,
answer
);
for
(
let
index
=
0
;
index
<
answer
.
answers
.
length
;
index
++
)
{
for
(
let
index
=
0
;
index
<
answer
.
answers
.
length
;
index
++
)
{
const
element
=
answer
.
answers
[
index
];
const
element
=
answer
.
answers
[
index
];
const
newAnswer
=
await
answerDb
.
createAnswer
({
const
newAnswer
=
await
answerDb
.
createAnswer
({
...
@@ -44,15 +45,14 @@ export const createAnswers = asyncWrap(async (reqExp, res) => {
...
@@ -44,15 +45,14 @@ export const createAnswers = asyncWrap(async (reqExp, res) => {
});
});
console
.
log
(
"
DB에 넣은 answer
"
,
newAnswer
);
console
.
log
(
"
DB에 넣은 answer
"
,
newAnswer
);
}
}
// 주의: ref는 반드시 save를 해야 디비에 생성이 됩니다.
return
res
.
json
();
return
res
.
json
();
}
catch
(
error
:
any
)
{
}
catch
(
error
:
any
)
{
console
.
log
(
"
error in create
us
er:
"
,
error
);
console
.
log
(
"
error in create
answ
er:
"
,
error
);
// 오류 발생시 저장된 파일 제거
// 오류 발생시 저장된 파일 제거
if
(
files
)
{
if
(
files
)
{
// uploadFiles && (await fileDb.deleteFileById(uploadFiles._id.toString()));
// uploadFiles && (await fileDb.deleteFileById(uploadFiles._id.toString()));
// await fs.unlink(files.filepath);
// await fs.unlink(files.filepath);
}
}
res
.
status
(
422
).
send
(
error
.
message
||
"
사용자
생성 오류
"
);
res
.
status
(
422
).
send
(
error
.
message
||
"
설문조사 응답
생성 오류
"
);
}
}
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment