Path: blob/master/src/packages/frontend/account/table-error.tsx
1503 views
/*1Show an error if something goes wrong trying to save2the account settings table to the database.3*/45import ShowError from "@cocalc/frontend/components/error";6import { redux, useTypedRedux } from "@cocalc/frontend/app-framework";78export default function AccountTableError() {9const tableError = useTypedRedux("account", "tableError");10if (!tableError) return null;1112const { error, query } = tableError.toJS();1314let obj;15try {16// this should work.17obj = query[0]["accounts"];18delete query["account_id"];19} catch (_err) {20obj = query;21}2223let description;24if (obj?.["name"] != null) {25// Issue trying to set the username.26description =27"Please try a different username. Names can be between 1 and 39 characters, contain upper and lower case letters, numbers, and dashes.";28} else {29description = `30There was an error trying to save an account setting to the server. In31particular, the following change failed:3233\`\`\`js34${JSON.stringify(obj, undefined, 2)}35\`\`\`36`;37}3839return (40<div style={{ width: "100%" }}>41<ShowError42error={`${error}\n\n${description}`}43setError={() =>44redux.getActions("account").setState({ tableError: undefined })45}46style={{ margin: "15px auto", maxWidth: "900px" }}47/>48</div>49);50}515253