-
-
-
{props.user.name}
-
- {props.eventType.title}
-
-
-
- {props.eventType.length} minutes
-
- {selectedLocation === LocationType.InPerson && (
+
+
+
+
+
+
{props.user.name}
+
+ {props.eventType.title}
+
-
- {locationInfo(selectedLocation).address}
+
+ {props.eventType.length} minutes
- )}
-
-
- {preferredTimeZone &&
- dayjs(date)
- .tz(preferredTimeZone)
- .format((is24h ? "H:mm" : "h:mma") + ", dddd DD MMMM YYYY")}
-
-
{props.eventType.description}
-
-
+
+
- {error && (
-
-
-
-
-
-
- )}
+ {locations.length > 1 && (
+
+ Location
+ {locations.map((location) => (
+
+ ))}
+
+ )}
+ {selectedLocation === LocationType.Phone && (
+
+
+
+
{
+ /* DO NOT REMOVE: Callback required by PhoneInput, comment added to satisfy eslint:no-empty-function */
+ }}
+ />
+
+
+ )}
+ {props.eventType.customInputs &&
+ props.eventType.customInputs
+ .sort((a, b) => a.id - b.id)
+ .map((input) => (
+
+ ))}
+
+
+
+
+
+
+
+
Cancel
+
+
+
+ {error && (
+
+ )}
+
-
-
-
+
+
+ )
);
}
export async function getServerSideProps(context) {
-
- const user = await whereAndSelect(prisma.user.findFirst, {
+ const user = await whereAndSelect(
+ prisma.user.findFirst,
+ {
username: context.query.user,
- }, [
- "username",
- "name",
- "email",
- "bio",
- "avatar",
- "eventTypes",
- "theme",
- ]
+ },
+ ["username", "name", "email", "bio", "avatar", "eventTypes", "theme"]
);
const eventType = await prisma.eventType.findUnique({
diff --git a/pages/api/user/profile.ts b/pages/api/user/profile.ts
index 0cfcab43d1..fbc13c7d14 100644
--- a/pages/api/user/profile.ts
+++ b/pages/api/user/profile.ts
@@ -1,23 +1,28 @@
-import type { NextApiRequest, NextApiResponse } from 'next';
-import { getSession } from 'next-auth/client';
-import prisma, {whereAndSelect} from '@lib/prisma';
+import type { NextApiRequest, NextApiResponse } from "next";
+import { getSession } from "next-auth/client";
+import prisma, { whereAndSelect } from "@lib/prisma";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
- const session = await getSession({req: req});
+ const session = await getSession({ req: req });
if (!session) {
- res.status(401).json({message: "Not authenticated"});
- return;
+ res.status(401).json({ message: "Not authenticated" });
+ return;
}
// Get user
- const user = await whereAndSelect(prisma.user.findUnique, {
+ const user = await whereAndSelect(
+ prisma.user.findUnique,
+ {
id: session.user.id,
},
- [ "id", "password" ]
+ ["id", "password"]
);
- if (!user) { res.status(404).json({message: 'User not found'}); return; }
+ if (!user) {
+ res.status(404).json({ message: "User not found" });
+ return;
+ }
const username = req.body.username;
// username is changed: username is optional but it is necessary to be unique, enforce here
@@ -25,10 +30,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const userConflict = await prisma.user.findFirst({
where: {
username,
- }
+ },
});
if (userConflict) {
- return res.status(409).json({ message: 'Username already taken' });
+ return res.status(409).json({ message: "Username already taken" });
}
}
@@ -40,7 +45,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const hideBranding = req.body.hideBranding;
const theme = req.body.theme;
- const updateUser = await prisma.user.update({
+ await prisma.user.update({
where: {
id: user.id,
},
@@ -56,5 +61,5 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
},
});
- return res.status(200).json({message: 'Profile updated successfully'});
+ return res.status(200).json({ message: "Profile updated successfully" });
}
diff --git a/pages/settings/profile.tsx b/pages/settings/profile.tsx
index e103b61cd5..6f7836ebfd 100644
--- a/pages/settings/profile.tsx
+++ b/pages/settings/profile.tsx
@@ -1,7 +1,7 @@
import { GetServerSideProps } from "next";
import Head from "next/head";
-import {useEffect, useRef, useState} from "react";
-import prisma, {whereAndSelect} from "@lib/prisma";
+import { useEffect, useRef, useState } from "react";
+import prisma, { whereAndSelect } from "@lib/prisma";
import Modal from "../../components/Modal";
import Shell from "../../components/Shell";
import SettingsShell from "../../components/Settings";
@@ -27,12 +27,14 @@ export default function Settings(props) {
const [errorMessage, setErrorMessage] = useState("");
const themeOptions = [
- {value: 'light', label: 'Light'},
- {value: 'dark', label: 'Dark'}
+ { value: "light", label: "Light" },
+ { value: "dark", label: "Dark" },
];
- useEffect( () => {
- setSelectedTheme(props.user.theme ? themeOptions.find( (theme) => theme.value === props.user.theme ) : null);
+ useEffect(() => {
+ setSelectedTheme(
+ props.user.theme ? themeOptions.find((theme) => theme.value === props.user.theme) : null
+ );
setSelectedWeekStartDay({ value: props.user.weekStart, label: props.user.weekStart });
}, []);
@@ -138,8 +140,7 @@ export default function Settings(props) {
placeholder="A little something about yourself."
rows={3}
defaultValue={props.user.bio}
- className="shadow-sm focus:ring-blue-500 focus:border-blue-500 mt-1 block w-full sm:text-sm border-gray-300 rounded-md">
-
+ className="shadow-sm focus:ring-blue-500 focus:border-blue-500 mt-1 block w-full sm:text-sm border-gray-300 rounded-md">