Skip to content
Open
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
6 changes: 3 additions & 3 deletions src/components/app/profile/personal-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,14 @@ export function PersonalDdetail() {
<div className="w-full justify-start items-start gap-4 mt-4 cursor-pointer" onClick={updateCivilIdFrontClicked}>
<div className="text-[#22223d] text-lg font-semibold mb-4 leading-7">{t('ID Photo Front')}</div>
<div className="min-h-[161px] bg-white rounded-2xl">
{ user.candidate_civil_photo_back && <img src={ import.meta.env.VITE_PERMANENT_BUCKET_URL + 'photos/' + user.candidate_civil_photo_back }
{ user.candidate_civil_photo_front && <img src={ import.meta.env.VITE_PERMANENT_BUCKET_URL + 'photos/' + user.candidate_civil_photo_front }
className="w-full h-full object-cover rounded-2xl" /> }
</div>
</div>
<div className="w-full justify-start items-start gap-4 mt-4 cursor-pointer" onClick={updateCivilIdBackClicked}>
<div className="text-[#22223d] text-lg font-semibold leading-7 mb-4">{t('ID Photo Back')}</div>
<div className="min-h-[161px] bg-white rounded-2xl">
{ user.candidate_civil_photo_front && <img src={ import.meta.env.VITE_PERMANENT_BUCKET_URL + 'photos/' + user.candidate_civil_photo_front }
{ user.candidate_civil_photo_back && <img src={ import.meta.env.VITE_PERMANENT_BUCKET_URL + 'photos/' + user.candidate_civil_photo_back }
className="w-full h-full object-cover rounded-2xl" /> }
</div>
</div>
Expand All @@ -348,4 +348,4 @@ export function PersonalDdetail() {
</div>
</div>
);
}
}
39 changes: 36 additions & 3 deletions src/pages/(auth)/civil-id/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,15 @@ export default function CivilIdPage() {

setRemovingFrontId(true);

removeCivilPhotoFront().then(() => {
removeCivilPhotoFront().then((res: any) => {
if (res?.operation && res.operation !== 'success') {
alertDialog({
title: t("Error"),
description: errorMessage(res.message),
});
return;
}

form.setValue('candidate_civil_photo_front', '');
form.trigger('candidate_civil_photo_front');
form.setValue('candidate_civil_photo_front_url', '');
Expand All @@ -193,16 +201,29 @@ export default function CivilIdPage() {
candidate_civil_photo_front: null
} }));

}).catch(() => {
alertDialog({
title: t("Error"),
description: errorMessage(t("Civil ID photo could not be removed. Please try again.")),
});
}).finally(() => {
setRemovingFrontId(false);
});
}

function resetBackId() {

setRemovingBackId(true);

removeCivilPhotoBack().then(() => {
removeCivilPhotoBack().then((res: any) => {
if (res?.operation && res.operation !== 'success') {
alertDialog({
title: t("Error"),
description: errorMessage(res.message),
});
return;
}

form.setValue('candidate_civil_photo_back', '');
form.trigger('candidate_civil_photo_back');
form.setValue('candidate_civil_photo_back_url', '');
Expand All @@ -213,6 +234,11 @@ export default function CivilIdPage() {
candidate_civil_photo_back: null
} }));

}).catch(() => {
alertDialog({
title: t("Error"),
description: errorMessage(t("Civil ID photo could not be removed. Please try again.")),
});
}).finally(() => {
setRemovingBackId(false);
});
Expand Down Expand Up @@ -277,6 +303,13 @@ export default function CivilIdPage() {
text-[40px] font-bold leading-[56px] mt-[102px] mb-[38px]">
{t('Civil ID Information')}
</h5>
{ query.get('fromProfile') && (
<div className="max-w-[650px] m-auto mb-[24px]">
<Button variant="ghost" type="button" onClick={() => router.push('/profile')}>
{t('Back to Profile')}
</Button>
</div>
) }
{ /**block-inline max-w-[313px] xs:max-w-full xs:w-full */}

<div suppressHydrationWarning={true} className="flex flex-col sm:flex-row max-w-[640px] min-h-[196px] m-auto mb-[24px]">
Expand Down
15 changes: 9 additions & 6 deletions src/providers/AxiosService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,29 @@ export async function handleAxiosError(err: any) {
console.log("axios error:", err);

const response = err.response;
const localErrorHandler = Boolean(err.config?.localErrorHandler);
//const errMsg = response.status ? `${response.status} - ${response.statusText}` : 'Server error';

if (!response) {
internetOffline$.next({});
if (!localErrorHandler) {
internetOffline$.next({});
}
return Promise.reject(err);
}

// Handle Bad Requests
if (response.status === 400) {
if (response.status === 400 && !localErrorHandler) {
error404$.next({});
// Router.push('/404');
}

// Handle No Internet Connection Error
if (response.status == 0 || response.status == 504) {
if ((response.status == 0 || response.status == 504) && !localErrorHandler) {
internetOffline$.next({});
// Router.push('/no-internet');
}

if(!navigator.onLine) {
if(!navigator.onLine && !localErrorHandler) {
internetOffline$.next({});
// Router.push('/no-internet');
}
Expand All @@ -81,14 +84,14 @@ export async function handleAxiosError(err: any) {
}

// Handle internal server error - 500
if (response.status === 500) {
if (response.status === 500 && !localErrorHandler) {
console.error(JSON.stringify(response));
error500$.next({});
// Router.push('/500');
}

// Handle page not found - 404 error
if (response.status === 404) {
if (response.status === 404 && !localErrorHandler) {
error404$.next({});
// Router.push('/404');
}
Expand Down
6 changes: 3 additions & 3 deletions src/providers/logged-in/account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export async function updateSkills(params: any): Promise<any> {
*/
export async function removeCivilPhotoFront(): Promise<any> {
const url = `${_accountEndpoint}` + '/remove-civil-photo-front';
const response = await axios.delete(url);
const response = await axios.delete(url, { localErrorHandler: true } as any);
return response.data;
}

Expand All @@ -89,7 +89,7 @@ export async function removeCivilPhotoFront(): Promise<any> {
*/
export async function removeCivilPhotoBack(): Promise<any> {
const url = `${_accountEndpoint}` + '/remove-civil-photo-back';
const response = await axios.delete(url);
const response = await axios.delete(url, { localErrorHandler: true } as any);
return response.data;
}

Expand Down Expand Up @@ -605,4 +605,4 @@ export function getNextRouteToCompleteProfile(user: Candidate | null) {
} /*else {
return 'profile';
}*/
}
}