Skip to content
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
86 changes: 86 additions & 0 deletions src/assets/app-errors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"APPERR_0001": {
"title": "Profile creation failed",
"message": "Failed to create your profile, please try again"
},
"APPERR_0002": {
"title": "Profile update failed",
"message": "Could not update profile information, please try again"
},
"APPERR_0003": {
"title": "Sign-in failed",
"message": "Something went wrong when signing you in, please try again"
},
"APPERR_0004": {
"title": "Sign in failed",
"message": "Something went wrong while verifying your email, please try again"
},
"APPERR_0005": {
"title": "Couldn't sign you out",
"message": "Something went wrong, please try again"
},
"APPERR_0006": {
"title": "Couldn't delete your account",
"message": "Something went wrong, please try again"
},
"APPERR_0007": {
"title": "Email registration failed",
"message": "Could not request for email registration, please try again"
},
"APPERR_0008": {
"title": "Profile image update failed",
"message": "Failed to update profile image"
},
"APPERR_0009": {
"title": "Process failed",
"message": "Failed to process profile image"
},
"APPERR_0010": {
"title": "User search failed",
"message": "Something went wrong while searching users, please try again"
},
"APPERR_0011": {
"title": "Something went wrong",
"message": "Could not get workspaces"
},
"APPERR_0012": {
"title": "Failed to update workspace",
"message": "Something went wrong when updating the workspace, please try again later."
},
"APPERR_0013": {
"title": "Failed to update invitation",
"message": "Something went wrong while responding to the invitation, please try again."
},
"APPERR_0014": {
"title": "Failed to create new workspace",
"message": "Something went wrong while creating new workspace, please try again later"
},
"APPERR_0015": {
"title": "Failed to delete workspace",
"message": "Something went wrong while deleting the workspace, please try again later."
},
"APPERR_0016": {
"title": "Failed to request access code",
"message": "Something went wrong while requesting the access code, please try again later."
},
"APPERR_0017": {
"title": "Failed to delete access code",
"message": "Something went wrong while deleting the access code, please try again later."
},
"APPERR_0018": {
"title": "Could not fetch latest notifications",
"message": "Something went wrong while getting your recent notifications"
},
"APPERR_0019": {
"title": "Could not load notifications",
"message": "Something went wrong while loading your notifications"
},
"APPERR_0020": {
"title": "Failed to open workspace",
"message": "Could not open workspace, please try again later"
},
"APPERR_0021": {
"title": "Could not connect to workspace",
"message": "Something went wrong while connecting to your workspace, please try again later"
}
}
6 changes: 6 additions & 0 deletions src/assets/app-success.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"APPSUCCESS_0001": {
"title": "Access request",
"message": "Request submitted successfully ! You'll get a notification with an access code soon."
}
}
164 changes: 164 additions & 0 deletions src/assets/server-errors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
{
"INVALID_AUTH_HEADER": {
"title": "Unauthorized access",
"message": "Action is not allowed"
},
"INVALID_TOKEN": {
"title": "Unauthorized access",
"message": "Action is not allowed"
},
"INVALID_EMAIL": {
"title": "Invalid email",
"message": "Provided email is invalid, please check and try again"
},
"EMAIL_REQUEST_CODE_MAX_ATTEMPTS_REACHED": {
"title": "Max attempts reached",
"message": "Cannot request email verification pin, please try again in 15 minutes."
},
"EMAIL_VERIFY_CODE_MAX_ATTEMPTS_REACHED": {
"title": "Max attempts reached",
"message": "Too many wrong attempts, please try again in 15 minutes."
},
"PIN_EXPIRED": {
"title": "Invalid pin",
"message": "Provided pin is invalid, please try again.",
"validationErr": "Invalid pin"
},
"EMAIL_VERIFY_CODE_WRONG": {
"title": "Wrong verification pin",
"message": "Provided pin for email verification is wrong, please try again.",
"validationErr": "Wrong pin"
},
"QUOTA_EXCEEDED": {
"title": "Quota exceeded",
"message": "Not allowed to perform more actions"
},
"TOKEN_EXPIRED": {
"title": "Invalid sign-in",
"message": "Please sign-in again"
},
"TOO_MANY_ATTEMPTS_TRY_LATER": {
"title": "Max attempts reached",
"message": "Too many attempts, please try again later"
},
"UNVERIFIED_EMAIL": {
"title": "Unverified email",
"message": "Provided email is unverified"
},
"USER_DETAILS_MISSING": {
"title": "Registration details missing",
"message": "Please provide all details"
},
"INVALID_USER_NAME": {
"title": "Invalid name",
"message": "Please provide a valid name"
},
"INVALID_USER_USERNAME": {
"title": "Invalid username",
"message": "Please provide a valid username"
},
"USER_ALREADY_REGISTERED": {
"title": "Already registered",
"message": "Provided user is already registered"
},
"INVALID_USER_IDENTITY": {
"title": "Invalid user identity",
"message": "User identity mismatch, please try again"
},
"UPDATE_USER_FORBIDDEN": {
"title": "Not allowed",
"message": "Profile update not allowed for some fields"
},
"USER_NOT_FOUND": {
"title": "Not found",
"message": "User not found"
},
"UNKNOWN": {
"title": "Something went wrong",
"message": "Something went wrong, please try again"
},
"NEED_CONFIRMATION": {
"title": "Account already exists",
"message": "Account already exists with the same email"
},
"WORKSPACE_PROVISION_INVALID_REQUEST": {
"title": "Invalid request",
"message": "Your request for provisioning a workspace was invalid"
},
"WORKSPACE_PROVISION_QUOTA_REACHED": {
"title": "Quota exceeded",
"message": "Workspace provisioning quota reached, not allowed to provision more workspaces"
},
"NO_WORKSPACE_MEMBERSHIP": {
"title": "Not a member",
"message": "You are not a member of this workspace"
},
"ACCESS_CODE_USE_FAILED": {
"title": "Access code usage failed",
"message": "Failed to use provided access code, please try again later"
},
"NO_CAPACITY": {
"title": "Capacity exhausted",
"message": "Your request cannot be processed at the moment, please try again later"
},
"WORKSPACE_PROVISION_FAILED": {
"title": "Workspace provision failed",
"message": "Failed to provision a new workspace, please try again later"
},
"WORKSPACE_RESTORE_FAILED": {
"title": "Workspace restore failed",
"message": "Failed to restore the workspace, please try again later"
},
"WORKSPACE_BOOT_FAILED": {
"title": "Workspace start failed",
"message": "Failed to start your workspace, please try again later"
},
"WORKSPACE_DELETE_INVALID_REQUEST": {
"title": "Invalid request",
"message": "Your request to delete a workspace was invalid"
},
"WORKSPACE_NOT_FOUND": {
"title": "Workspace not found",
"message": "Requested workspace not found"
},
"WORKSPACE_ACTION_NOT_AUTHORIZED": {
"title": "Insufficient privileges",
"message": "Not allowed to perform provided action on this workspace due to insufficient privileges"
},
"ACCESS_CODE_LIMIT": {
"title": "Quota exceeded",
"message": "Cannot request more access codes since you already have a pending request"
},
"WORKSPACE_OPEN_INVALID_REQUEST": {
"title": "Invalid request",
"message": "Your request to open a workspace was invalid"
},
"WORKSPACE_OPEN_FAILED": {
"title": "Failed to open workspace",
"message": "Something went wrong while opening your workspace, please try again later"
},
"WORKSPACE_UNREACHABLE": {
"title": "Workspace unreachable",
"message": "Workspace is unreachable, please try again later"
},
"FS_ERR_FETCH_DIRECTORY": {
"title": "Failed to fetch directory",
"message": "Failed to fetch directory, please try again"
},
"FS_ERR_READ_FILE": {
"title": "Failed to read file",
"message": "Failed to read file, please try again"
},
"FS_ERR_FETCH_FILE": {
"title": "Failed to read file",
"message": "Failed to read file, please try again"
},
"FATAL_ERR_NO_WORKSPACE": {
"title": "Workspace disconnected",
"message": "Workspace was disconnected, please try again"
},
"FS_TIMEOUT": {
"title": "Workspace timed out",
"message": "Workspace did not respond in time, please try again later"
}
}
19 changes: 4 additions & 15 deletions src/components/AddMembers/AddMembers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useState } from "react";
import Search from "../common/Search/Search";
import classes from "./AddMembers.module.css";
import Spinner from "../common/Spinner/Spinner";
import { search } from "@/services/user";
import { User, UserSearchHits } from "@/models/user";
import { useAppDispatch } from "@/hooks/store";
import { notify } from "@/store/notifications";
Expand All @@ -15,6 +14,7 @@ import { getSSHKey } from "@/utils/driver";
import { auth } from "@/config/firebase";
import { InternalNotificationPayload } from "@/models/notification";
import classNames from "classnames";
import { searchUsers } from "@/store/typesense";

interface AddMembersProps {
workspace: WorkspaceDTO;
Expand All @@ -33,23 +33,12 @@ const AddMembers = ({ workspace, onBack }: AddMembersProps) => {
const handleSearch = async (query: string) => {
setHits(null);
setBusy(true);
try {
const res = await search(auth.currentUser!.uid, query, page);
const res = await dispatch(searchUsers({ uid: auth.currentUser!.uid, query, page })).unwrap();
if (res) {
setPage(res.page);
setBusy(false);
setHits(res.data);
} catch (error) {
console.log(error);
dispatch(
notify({
title: "Something went wrong, please try again",
message: "Cannot search users",
status: "error",
} as InternalNotificationPayload)
);
} finally {
setBusy(false);
}
setBusy(false);
};
const handleAdd = (user: User) => {
setAdded((prev) => {
Expand Down
19 changes: 5 additions & 14 deletions src/components/Profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,14 @@ const Profile = ({ profile, save, action }: ProfileProps) => {
URL.revokeObjectURL(oldUrl);
setAvatar(croppedAvatarImg.current);

try {
const picture = await dispatch(uploadAvatar({ data: croppedImage, uid: auth.currentUser!.uid })).unwrap();
if (action === "edit") {
await dispatch(updateProfile({ picture }));
}
} catch (error) {
console.log(error);
dispatch(
notify({
status: "error",
title: "Avatar update failed",
message: "Could not upload avatar image, please try again",
} as InternalNotificationPayload)
);
const picture = await dispatch(uploadAvatar({ data: croppedImage, uid: auth.currentUser!.uid })).unwrap();
if (!picture) {
setUploadBusy(false);
return;
}
if (action === "edit") {
await dispatch(updateProfile({ picture }));
}

setUploadBusy(false);
avatarModalRef.current?.close();
Expand Down
34 changes: 5 additions & 29 deletions src/components/auth/EmailProvider/EmailProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { useRef, useState } from "react";
import classes from "./EmailProvider.module.css";
import { useAppDispatch } from "@/hooks/store";
import { AuthType, signIn } from "@/store/auth";
import { AuthType, registerUserEmail, signIn } from "@/store/auth";
import Button from "@/components/common/Button/Button";
import { Input, InputRef } from "@/components/common/Input/Input";
import { emailPinRegex, emailRegex, errorMap } from "@/utils/constants";
import { registerEmail } from "@/services/auth";
import { notify } from "@/store/notifications";
import { InternalNotificationPayload } from "@/models/notification";
import { emailPinRegex, emailRegex } from "@/utils/constants";
import PINInput, { PINInputRef } from "@/components/common/PINInput/PINInput";
import classNames from "classnames";
import { isAxiosError } from "axios";

const EmailProvider = () => {
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -41,10 +37,6 @@ const EmailProvider = () => {
pinInput.current?.clear(true);
if (error.validationErr) {
pinInput.current?.invalidate(error.validationErr);
} else {
dispatch(
notify({ status: "error", title: error.title, message: error.message } as InternalNotificationPayload)
);
}
}
} else {
Expand All @@ -54,26 +46,10 @@ const EmailProvider = () => {
return;
}

try {
await registerEmail(email);
const success = await dispatch(registerUserEmail(email));
if (success) {
setpinRequested(true);
} catch (error) {
if (!isAxiosError(error) || !errorMap[error.response?.data.message]) {
console.log(error);
dispatch(
notify({
status: "error",
title: "Email registration failed",
message: "Could not request for email registration, please try again",
} as InternalNotificationPayload)
);
pinInput.current?.clear(true);
return;
}
const errMsg = errorMap[error.response?.data.message];
dispatch(
notify({ status: "error", title: errMsg.title, message: errMsg.message } as InternalNotificationPayload)
);
} else {
pinInput.current?.clear(true);
}
}
Expand Down
Loading
Loading