Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCRUM-1 Fixes #88

Merged
merged 6 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/Sidebar/SidebarContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ const renderUserCard = (
export const SidebarContent = (props: SidebarContentProps) => {
return (
<div id="scrollableDiv" className="overflow-auto">
{props.userCardList.length === 0 || props.disabled ? (
{props.userCardList.length === 0 ||
(props.disabled && props.subType !== "favorites") ? (
<div className="m-4 text-center text-lg font-light">
{emptyMessage(props.subType, props.disabled)}
</div>
Expand Down
4 changes: 1 addition & 3 deletions src/components/UserCards/UserCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ export const UserCard = (props: UserCardProps): JSX.Element => {
{user.role === "VIEWER" ? (
<p className="font-semibold">{`${props.otherUser.role.charAt(
0
)}${props.otherUser.role.slice(1).toLowerCase()} ${
props.otherUser.id
}`}</p>
)}${props.otherUser.role.slice(1).toLowerCase()}`}</p>
) : (
<p className="font-semibold">{props.otherUser.preferredName}</p>
)}
Expand Down
13 changes: 4 additions & 9 deletions src/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { serverEnv } from "../../../utils/env/server";
import AzureADProvider from "next-auth/providers/azure-ad";
import GoogleProvider from "next-auth/providers/google";
import { Adapter } from "next-auth/adapters";
import { browserEnv } from "../../../utils/env/browser";

const CustomPrismaAdapter = (p: typeof prisma): Adapter => {
return {
Expand Down Expand Up @@ -50,14 +49,10 @@ export const authOptions: NextAuthOptions = {
},
adapter: CustomPrismaAdapter(prisma),
providers: [
...(browserEnv.NEXT_PUBLIC_ENV === "staging"
? [
GoogleProvider({
clientId: serverEnv.GOOGLE_CLIENT_ID,
clientSecret: serverEnv.GOOGLE_CLIENT_SECRET,
}),
]
: []),
GoogleProvider({
clientId: serverEnv.GOOGLE_CLIENT_ID,
clientSecret: serverEnv.GOOGLE_CLIENT_SECRET,
}),
AzureADProvider({
clientId: serverEnv.AZURE_CLIENT_ID,
clientSecret: serverEnv.AZURE_CLIENT_SECRET,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ const Home: NextPage<any> = () => {
newMap.setMaxZoom(13);
newMap.on("load", () => {
addClusters(newMap, geoJsonUsers);
updateUserLocation(newMap, user.startCoordLng, user.startCoordLat);
if (!isViewer) {
updateUserLocation(newMap, user.startCoordLng, user.startCoordLat);
updateCompanyLocation(
newMap,
user.companyCoordLng,
Expand Down
8 changes: 5 additions & 3 deletions src/server/router/mapbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export const mapboxRouter = router({
// Now returns all drivers and riders if user is in viewer mode
const oppRole =
currentUser?.role === Role.DRIVER ? Role.RIDER : Role.DRIVER;
const viewCheck = currentUser?.role === Role.VIEWER ? Role.RIDER : oppRole;
const isViewer = currentUser?.role === Role.VIEWER;
const viewCheck = isViewer ? Role.RIDER : oppRole;
const users = await ctx.prisma.user.findMany({
where: {
id: {
Expand Down Expand Up @@ -96,10 +97,11 @@ export const mapboxRouter = router({
distances.sort((a, b) => a.score - b.score);
const sortedUsers = _.compact(
distances.map((rec) => users.find((user) => user.id === rec.id))
).slice(0, 50);
);
const finalUsers = isViewer ? sortedUsers : sortedUsers.slice(0, 50);

// creates points for each user with coordinates at company location
const features: Feature[] = sortedUsers.map((u) => {
const features: Feature[] = finalUsers.map((u) => {
const feat = {
type: "Feature" as "Feature",
geometry: {
Expand Down
3 changes: 0 additions & 3 deletions src/utils/env/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@ export const browserEnv = envsafe({
NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN: str({
input: process.env.NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN,
}),
NEXT_PUBLIC_ENV: str({
input: process.env.NEXT_PUBLIC_ENV,
}),
});
Loading