Track cleanup progress and polish profile/system flows
This commit is contained in:
@@ -27,7 +27,7 @@ import AutoAwesomeIcon from "@mui/icons-material/AutoAwesome";
|
||||
import MailOutlineIcon from "@mui/icons-material/MailOutline";
|
||||
import { IconButton } from "@mui/material";
|
||||
|
||||
import { api } from "../api";
|
||||
import { api, getApiErrorMessage } from "../api";
|
||||
import { useToast } from "../toast";
|
||||
import { CorrespondenceMessage, GmailMessageSummary, GmailStatus } from "../types";
|
||||
import { useDialogActions } from "../dialogs";
|
||||
@@ -126,8 +126,7 @@ export default function Correspondence({ jobId }: { jobId: number }) {
|
||||
});
|
||||
setGmailMessages(res.data);
|
||||
} catch (error: any) {
|
||||
const message = error?.response?.data && typeof error.response.data === "string" ? error.response.data : "Failed to load Gmail messages.";
|
||||
toast(message, "error");
|
||||
toast(getApiErrorMessage(error, "Failed to load Gmail messages."), "error");
|
||||
} finally {
|
||||
setGmailMessagesLoading(false);
|
||||
}
|
||||
@@ -206,8 +205,8 @@ export default function Correspondence({ jobId }: { jobId: number }) {
|
||||
await api.post("/correspondence", { jobApplicationId: jobId, from, content: text });
|
||||
setText("");
|
||||
await load();
|
||||
} catch {
|
||||
toast("Failed to add message.", "error");
|
||||
} catch (error) {
|
||||
toast(getApiErrorMessage(error, "Failed to add message."), "error");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -231,8 +230,8 @@ export default function Correspondence({ jobId }: { jobId: number }) {
|
||||
setRawEmail("");
|
||||
await load();
|
||||
toast("Email logged.", "success");
|
||||
} catch {
|
||||
toast("Failed to import email.", "error");
|
||||
} catch (error) {
|
||||
toast(getApiErrorMessage(error, "Failed to import email."), "error");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -241,8 +240,8 @@ export default function Correspondence({ jobId }: { jobId: number }) {
|
||||
const res = await api.get<{ url: string }>("/gmail/connect-url");
|
||||
const popup = window.open(res.data.url, "jobtracker-gmail-connect", "width=620,height=760,resizable=yes,scrollbars=yes");
|
||||
if (!popup) toast("Your browser blocked the Gmail popup.", "error");
|
||||
} catch {
|
||||
toast("Failed to start Gmail connection.", "error");
|
||||
} catch (error) {
|
||||
toast(getApiErrorMessage(error, "Failed to start Gmail connection."), "error");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -252,8 +251,8 @@ export default function Correspondence({ jobId }: { jobId: number }) {
|
||||
setGmailStatus({ connected: false });
|
||||
setGmailMessages([]);
|
||||
toast("Gmail disconnected.", "success");
|
||||
} catch {
|
||||
toast("Failed to disconnect Gmail.", "error");
|
||||
} catch (error) {
|
||||
toast(getApiErrorMessage(error, "Failed to disconnect Gmail."), "error");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -263,8 +262,8 @@ export default function Correspondence({ jobId }: { jobId: number }) {
|
||||
await api.delete(`/correspondence/${messageId}`);
|
||||
await load();
|
||||
toast("Message removed.", "success");
|
||||
} catch {
|
||||
toast("Failed to remove message.", "error");
|
||||
} catch (error) {
|
||||
toast(getApiErrorMessage(error, "Failed to remove message."), "error");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -275,8 +274,7 @@ export default function Correspondence({ jobId }: { jobId: number }) {
|
||||
await load();
|
||||
toast("Email imported from Gmail.", "success");
|
||||
} catch (error: any) {
|
||||
const message = error?.response?.data && typeof error.response.data === "string" ? error.response.data : "Failed to import Gmail message.";
|
||||
toast(message, "error");
|
||||
toast(getApiErrorMessage(error, "Failed to import Gmail message."), "error");
|
||||
} finally {
|
||||
setImportingMessageId(null);
|
||||
}
|
||||
@@ -289,8 +287,7 @@ export default function Correspondence({ jobId }: { jobId: number }) {
|
||||
await load();
|
||||
toast(`Imported ${res.data.imported} messages${res.data.skipped ? `, skipped ${res.data.skipped} duplicates` : ""}.`, "success");
|
||||
} catch (error: any) {
|
||||
const message = error?.response?.data && typeof error.response.data === "string" ? error.response.data : "Failed to import Gmail thread.";
|
||||
toast(message, "error");
|
||||
toast(getApiErrorMessage(error, "Failed to import Gmail thread."), "error");
|
||||
} finally {
|
||||
setImportingThreadId(null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user