Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

fix: cyptic message when no password is set #183

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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@emotion/cache": "11.10.8",
"@emotion/react": "11.11.1",
"@emotion/styled": "11.11.0",
"@graasp/query-client": "1.4.0",
"@graasp/query-client": "1.4.1",
"@graasp/sdk": "1.2.0",
"@graasp/translations": "1.18.0",
"@graasp/ui": "3.3.0",
Expand Down Expand Up @@ -41,6 +41,7 @@
"build": "vite build",
"build:dev": "vite build --mode development",
"preview": "vite preview",
"preview:dev": "vite preview --mode development",
"lint": "eslint .",
"pre-commit": "yarn prettier:check && yarn lint",
"prettier:check": "prettier --check {src,cypress}/**/*.{js,ts,tsx}",
Expand Down
25 changes: 16 additions & 9 deletions src/config/notifier.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { AxiosError } from 'axios';
import { toast } from 'react-toastify';

import { routines } from '@graasp/query-client';
import { Notifier, routines } from '@graasp/query-client';
import { FAILURE_MESSAGES } from '@graasp/translations';

import { SHOW_NOTIFICATIONS } from './env';
import i18n from './i18n';
Expand All @@ -12,13 +14,18 @@ const {
signInWithPasswordRoutine,
} = routines;

const notifier = (args: {
type: string;
payload?: {
error?: Error;
message?: string;
};
}) => {
const getErrorMessage = (
error: Parameters<Notifier>[0]['payload']['error'],
) => {
if (error instanceof AxiosError) {
if (error.isAxiosError) {
return error.response.data.message ?? FAILURE_MESSAGES.UNEXPECTED_ERROR;
}
}
return FAILURE_MESSAGES.UNEXPECTED_ERROR;
};

const notifier: Notifier = (args) => {
const { type, payload } = args;

if (!SHOW_NOTIFICATIONS) {
Expand All @@ -32,7 +39,7 @@ const notifier = (args: {
case signUpRoutine.FAILURE:
case signInWithPasswordRoutine.FAILURE:
case getInvitationRoutine.FAILURE: {
message = payload?.error?.message ?? 'An unexpected error occured';
message = getErrorMessage(payload.error);
break;
}
case signInRoutine.SUCCESS:
Expand Down
7 changes: 5 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const config = ({ mode }: { mode: string }): UserConfigExport => {
ignored: ['**/coverage/**'],
},
},
preview: {
port: parseInt(process.env.VITE_PORT || '3001', 10),
},
build: {
outDir: 'build',
},
Expand All @@ -35,14 +38,14 @@ const config = ({ mode }: { mode: string }): UserConfigExport => {
requireEnv: false,
checkProd: true,
}),
...(mode === 'dev'
...(mode === 'development'
? [
visualizer({
template: 'treemap', // or sunburst
open: true,
gzipSize: true,
brotliSize: true,
filename: 'analice.html',
filename: 'bundle_analysis.html',
}) as PluginOption,
]
: []),
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3118,9 +3118,9 @@ __metadata:
languageName: node
linkType: hard

"@graasp/query-client@npm:1.4.0":
version: 1.4.0
resolution: "@graasp/query-client@npm:1.4.0"
"@graasp/query-client@npm:1.4.1":
version: 1.4.1
resolution: "@graasp/query-client@npm:1.4.1"
dependencies:
"@graasp/sdk": 1.2.0
"@graasp/translations": 1.18.1
Expand All @@ -3133,7 +3133,7 @@ __metadata:
uuid: 9.0.0
peerDependencies:
react: ^17.0.0
checksum: d5581682e607a3275c05ee351987afe490086c06ef078d50aa8c6e2b4662844f9ae722ec925f3aa9bd91c1a68da8b0dea1c6293d263fbed23939156dfe60f90f
checksum: 95d97d12d4d8fee4c06fbce468edd58909e35b63a05e34de4a5cf44d9f5f2246bfae296e97cbef04e72e46160b53059a757aac2118c9074e647f4781efc34705
languageName: node
linkType: hard

Expand Down Expand Up @@ -8608,7 +8608,7 @@ __metadata:
"@emotion/cache": 11.10.8
"@emotion/react": 11.11.1
"@emotion/styled": 11.11.0
"@graasp/query-client": 1.4.0
"@graasp/query-client": 1.4.1
"@graasp/sdk": 1.2.0
"@graasp/translations": 1.18.0
"@graasp/ui": 3.3.0
Expand Down