Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mutirao do Bem
Mutirao do Bem Web
Commits
65c29f25
Commit
65c29f25
authored
3 years ago
by
William Schneider
Browse files
Options
Download
Email Patches
Plain Diff
finished task US15
parent
d0cd6c72
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/RegistrationCard/index.tsx
+57
-4
src/components/RegistrationCard/index.tsx
src/pages/RegistrationRequest/index.tsx
+8
-7
src/pages/RegistrationRequest/index.tsx
src/services/userService.ts
+22
-0
src/services/userService.ts
with
87 additions
and
11 deletions
+87
-11
src/components/RegistrationCard/index.tsx
View file @
65c29f25
...
...
@@ -19,23 +19,74 @@ import {
completeTask
,
leaveTask
,
}
from
"
../../services/taskService
"
;
import
{
accept
,
deny
}
from
"
../../services/userService
"
;
import
{
getLoggedUserFromLocalStorage
}
from
"
../../utils/utils
"
;
import
Button
from
"
../Button
"
;
import
EvaluationModal
from
"
../EvaluationModal
"
;
export
interface
RegistrationCardProps
{
id
?:
string
;
name
?:
string
;
phone
?:
string
;
email
?:
string
;
image
?:
string
;
findUsers
:
()
=>
void
;
}
const
RegistrationCard
=
({
id
=
"
id
"
,
name
=
"
nome de empresa
"
,
phone
=
"
telefone
"
,
email
=
"
email
"
,
image
=
"
uma imagem
"
,
findUsers
,
}:
RegistrationCardProps
)
=>
{
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
toast
=
useToast
();
const
showToastMessage
=
(
title
:
string
,
status
:
"
info
"
|
"
warning
"
|
"
success
"
|
"
error
"
|
undefined
,
position
:
ToastPositionWithLogical
|
undefined
)
=>
{
toast
({
title
,
status
,
position
,
isClosable
:
true
,
});
};
const
acceptUser
=
async
()
=>
{
setLoading
(
true
);
try
{
await
accept
(
id
);
findUsers
();
showToastMessage
(
"
Solicitacao aceita com sucesso!
"
,
"
success
"
,
"
top-right
"
);
}
catch
(
e
:
any
)
{
showToastMessage
(
e
,
"
error
"
,
"
top-right
"
);
}
setLoading
(
false
);
};
const
denyUser
=
async
()
=>
{
setLoading
(
true
);
try
{
await
deny
(
id
);
findUsers
();
showToastMessage
(
"
Solicitacao negada com sucesso!
"
,
"
success
"
,
"
top-right
"
);
}
catch
(
e
:
any
)
{
showToastMessage
(
e
,
"
error
"
,
"
top-right
"
);
}
setLoading
(
false
);
};
return
(
<
Flex
w
=
"100%"
...
...
@@ -82,21 +133,23 @@ const RegistrationCard = ({
theme
=
"quaternary"
width
=
"140px"
height
=
"30px"
onClick
=
{
denyUser
}
isLoading
=
{
loading
}
margin
=
"0px 10px 0px 10px"
fontSize
=
"14px"
>
{
"
"
}
Negar
{
"
"
}
Negar
</
Button
>
<
Button
theme
=
"secondary"
width
=
"140px"
height
=
"30px"
onClick
=
{
acceptUser
}
isLoading
=
{
loading
}
margin
=
"0px 10px 0px 10px"
fontSize
=
"14px"
>
{
"
"
}
Aceitar
{
"
"
}
Aceitar
</
Button
>
</
HStack
>
</
Flex
>
...
...
This diff is collapsed.
Click to expand it.
src/pages/RegistrationRequest/index.tsx
View file @
65c29f25
...
...
@@ -12,12 +12,11 @@ const RegistrationRequest = (): React.ReactElement => {
const
[
usersInactiveEntities
,
setUsersInactiveEntities
]
=
useState
<
User
[]
>
(
[]
);
const
getUsersEntities
=
async
()
=>
{
const
entities
=
await
getUsersInactiveEntities
();
setUsersInactiveEntities
(
entities
);
};
useEffect
(()
=>
{
const
getUsersEntities
=
async
()
=>
{
const
entities
=
await
getUsersInactiveEntities
();
setUsersInactiveEntities
(
entities
);
console
.
log
(
entities
);
};
getUsersEntities
();
},
[]);
...
...
@@ -47,13 +46,15 @@ const RegistrationRequest = (): React.ReactElement => {
</
div
>
<
Box
id
=
"cards-collection"
width
=
"100%"
alignContent
=
"end"
>
<
Box
id
=
"cards-collection2"
width
=
"90%"
marginLeft
=
"10%"
>
{
usersInactiveEntities
.
map
((
entity
)
=>
(
<
Box
id
=
"card"
marginTop
=
"20px"
>
{
usersInactiveEntities
.
map
((
entity
,
key
)
=>
(
<
Box
key
=
{
key
}
marginTop
=
"20px"
>
<
RegistrationCard
id
=
{
entity
.
id
}
name
=
{
entity
.
name
}
email
=
{
entity
.
email
}
image
=
{
entity
.
image
}
phone
=
{
entity
.
phone
}
findUsers
=
{
getUsersEntities
}
/>
</
Box
>
))
}
...
...
This diff is collapsed.
Click to expand it.
src/services/userService.ts
View file @
65c29f25
...
...
@@ -26,3 +26,25 @@ export async function getUsersInactiveEntities(): Promise<User[]> {
return
response
.
data
;
}
export
async
function
accept
(
userId
:
string
):
Promise
<
any
>
{
let
response
=
null
;
await
api
.
put
(
`
${
serviceName
}
/admin/accept/
${
userId
}
`
)
.
then
((
data
)
=>
(
response
=
data
))
.
catch
((
error
)
=>
{
throw
error
;
});
return
response
;
}
export
async
function
deny
(
userId
:
string
):
Promise
<
any
>
{
let
response
=
null
;
await
api
.
put
(
`
${
serviceName
}
/admin/deny/
${
userId
}
`
)
.
then
((
data
)
=>
(
response
=
data
))
.
catch
((
error
)
=>
{
throw
error
;
});
return
response
;
}
This diff is collapsed.
Click to expand it.
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