) => {
+ e.preventDefault()
+ if (!name && !email && !bio) {
+ setToast({
+ text: "Please fill out at least one field",
+ type: "error"
+ })
+ return
+ }
- const data = {
- displayName: name,
- email,
- bio,
- }
+ const data = {
+ displayName: name,
+ email,
+ bio
+ }
- const res = await fetch("/server-api/user/profile", {
- method: "PUT",
- headers: {
- "Content-Type": "application/json",
- "Authorization": `Bearer ${Cookies.get("drift-token")}`,
- },
- body: JSON.stringify(data),
- })
+ const res = await fetch("/server-api/user/profile", {
+ method: "PUT",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${Cookies.get("drift-token")}`
+ },
+ body: JSON.stringify(data)
+ })
- if (res.status === 200) {
- setToast({
- text: "Profile updated",
- type: "success",
- })
- } else {
- setToast({
- text: "Something went wrong updating your profile",
- type: "error",
- })
- }
- }
+ if (res.status === 200) {
+ setToast({
+ text: "Profile updated",
+ type: "success"
+ })
+ } else {
+ setToast({
+ text: "Something went wrong updating your profile",
+ type: "error"
+ })
+ }
+ }
- return (<>
-
- This information will be publicly available on your profile
-
- >)
+ return (
+ <>
+
+ This information will be publicly available on your profile
+
+
+ >
+ )
}
-export default Profile
\ No newline at end of file
+export default Profile
diff --git a/client/pages/index.tsx b/client/pages/index.tsx
index 048a0fca..e560ed4a 100644
--- a/client/pages/index.tsx
+++ b/client/pages/index.tsx
@@ -3,14 +3,16 @@ import PageSeo from "@components/page-seo"
import HomeComponent from "@components/home"
import { Page, Text } from "@geist-ui/core"
import type { GetStaticProps } from "next"
-import { InferGetStaticPropsType } from 'next'
-type Props = {
- introContent: string
- introTitle: string
- rendered: string
-} | {
- error: boolean
-}
+import { InferGetStaticPropsType } from "next"
+type Props =
+ | {
+ introContent: string
+ introTitle: string
+ rendered: string
+ }
+ | {
+ error: boolean
+ }
export const getStaticProps: GetStaticProps = async () => {
try {
@@ -32,21 +34,26 @@ export const getStaticProps: GetStaticProps = async () => {
// Next.js will attempt to re-generate the page:
// - When a request comes in
// - At most every 60 seconds
- revalidate: 60, // In seconds
+ revalidate: 60 // In seconds
}
} catch (err) {
// If there was an error, it's likely due to the server not running, so we attempt to regenerate the page
return {
props: {
- error: true,
+ error: true
},
- revalidate: 10, // In seconds
+ revalidate: 10 // In seconds
}
}
}
// TODO: fix props type
-const Home = ({ rendered, introContent, introTitle, error }: InferGetStaticPropsType) => {
+const Home = ({
+ rendered,
+ introContent,
+ introTitle,
+ error
+}: InferGetStaticPropsType) => {
return (
diff --git a/client/pages/post/[id].tsx b/client/pages/post/[id].tsx
index 10531bac..24894667 100644
--- a/client/pages/post/[id].tsx
+++ b/client/pages/post/[id].tsx
@@ -69,7 +69,6 @@ export const getServerSideProps: GetServerSideProps = async ({
}
}
-
return {
props: {
post: json,
diff --git a/client/pages/settings.tsx b/client/pages/settings.tsx
index ce40051e..9f2a2cb0 100644
--- a/client/pages/settings.tsx
+++ b/client/pages/settings.tsx
@@ -1,15 +1,27 @@
-import { Button, Divider, Text, Fieldset, Input, Page, Note, Textarea } from "@geist-ui/core"
+import {
+ Button,
+ Divider,
+ Text,
+ Fieldset,
+ Input,
+ Page,
+ Note,
+ Textarea
+} from "@geist-ui/core"
import PageSeo from "@components/page-seo"
import styles from "@styles/Home.module.css"
import SettingsPage from "@components/settings"
const Settings = () => (
-
-
-
-
-
-
+
+
+
+
+
+
)
export default Settings
diff --git a/server/src/migrations/09_add_more_user_settings.ts b/server/src/migrations/09_add_more_user_settings.ts
index 4624306e..9547530a 100644
--- a/server/src/migrations/09_add_more_user_settings.ts
+++ b/server/src/migrations/09_add_more_user_settings.ts
@@ -3,24 +3,24 @@ import { DataTypes } from "sequelize"
import type { Migration } from "../database"
export const up: Migration = async ({ context: queryInterface }) =>
- Promise.all([
- queryInterface.addColumn("users", "email", {
- type: DataTypes.STRING,
- allowNull: true
- }),
- queryInterface.addColumn("users", "displayName", {
- type: DataTypes.STRING,
- allowNull: true,
- }),
- queryInterface.addColumn("users", "bio", {
- type: DataTypes.STRING,
- allowNull: true,
- }),
- ])
+ Promise.all([
+ queryInterface.addColumn("users", "email", {
+ type: DataTypes.STRING,
+ allowNull: true
+ }),
+ queryInterface.addColumn("users", "displayName", {
+ type: DataTypes.STRING,
+ allowNull: true
+ }),
+ queryInterface.addColumn("users", "bio", {
+ type: DataTypes.STRING,
+ allowNull: true
+ })
+ ])
export const down: Migration = async ({ context: queryInterface }) =>
- Promise.all([
- queryInterface.removeColumn("users", "email"),
- queryInterface.removeColumn("users", "displayName"),
- queryInterface.removeColumn("users", "bio"),
- ])
+ Promise.all([
+ queryInterface.removeColumn("users", "email"),
+ queryInterface.removeColumn("users", "displayName"),
+ queryInterface.removeColumn("users", "bio")
+ ])
diff --git a/server/src/routes/auth.ts b/server/src/routes/auth.ts
index 742adcd2..ca763598 100644
--- a/server/src/routes/auth.ts
+++ b/server/src/routes/auth.ts
@@ -195,7 +195,8 @@ auth.post("/signout", secretKey, async (req, res, next) => {
}
})
-auth.put("/change-password",
+auth.put(
+ "/change-password",
jwt,
celebrate({
body: {
diff --git a/server/src/routes/user.ts b/server/src/routes/user.ts
index e4226a5f..46368d40 100644
--- a/server/src/routes/user.ts
+++ b/server/src/routes/user.ts
@@ -30,13 +30,14 @@ user.get("/self", jwt, async (req: UserJwtRequest, res, next) => {
}
})
-user.put("/profile",
+user.put(
+ "/profile",
jwt,
celebrate({
body: {
displayName: Joi.string().optional().allow(""),
bio: Joi.string().optional().allow(""),
- email: Joi.string().optional().email().allow(""),
+ email: Joi.string().optional().email().allow("")
}
}),
async (req: UserJwtRequest, res, next) => {