Skip to content

Commit a354be9

Browse files
committed
chore: comment all console log and error
1 parent 72f4c14 commit a354be9

File tree

10 files changed

+101
-106
lines changed

10 files changed

+101
-106
lines changed

src/components/SideMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const SideMenu: React.FC = () => {
3333

3434
history.replace('/login');
3535
} catch (err) {
36-
console.error(err);
36+
// console.error(err);
3737
}
3838
};
3939

src/contexts/auth/AuthProvider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }: AuthProv
3434
try {
3535
await registerUser(email, password, fullName, phoneNumber, address, gender, bio, photoUrl);
3636
} catch (err) {
37-
console.error(err);
37+
// console.error(err);
3838
throw new Error('Oops! Something went wrong.');
3939
}
4040
};
@@ -47,7 +47,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }: AuthProv
4747
throw new Error('email_not_verified');
4848
}
4949
} catch (err) {
50-
console.error(err);
50+
// console.error(err);
5151

5252
if (err instanceof Error) {
5353
throw new Error(err.message);
@@ -61,7 +61,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }: AuthProv
6161
try {
6262
await logoutUser();
6363
} catch (err) {
64-
console.error(err);
64+
// console.error(err);
6565
}
6666
};
6767

src/contexts/personalContact/PersonalContactProvider.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export const PersonalContactProvider: React.FC<PersonalContactProviderProps> = (
2727
if (!data) return;
2828

2929
setContacts(data);
30-
} catch (error) {
31-
console.log(error);
30+
} catch (err) {
31+
// console.error(err);
3232
}
3333
};
3434

@@ -42,8 +42,8 @@ export const PersonalContactProvider: React.FC<PersonalContactProviderProps> = (
4242
const updatedContacts = [...contacts, newContact];
4343

4444
setContacts(updatedContacts);
45-
} catch (error) {
46-
console.error(error);
45+
} catch (err) {
46+
// console.error(err);
4747
throw new Error('Failed to add new personal contact.');
4848
}
4949
};
@@ -53,8 +53,8 @@ export const PersonalContactProvider: React.FC<PersonalContactProviderProps> = (
5353
const updatedContacts = await editPersonalContact(currentUser, id, name, phoneNumber);
5454

5555
setContacts(updatedContacts);
56-
} catch (error) {
57-
console.error(error);
56+
} catch (err) {
57+
// console.error(err);
5858
throw new Error('Failed to edit personal contact.');
5959
}
6060
};
@@ -64,8 +64,8 @@ export const PersonalContactProvider: React.FC<PersonalContactProviderProps> = (
6464
const updatedContacts = await deletePersonalContact(currentUser, id);
6565

6666
setContacts(updatedContacts);
67-
} catch (error) {
68-
console.error(error);
67+
} catch (err) {
68+
// console.error(err);
6969
throw new Error('Failed to delete personal contact.');
7070
}
7171
};

src/contexts/userData/UserDataProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const UserDataProvider: React.FC<UserDataProviderProps> = ({
4040

4141
setUserData(data);
4242
} catch (err) {
43-
console.log(err);
43+
// console.error(err);
4444
throw new Error('Oops! Something went wrong.');
4545
}
4646
};
@@ -58,7 +58,7 @@ export const UserDataProvider: React.FC<UserDataProviderProps> = ({
5858

5959
setStartFetchData(true);
6060
} catch (err) {
61-
console.error(err);
61+
// console.error(err);
6262
throw new Error('Oops! Something went wrong.');
6363
}
6464

src/pages/auth/Login.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ const Login: React.FC = () => {
133133
color: 'danger'
134134
});
135135

136-
console.error(err);
136+
// console.error(err);
137137
}
138138

139139
dismissLoading();

src/pages/auth/Register.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const Register: React.FC = () => {
146146
});
147147

148148
history.replace('/login');
149-
} catch (error) {
149+
} catch (err) {
150150
presentToast({
151151
message: 'Gagal membuat akun.',
152152
duration: 2000,

src/pages/main/profile/EditProfile.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ const EditProfile: React.FC = () => {
4848
}
4949

5050
setPhoto(photo.webPath);
51-
} catch (error) {
52-
console.error(error);
51+
} catch (err) {
52+
// console.error(err);
5353
setPhoto('');
5454
}
5555
};
@@ -83,7 +83,7 @@ const EditProfile: React.FC = () => {
8383

8484
history.replace('/main/profile');
8585
} catch (err) {
86-
console.error(err);
86+
// console.error(err);
8787
presentToast({
8888
message: 'Profil gagal diubah.',
8989
duration: 2000,

src/pages/main/profile/Profile.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const Profile: React.FC = () => {
1414
const history = useHistory();
1515

1616
const handleLogout = async () => {
17-
console.log('start');
1817
try {
1918
await logout();
2019

@@ -26,7 +25,7 @@ const Profile: React.FC = () => {
2625

2726
history.replace('/login');
2827
} catch (err) {
29-
console.error(err);
28+
// console.error(err);
3029
}
3130
};
3231

src/serviceWorkerRegistration.ts

Lines changed: 64 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ export function register(config?: Config) {
4444
// Add some additional logging to localhost, pointing developers to the
4545
// service worker/PWA documentation.
4646
navigator.serviceWorker.ready.then(() => {
47-
console.log(
48-
'This web app is being served cache-first by a service ' +
49-
'worker. To learn more, visit https://cra.link/PWA'
50-
);
47+
// console.log(
48+
// 'This web app is being served cache-first by a service ' +
49+
// 'worker. To learn more, visit https://cra.link/PWA'
50+
// );
5151
});
5252
} else {
5353
// Is not localhost. Just register service worker
@@ -58,85 +58,81 @@ export function register(config?: Config) {
5858
}
5959

6060
function registerValidSW(swUrl: string, config?: Config) {
61-
navigator.serviceWorker
62-
.register(swUrl)
63-
.then((registration) => {
64-
registration.onupdatefound = () => {
65-
const installingWorker = registration.installing;
66-
if (installingWorker == null) {
67-
return;
68-
}
69-
installingWorker.onstatechange = () => {
70-
if (installingWorker.state === 'installed') {
71-
if (navigator.serviceWorker.controller) {
72-
// At this point, the updated precached content has been fetched,
73-
// but the previous service worker will still serve the older
74-
// content until all client tabs are closed.
75-
console.log(
76-
'New content is available and will be used when all ' +
77-
'tabs for this page are closed. See https://cra.link/PWA.'
78-
);
61+
navigator.serviceWorker.register(swUrl).then((registration) => {
62+
registration.onupdatefound = () => {
63+
const installingWorker = registration.installing;
64+
if (installingWorker == null) {
65+
return;
66+
}
67+
installingWorker.onstatechange = () => {
68+
if (installingWorker.state === 'installed') {
69+
if (navigator.serviceWorker.controller) {
70+
// At this point, the updated precached content has been fetched,
71+
// but the previous service worker will still serve the older
72+
// content until all client tabs are closed.
73+
// console.log(
74+
// 'New content is available and will be used when all ' +
75+
// 'tabs for this page are closed. See https://cra.link/PWA.'
76+
// );
7977

80-
// Execute callback
81-
if (config && config.onUpdate) {
82-
config.onUpdate(registration);
83-
}
84-
} else {
85-
// At this point, everything has been precached.
86-
// It's the perfect time to display a
87-
// "Content is cached for offline use." message.
88-
console.log('Content is cached for offline use.');
78+
// Execute callback
79+
if (config && config.onUpdate) {
80+
config.onUpdate(registration);
81+
}
82+
} else {
83+
// At this point, everything has been precached.
84+
// It's the perfect time to display a
85+
// "Content is cached for offline use." message.
86+
// console.log('Content is cached for offline use.');
8987

90-
// Execute callback
91-
if (config && config.onSuccess) {
92-
config.onSuccess(registration);
93-
}
88+
// Execute callback
89+
if (config && config.onSuccess) {
90+
config.onSuccess(registration);
9491
}
9592
}
96-
};
93+
}
9794
};
98-
})
99-
.catch((error) => {
100-
console.error('Error during service worker registration:', error);
101-
});
95+
};
96+
});
97+
// .catch((error) => {
98+
// console.error('Error during service worker registration:', error);
99+
// });
102100
}
103101

104102
function checkValidServiceWorker(swUrl: string, config?: Config) {
105103
// Check if the service worker can be found. If it can't reload the page.
106104
fetch(swUrl, {
107105
headers: { 'Service-Worker': 'script' }
108-
})
109-
.then((response) => {
110-
// Ensure service worker exists, and that we really are getting a JS file.
111-
const contentType = response.headers.get('content-type');
112-
if (
113-
response.status === 404 ||
114-
(contentType != null && contentType.indexOf('javascript') === -1)
115-
) {
116-
// No service worker found. Probably a different app. Reload the page.
117-
navigator.serviceWorker.ready.then((registration) => {
118-
registration.unregister().then(() => {
119-
window.location.reload();
120-
});
106+
}).then((response) => {
107+
// Ensure service worker exists, and that we really are getting a JS file.
108+
const contentType = response.headers.get('content-type');
109+
if (
110+
response.status === 404 ||
111+
(contentType != null && contentType.indexOf('javascript') === -1)
112+
) {
113+
// No service worker found. Probably a different app. Reload the page.
114+
navigator.serviceWorker.ready.then((registration) => {
115+
registration.unregister().then(() => {
116+
window.location.reload();
121117
});
122-
} else {
123-
// Service worker found. Proceed as normal.
124-
registerValidSW(swUrl, config);
125-
}
126-
})
127-
.catch(() => {
128-
console.log('No internet connection found. App is running in offline mode.');
129-
});
118+
});
119+
} else {
120+
// Service worker found. Proceed as normal.
121+
registerValidSW(swUrl, config);
122+
}
123+
});
124+
// .catch(() => {
125+
// console.log('No internet connection found. App is running in offline mode.');
126+
// });
130127
}
131128

132129
export function unregister() {
133130
if ('serviceWorker' in navigator) {
134-
navigator.serviceWorker.ready
135-
.then((registration) => {
136-
registration.unregister();
137-
})
138-
.catch((error) => {
139-
console.error(error.message);
140-
});
131+
navigator.serviceWorker.ready.then((registration) => {
132+
registration.unregister();
133+
});
134+
// .catch((error) => {
135+
// console.error(error.message);
136+
// });
141137
}
142138
}

0 commit comments

Comments
 (0)