-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
144f619
commit e68c3c4
Showing
22 changed files
with
739 additions
and
193 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
.../backend/migrations/1586499740485_alter_table_public_user_add_column_first_name/down.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- args: | ||
cascade: false | ||
read_only: false | ||
sql: ALTER TABLE "public"."user" DROP COLUMN "first_name"; | ||
type: run_sql |
5 changes: 5 additions & 0 deletions
5
...es/backend/migrations/1586499740485_alter_table_public_user_add_column_first_name/up.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- args: | ||
cascade: false | ||
read_only: false | ||
sql: ALTER TABLE "public"."user" ADD COLUMN "first_name" bpchar NULL; | ||
type: run_sql |
5 changes: 5 additions & 0 deletions
5
...s/backend/migrations/1586499749809_alter_table_public_user_add_column_last_name/down.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- args: | ||
cascade: false | ||
read_only: false | ||
sql: ALTER TABLE "public"."user" DROP COLUMN "last_name"; | ||
type: run_sql |
5 changes: 5 additions & 0 deletions
5
...ges/backend/migrations/1586499749809_alter_table_public_user_add_column_last_name/up.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- args: | ||
cascade: false | ||
read_only: false | ||
sql: ALTER TABLE "public"."user" ADD COLUMN "last_name" bpchar NULL; | ||
type: run_sql |
25 changes: 25 additions & 0 deletions
25
packages/backend/migrations/1586500484768_update_permission_user_public_table_user/down.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
- args: | ||
role: user | ||
table: | ||
name: user | ||
schema: public | ||
type: drop_insert_permission | ||
- args: | ||
permission: | ||
check: | ||
id: | ||
_eq: X-Hasura-User-Id | ||
columns: | ||
- active | ||
- password | ||
- updated_at | ||
localPresets: | ||
- key: "" | ||
value: "" | ||
set: {} | ||
role: user | ||
table: | ||
name: user | ||
schema: public | ||
type: create_insert_permission |
29 changes: 29 additions & 0 deletions
29
packages/backend/migrations/1586500484768_update_permission_user_public_table_user/up.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
- args: | ||
role: user | ||
table: | ||
name: user | ||
schema: public | ||
type: drop_insert_permission | ||
- args: | ||
permission: | ||
check: | ||
id: | ||
_eq: X-Hasura-User-Id | ||
columns: | ||
- id | ||
- password | ||
- created_at | ||
- active | ||
- updated_at | ||
- first_name | ||
- last_name | ||
localPresets: | ||
- key: "" | ||
value: "" | ||
set: {} | ||
role: user | ||
table: | ||
name: user | ||
schema: public | ||
type: create_insert_permission |
25 changes: 25 additions & 0 deletions
25
packages/backend/migrations/1586500489369_update_permission_user_public_table_user/down.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
- args: | ||
role: user | ||
table: | ||
name: user | ||
schema: public | ||
type: drop_select_permission | ||
- args: | ||
permission: | ||
allow_aggregations: false | ||
columns: | ||
- active | ||
- password | ||
- created_at | ||
- updated_at | ||
- id | ||
computed_fields: [] | ||
filter: | ||
id: | ||
_eq: X-Hasura-User-Id | ||
role: user | ||
table: | ||
name: user | ||
schema: public | ||
type: create_select_permission |
27 changes: 27 additions & 0 deletions
27
packages/backend/migrations/1586500489369_update_permission_user_public_table_user/up.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
- args: | ||
role: user | ||
table: | ||
name: user | ||
schema: public | ||
type: drop_select_permission | ||
- args: | ||
permission: | ||
allow_aggregations: false | ||
columns: | ||
- active | ||
- first_name | ||
- last_name | ||
- password | ||
- created_at | ||
- updated_at | ||
- id | ||
computed_fields: [] | ||
filter: | ||
id: | ||
_eq: X-Hasura-User-Id | ||
role: user | ||
table: | ||
name: user | ||
schema: public | ||
type: create_select_permission |
25 changes: 25 additions & 0 deletions
25
packages/backend/migrations/1586500492823_update_permission_user_public_table_user/down.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
- args: | ||
role: user | ||
table: | ||
name: user | ||
schema: public | ||
type: drop_update_permission | ||
- args: | ||
permission: | ||
columns: | ||
- active | ||
- password | ||
- updated_at | ||
filter: | ||
id: | ||
_eq: X-Hasura-User-Id | ||
localPresets: | ||
- key: "" | ||
value: "" | ||
set: {} | ||
role: user | ||
table: | ||
name: user | ||
schema: public | ||
type: create_update_permission |
29 changes: 29 additions & 0 deletions
29
packages/backend/migrations/1586500492823_update_permission_user_public_table_user/up.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
- args: | ||
role: user | ||
table: | ||
name: user | ||
schema: public | ||
type: drop_update_permission | ||
- args: | ||
permission: | ||
columns: | ||
- active | ||
- first_name | ||
- last_name | ||
- password | ||
- created_at | ||
- updated_at | ||
- id | ||
filter: | ||
id: | ||
_eq: X-Hasura-User-Id | ||
localPresets: | ||
- key: "" | ||
value: "" | ||
set: {} | ||
role: user | ||
table: | ||
name: user | ||
schema: public | ||
type: create_update_permission |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import React from "react"; | ||
import { Box, Link as _Link, Button, Stack } from "@chakra-ui/core"; | ||
import { NextComponentType } from "next"; | ||
import Link from "next/link"; | ||
import { cookieRemover } from "lib/cookie"; | ||
import Router from "next/router"; | ||
import gql from "graphql-tag"; | ||
import { useQuery } from "react-apollo"; | ||
import withApollo from "lib/with-apollo"; | ||
import { cookieParser } from "lib/cookie"; | ||
|
||
const FETCH_USER_QUERY = gql` | ||
query fetchUser($id: uuid!) { | ||
user_by_pk(id: $id) { | ||
id | ||
user_roles { | ||
role { | ||
name | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const Navbar: NextComponentType = () => { | ||
const currentUserId = cookieParser("user-id"); | ||
|
||
const { data, loading, error } = useQuery(FETCH_USER_QUERY, { | ||
variables: { id: currentUserId }, | ||
fetchPolicy: "network-only", | ||
}); | ||
|
||
if (loading) { | ||
return <div>Loading...</div>; | ||
} | ||
|
||
if (error) { | ||
return <p>Error: {error.message}</p>; | ||
} | ||
|
||
const { user_roles } = data.user_by_pk; | ||
|
||
const handleSignOut = () => { | ||
cookieRemover("token"); | ||
cookieRemover("user-id"); | ||
|
||
Router.push("/sign-up"); | ||
}; | ||
|
||
return ( | ||
<Box borderBottomWidth={1} bg="white"> | ||
<Box | ||
maxW="6xl" | ||
w="full" | ||
mx="auto" | ||
d="flex" | ||
justifyContent="space-between" | ||
p={4} | ||
color="gray.700" | ||
> | ||
<Stack | ||
isInline | ||
spacing={4} | ||
align="center" | ||
justifyContent="space-between" | ||
w="full" | ||
> | ||
<Box> | ||
<Stack isInline spacing={4} align="center"> | ||
<Box> | ||
<Link href="/"> | ||
<_Link>Home</_Link> | ||
</Link> | ||
</Box> | ||
{user_roles[0].role.name === "admin" ? ( | ||
<Box> | ||
<Link href="/users"> | ||
<_Link>Users</_Link> | ||
</Link> | ||
</Box> | ||
) : null} | ||
</Stack> | ||
</Box> | ||
<Box> | ||
<Stack isInline spacing={4} align="center"> | ||
<Box> | ||
<Link href="/my-profile"> | ||
<_Link>My Profile</_Link> | ||
</Link> | ||
</Box> | ||
<Box> | ||
<Button variantColor="purple" onClick={handleSignOut}> | ||
Sign out | ||
</Button> | ||
</Box> | ||
</Stack> | ||
</Box> | ||
</Stack> | ||
</Box> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default withApollo(Navbar); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.