Skip to content

Commit

Permalink
fix: user verification
Browse files Browse the repository at this point in the history
  • Loading branch information
lakhansamani committed Mar 28, 2024
1 parent 27b51ad commit 67f866a
Show file tree
Hide file tree
Showing 21 changed files with 2,040 additions and 1,806 deletions.
902 changes: 451 additions & 451 deletions app/yarn.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dashboard/src/graphql/queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export const UserDetailsQuery = `
id
email
email_verified
phone_number_verified
given_name
family_name
middle_name
Expand Down
59 changes: 41 additions & 18 deletions dashboard/src/pages/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,25 @@ export default function Users() {
};

const userVerificationHandler = async (user: userDataTypes) => {
const { id, email } = user;
const { id, email, phone_number } = user;
let params = {};
if (email) {
params = {
id,
email,
email_verified: true,
};
}
if (phone_number) {
params = {
id,
phone_number,
phone_number_verified: true,
};
}
const res = await client
.mutation(UpdateUser, {
params: {
id,
email,
email_verified: true,
},
params,
})
.toPromise();
if (res.error) {
Expand Down Expand Up @@ -298,7 +309,7 @@ export default function Users() {
<Table variant="simple">
<Thead>
<Tr>
<Th>Email</Th>
<Th>Email / Phone</Th>
<Th>Created At</Th>
<Th>Signup Methods</Th>
<Th>Roles</Th>
Expand All @@ -314,10 +325,15 @@ export default function Users() {
</Thead>
<Tbody>
{userList.map((user: userDataTypes) => {
const { email_verified, created_at, ...rest }: any = user;
const {
email_verified,
phone_number_verified,
created_at,
...rest
}: any = user;
return (
<Tr key={user.id} style={{ fontSize: 14 }}>
<Td maxW="300">{user.email}</Td>
<Td maxW="300">{user.email || user.phone_number}</Td>
<Td>
{dayjs(user.created_at * 1000).format('MMM DD, YYYY')}
</Td>
Expand All @@ -327,9 +343,15 @@ export default function Users() {
<Tag
size="sm"
variant="outline"
colorScheme={user.email_verified ? 'green' : 'yellow'}
colorScheme={
user.email_verified || user.phone_number_verified
? 'green'
: 'yellow'
}
>
{user.email_verified.toString()}
{(
user.email_verified || user.phone_number_verified
).toString()}
</Tag>
</Td>
<Td>
Expand Down Expand Up @@ -368,13 +390,14 @@ export default function Users() {
</Flex>
</MenuButton>
<MenuList>
{!user.email_verified && (
<MenuItem
onClick={() => userVerificationHandler(user)}
>
Verify User
</MenuItem>
)}
{!user.email_verified &&
!user.phone_number_verified && (
<MenuItem
onClick={() => userVerificationHandler(user)}
>
Verify User
</MenuItem>
)}
<EditUserModal
user={rest}
updateUserList={updateUserList}
Expand Down
Loading

0 comments on commit 67f866a

Please sign in to comment.