Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-155
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-155
2021-155
Commits
d49badaa
Commit
d49badaa
authored
Jul 02, 2021
by
Ekanayake P.M.D.P IT18013610
☺
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'it18013610' into 'master'
Stackoverflow answer ui created See merge request
!7
parents
aab52fe9
f14e8024
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
154 additions
and
13 deletions
+154
-13
client/components/automated-answer-container/automated-answer-container.module.css
...ed-answer-container/automated-answer-container.module.css
+1
-1
client/components/automated-answer-container/index.js
client/components/automated-answer-container/index.js
+42
-4
client/components/automated-answer/index.js
client/components/automated-answer/index.js
+9
-3
client/components/automated-answer/no-automated-answer/index.js
.../components/automated-answer/no-automated-answer/index.js
+4
-5
client/components/stof-answer/index.js
client/components/stof-answer/index.js
+18
-0
client/components/stof-answer/stof-answer.module.css
client/components/stof-answer/stof-answer.module.css
+12
-0
client/pages/_app.js
client/pages/_app.js
+1
-0
client/styles/automatedanswer.css
client/styles/automatedanswer.css
+67
-0
No files found.
client/components/automated-answer-container/automated-answer-container.module.css
View file @
d49badaa
...
...
@@ -26,7 +26,7 @@
}
.wrapper
{
background-color
:
var
(
--black-
8
00
);
background-color
:
var
(
--black-
9
00
);
color
:
var
(
--white
);
border-radius
:
5px
;
margin
:
2rem
1rem
2rem
1rem
;
...
...
client/components/automated-answer-container/index.js
View file @
d49badaa
import
React
,
{
useEffect
,
useState
}
from
'
react
'
import
{
publicFetch
}
from
'
../../util/fetcher
'
import
AutomatedAnswer
from
'
../automated-answer
'
import
NoAutomatedAnswer
from
'
../automated-answer/no-automated-answer
'
import
{
Spinner
}
from
'
../icons
'
...
...
@@ -6,12 +8,46 @@ import styles from './automated-answer-container.module.css'
const
AutomatedAnswerContainer
=
({
question_id
})
=>
{
const
[
loading
,
setLoading
]
=
useState
(
true
)
const
[
answer
,
setAnswer
]
=
useState
()
const
[
error
,
setError
]
=
useState
({
status
:
''
,
action
:
''
,
button
:
''
,
message
:
''
})
useEffect
(()
=>
{
setTimeout
(()
=>
{
const
fetchAutomatedAnswer
=
async
()
=>
{
try
{
const
response
=
await
publicFetch
.
get
(
`automatedanswer/
${
question_id
}
`
)
if
(
response
.
status
==
200
)
setAnswer
(
response
.
data
)
else
setServerError
({
response
})
}
catch
(
error
)
{
setServerError
(
error
)
}
setLoading
(
false
)
}
,
4000
)
console
.
log
(
question_id
)
}
fetchAutomatedAnswer
(
)
},
[
question_id
])
const
setServerError
=
(
error
)
=>
{
if
(
error
.
response
.
status
==
404
)
{
setError
({
status
:
'
404
'
,
action
:
'
create
'
,
button
:
'
Generate One
'
,
message
:
'
No automated answer found for this question
'
})
}
else
{
setError
({
status
:
'
500
'
,
action
:
'
tryagain
'
,
button
:
'
Try again
'
,
message
:
'
Server error, Please try again
'
})
}
}
return
(
<
div
className
=
{
styles
.
container
}
>
<
div
className
=
{
styles
.
header
}
>
...
...
@@ -22,8 +58,10 @@ const AutomatedAnswerContainer = ({ question_id }) => {
<
div
className
=
{
styles
.
wrapper
}
>
{
loading
?
(
<
Spinner
className
=
{
styles
.
spinner
}
/
>
)
:
answer
!=
null
?
(
<
AutomatedAnswer
automatedAnswer
=
{
answer
.
automatedanswer
}
/
>
)
:
(
<
NoAutomatedAnswer
question_id
=
{
question_id
}
/
>
<
NoAutomatedAnswer
question_id
=
{
question_id
}
error
=
{
error
}
/
>
)}
<
/div
>
<
/div
>
...
...
client/components/automated-answer/index.js
View file @
d49badaa
import
React
from
'
react
'
import
StackOverflowAnswer
from
'
../stof-answer
'
const
AutomatedAnswer
=
({
automatedAnswer
})
=>
{
console
.
log
(
automatedAnswer
)
return
(
<
div
>
<
h1
>
Actual
automated
answer
<
/h1
>
<
/div
>
<>
{
automatedAnswer
.
stackoverflow
!=
null
?
(
<
StackOverflowAnswer
stof
=
{
automatedAnswer
.
stackoverflow
}
/
>
)
:
(
<
h1
>
No
Stack
overflow
<
/h1
>
)}
<
/
>
)
}
...
...
client/components/automated-answer/no-automated-answer/index.js
View file @
d49badaa
import
React
from
'
react
'
import
styles
from
'
./no-automated-answer.module.css
'
const
NoAutomatedAnswer
=
({
question_id
})
=>
{
const
NoAutomatedAnswer
=
({
question_id
,
error
})
=>
{
const
{
status
,
action
,
button
,
message
}
=
error
return
(
<
div
className
=
{
styles
.
no_automated_answer
}
>
<
h1
className
=
{
styles
.
title
}
>
No
Automated
answer
found
for
this
question
<
/h1
>
<
button
className
=
{
styles
.
generate_btn
}
>
Generate
one
<
/button
>
<
h1
className
=
{
styles
.
title
}
>
{
message
}
<
/h1
>
<
button
className
=
{
styles
.
generate_btn
}
>
{
button
}
<
/button
>
<
/div
>
)
}
...
...
client/components/stof-answer/index.js
0 → 100644
View file @
d49badaa
import
React
from
'
react
'
import
styles
from
'
./stof-answer.module.css
'
const
StackOverflowAnswer
=
({
stof
})
=>
{
const
createMarkup
=
()
=>
{
return
{
__html
:
stof
.
content
}
}
return
(
<>
<
h1
className
=
{
styles
.
h
}
>
Answer
from
Stackoverflow
-
{
stof
.
status
}
<
/h1
>
<
div
className
=
{
styles
.
wrapper
}
>
<
div
dangerouslySetInnerHTML
=
{
createMarkup
()}
><
/div
>
<
/div
>
<
/
>
)
}
export
default
StackOverflowAnswer
client/components/stof-answer/stof-answer.module.css
0 → 100644
View file @
d49badaa
@import
url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600&display=swap')
;
.wrapper
{
margin-top
:
0.5em
;
background-color
:
#2d2d2d
;
padding
:
0.8em
;
border-radius
:
10px
;
font-family
:
'Open Sans'
,
sans-serif
;
}
.h
{
font-size
:
1.3em
!important
;
}
client/pages/_app.js
View file @
d49badaa
...
...
@@ -15,6 +15,7 @@ import '../styles/variables.css'
import
'
../styles/nprogress.css
'
import
'
react-tagsinput/react-tagsinput.css
'
import
'
../styles/app.css
'
import
'
../styles/automatedanswer.css
'
Router
.
events
.
on
(
'
routeChangeStart
'
,
()
=>
NProgress
.
start
())
Router
.
events
.
on
(
'
routeChangeComplete
'
,
()
=>
NProgress
.
done
())
...
...
client/styles/automatedanswer.css
0 → 100644
View file @
d49badaa
@import
url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100;200;300;400;500;600;700&display=swap')
;
.s-prose
{
line-height
:
1.5em
;
word-break
:
break-word
;
font-size
:
15px
;
a
{
text-decoration
:
underline
;
color
:
var
(
--blue-300
);
}
a
:hover
{
color
:
var
(
--blue-600
);
}
p
{
margin-bottom
:
1em
;
}
hr
{
border
:
0
;
color
:
var
(
--black-100
);
background-color
:
var
(
--black-100
);
height
:
1px
;
margin-bottom
:
1em
;
}
ul
,
ol
{
margin-left
:
30px
;
list-style-type
:
disc
;
}
code
{
font-size
:
13px
;
font-family
:
'Roboto Mono'
,
monospace
!important
;
}
li
{
margin-bottom
:
0.6em
;
ul
{
margin-top
:
0.6em
;
}
}
}
.s-prose
*
:not
(
.s-code-block
)
>
code
{
padding
:
2px
4px
;
color
:
var
(
--white
);
background-color
:
var
(
--black-600
);
border-radius
:
3px
;
}
sup
,
sub
{
font-size
:
80%
;
line-height
:
1
;
}
sup
{
vertical-align
:
super
;
}
sub
{
vertical-align
:
sub
;
}
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