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
dc16c4a2
Commit
dc16c4a2
authored
Aug 19, 2022
by
Yoon, Daeki
😅
Browse files
컨텍스트 루트로 로직 변경
parent
44530f9a
Changes
2
Hide whitespace changes
Inline
Side-by-side
frontend/src/surveys/CreateSurvey.tsx
View file @
dc16c4a2
import
React
from
"
react
"
;
import
React
from
"
react
"
;
import
{
surveyApi
}
from
"
../apis
"
;
import
{
surveyApi
}
from
"
../apis
"
;
import
{
useSurveys
}
from
"
../layouts
"
;
import
{
ISurvey
}
from
"
../types
"
;
import
{
ISurvey
}
from
"
../types
"
;
import
{
ModifySurvey
}
from
"
./ModifySurvey
"
;
import
{
ModifySurvey
}
from
"
./ModifySurvey
"
;
export
const
CreateSurvey
=
()
=>
{
export
const
CreateSurvey
=
()
=>
{
const
{
error
,
loading
,
create
}
=
useSurveys
();
const
surveyData
=
{
const
surveyData
=
{
_id
:
""
,
_id
:
""
,
user
:
""
,
user
:
""
,
...
@@ -12,10 +15,10 @@ export const CreateSurvey = () => {
...
@@ -12,10 +15,10 @@ export const CreateSurvey = () => {
questions
:
[],
questions
:
[],
};
};
const
create
=
async
(
surveyData
:
ISurvey
)
=>
{
//
const create = async (surveyData: ISurvey) => {
const
result
=
await
surveyApi
.
createSurvey
(
surveyData
);
//
const result = await surveyApi.createSurvey(surveyData);
return
result
;
//
return result;
};
//
};
return
<
ModifySurvey
surveyData
=
{
surveyData
}
callApi
=
{
create
}
/>;
return
<
ModifySurvey
surveyData
=
{
surveyData
}
callApi
=
{
create
}
/>;
};
};
frontend/src/surveys/EditSurvey.tsx
View file @
dc16c4a2
import
React
from
"
react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
useLocation
}
from
"
react-router-dom
"
;
import
{
Navigate
,
useLocation
,
useParams
}
from
"
react-router-dom
"
;
import
{
surveyApi
}
from
"
../apis
"
;
import
{
surveyApi
}
from
"
../apis
"
;
import
{
ISurvey
}
from
"
../types
"
;
import
{
ISurvey
}
from
"
../types
"
;
import
{
ModifySurvey
}
from
"
./ModifySurvey
"
;
import
{
ModifySurvey
}
from
"
./ModifySurvey
"
;
import
{
useSurvey
}
from
"
../layouts/SurveyLayout
"
;
export
const
EditSurvey
=
()
=>
{
export
const
EditSurvey
=
()
=>
{
const
location
=
useLocation
();
const
{
survey
,
update
}
=
useSurvey
();
const
surveyState
=
location
.
state
as
ISurvey
;
// const [survey, setSurvey] = useState(surveyData);
console
.
log
(
"
edit survey:
"
,
surveyState
);
cons
t
update
=
async
(
surveyData
:
IS
urvey
)
=>
{
cons
ole
.
log
(
"
survey
"
,
s
urvey
)
;
const
result
=
await
surveyApi
.
updateSurvey
(
surveyData
);
//
const
location = useLocation(
);
return
result
;
// const surveyState = location.state as ISurvey
;
}
;
// console.log("edit survey:", surveyState)
;
return
<
ModifySurvey
surveyData
=
{
surveyState
}
callApi
=
{
update
}
/>;
// const update = async (surveyData: ISurvey) => {
// const result = await surveyApi.updateSurvey(surveyData);
// return result;
// };
if
(
!
survey
)
{
return
<
Navigate
to
=
{
"
/surveys
"
}
/>;
}
return
<
ModifySurvey
surveyData
=
{
survey
}
callApi
=
{
update
}
/>;
};
};
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