Skip to content

Commit

Permalink
Merge pull request #314 from labzero/jeffrey/fixes
Browse files Browse the repository at this point in the history
Check for user instead of id; bring back CITEXT
  • Loading branch information
JeffreyATW authored May 19, 2023
2 parents 3dfe7e0 + bbbabd4 commit 99bd24e
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("RestaurantAddTagForm", () => {
props = {
id: 1,
votes: [{ restaurantId: 1 }],
user: {},
user: { id: 1 },
users: [],
};
});
Expand Down
4 changes: 2 additions & 2 deletions src/models/Invitation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Column, Model, Table } from "sequelize-typescript";
import { Column, DataType, Model, Table } from "sequelize-typescript";

@Table({ modelName: "invitation" })
class Invitation extends Model {
@Column({ allowNull: false, unique: true })
@Column({ allowNull: false, type: DataType.CITEXT, unique: true })
email: string;

@Column
Expand Down
3 changes: 2 additions & 1 deletion src/models/User.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
BelongsToMany,
Column,
DataType,
HasMany,
Model,
Scopes,
Expand Down Expand Up @@ -92,7 +93,7 @@ class User extends Model {
@Column
name: string;

@Column
@Column({ type: DataType.CITEXT })
email: string;

@Column
Expand Down
2 changes: 1 addition & 1 deletion src/routes/helpers/renderIfHasName.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default (context, makeRoute) => {
redirect = `${redirect}&team=${context.subdomain}`;
}

if (user.id) {
if (user) {
if (user.name) {
return makeRoute();
}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/helpers/tests/renderIfHasName.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("routes/helpers/renderIfHasName", () => {
}).default;
context = {
store: mockStore({
user: {},
user: null,
}),
};
renderIfHasNameProxy(context, makeRouteSpy);
Expand Down
2 changes: 1 addition & 1 deletion src/routes/main/account/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default (context) => {
const state = context.store.getState();
const user = state.user;

if (user.id) {
if (user) {
return {
title,
chunks: ["account"],
Expand Down
2 changes: 1 addition & 1 deletion src/routes/main/welcome/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default (context) => {
const state = context.store.getState();
const user = state.user;

if (user.id) {
if (user) {
return {
title,
chunks: ["welcome"],
Expand Down
8 changes: 6 additions & 2 deletions src/routes/team/home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import s from "./Home.scss";

export class _Home extends Component {
static propTypes = {
user: PropTypes.object.isRequired,
user: PropTypes.object,
fetchDecisions: PropTypes.func.isRequired,
fetchRestaurants: PropTypes.func.isRequired,
fetchTags: PropTypes.func.isRequired,
Expand All @@ -28,6 +28,10 @@ export class _Home extends Component {
wsPort: PropTypes.number.isRequired,
};

static defaultProps = {
user: null,
};

componentDidMount() {
const { messageReceived, wsPort } = this.props;

Expand Down Expand Up @@ -98,7 +102,7 @@ export class _Home extends Component {
</div>
<div className={s.listContainer} id="listContainer">
<section className={s.forms} id="listForms">
{user.id && <RestaurantAddFormContainer />}
{user && <RestaurantAddFormContainer />}
<NameFilterFormContainer />
<TagFilterFormContainer />
<TagFilterFormContainer exclude />
Expand Down
4 changes: 2 additions & 2 deletions src/routes/team/home/Home.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe("Home", () => {
invalidateUsers,
messageReceived: () => undefined,
pastDecisionsShown: false,
user: {},
user: null,
wsPort: 3000,
};
});
Expand All @@ -91,7 +91,7 @@ describe("Home", () => {
};

it("renders form if user is logged in", async () => {
props.user.id = 1;
props.user = { id: 1 };

await renderComponent();

Expand Down

0 comments on commit 99bd24e

Please sign in to comment.