Skip to content

Commit

Permalink
messages remaining in various components
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizFNJ committed Jan 11, 2025
1 parent 4f0c69f commit 2100c2c
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 72 deletions.
20 changes: 10 additions & 10 deletions src/components/Claim/CreateClaim/ClaimSelectPersonality.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Card, CardActions, CardContent } from "@mui/material";
import { Col, message, Row } from "antd";
import { Grid, Card, CardActions, CardContent } from "@mui/material";
import global from "../../../components/Messages";
import { useAtom } from "jotai";
import { useTranslation } from "next-i18next";

Expand Down Expand Up @@ -34,7 +34,7 @@ const ClaimSelectPersonality = () => {

const addPersonality = (personality) => {
if (claimData.personalities.some((p) => p._id === personality._id)) {
message.info(t("claimForm:personalityAlreadyAdded"));
global.showMessage("info", t("claimForm:personalityAlreadyAdded"));
return;
}
send({
Expand All @@ -50,7 +50,7 @@ const ClaimSelectPersonality = () => {
const continueWithPersonality = () => {
if (claimData.personalities.length !== 0) {
send(CreateClaimEvents.savePersonality);
} else message.warning(t("claimForm:selectPersonalityText"));
} else global.showMessage("warning", t("claimForm:selectPersonalityText"));
};

const continueWithoutPersonality = () => {
Expand Down Expand Up @@ -107,11 +107,11 @@ const ClaimSelectPersonality = () => {
>
{t("claimForm:selectedPersonalities")}
</h3>
<Row>
<Grid container>
{personalities &&
personalities.length > 0 &&
personalities.map((personality) => (
<Col span={12} key={personality._id}>
<Grid item xs={12} sm={6} key={personality._id}>
<Card variant="elevation" style={{ margin: "8px" }}>
<CardContent
style={{
Expand All @@ -133,10 +133,10 @@ const ClaimSelectPersonality = () => {
</AletheiaButton>
</CardActions>
</Card>
</Col>
</Grid>
))}
</Row>
<Col
</Grid>
<Grid item
style={{
margin: "24px 0",
display: "flex",
Expand All @@ -160,7 +160,7 @@ const ClaimSelectPersonality = () => {
{t("claimForm:noPersonalityButton")}
</AletheiaButton>
)}
</Col>
</Grid>
</>
);
};
Expand Down
17 changes: 9 additions & 8 deletions src/components/ImageUpload.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable @next/next/no-img-element */
import { FileUploadOutlined } from "@mui/icons-material";
import { Col, message, Upload } from "antd";
import { Upload } from "antd";
import { Grid, Typography } from "@mui/material";
import global from "../components/Messages";
import { RcFile, UploadChangeParam, UploadProps } from "antd/lib/upload";
import { useTranslation } from "next-i18next";
import React, { useState } from "react";
Expand All @@ -9,7 +11,6 @@ import AletheiaButton from "./Button";
import { AletheiaModal } from "./Modal/AletheiaModal.style";

import type { UploadFile } from "antd/lib/upload/interface";
import Text from "antd/lib/typography/Text";

interface ImageUploadProps {
onChange: (fileList: UploadFile[]) => void;
Expand Down Expand Up @@ -64,15 +65,15 @@ const ImageUpload = ({
);

if (!isAllowedFormat) {
message.error(
global.showMessage("error",
t("claimForm:fileTypeError", {
types: ALLOWED_FORMATS.join("/"),
})
);
}
const isAllowedSize = file.size < MAX_SIZE;
if (!isAllowedSize) {
message.error(
global.showMessage("error",
t("claimForm:fileSizeError", { size: `${ALLOWED_MB}MB` })
);
}
Expand All @@ -96,7 +97,7 @@ const ImageUpload = ({
);

return (
<Col span={24}>
<Grid item xs={12}>
<Upload
listType="picture"
fileList={fileList}
Expand All @@ -108,9 +109,9 @@ const ImageUpload = ({
{fileList.length >= UPLOAD_LIMIT ? null : uploadButton}
</Upload>
{error && (
<Text type="danger" style={{ display: "block" }}>
<Typography variant="body2" color="error" style={{ display: "block" }}>
{t("common:requiredFieldError")}
</Text>
</Typography>
)}
<AletheiaModal
open={previewOpen}
Expand All @@ -126,7 +127,7 @@ const ImageUpload = ({
src={previewImage}
/>
</AletheiaModal>
</Col>
</Grid>
);
};

Expand Down
56 changes: 28 additions & 28 deletions src/components/Kanban/KanbanCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Avatar, Col, Row, Typography } from "antd";
import React from "react";

import CardBase from "../CardBase";
import UserTag from "./UserTag";
import claimApi from "../../api/claim";
Expand All @@ -9,15 +7,14 @@ import { useTranslation } from "next-i18next";
import actions from "../../store/actions";
import { useDispatch } from "react-redux";
import { ContentModelEnum } from "../../types/enums";
import PhotoOutlinedIcon from "@mui/icons-material/PhotoOutlined";
import ArticleOutlinedIcon from "@mui/icons-material/ArticleOutlined";
import { PhotoOutlined, ArticleOutlined } from "@mui/icons-material";
import { AvatarGroup, Grid, Typography } from "@mui/material";
import { useAtom } from "jotai";
import { currentNameSpace } from "../../atoms/namespace";
import SourceApi from "../../api/sourceApi";
import { ReviewTaskTypeEnum } from "../../machines/reviewTask/enums";
import verificationRequestApi from "../../api/verificationRequestApi";

const { Text, Paragraph } = Typography;
import colors from "../../styles/colors";

const KanbanCard = ({ reviewTask, reviewTaskType }) => {
const { t } = useTranslation();
Expand Down Expand Up @@ -72,48 +69,51 @@ const KanbanCard = ({ reviewTask, reviewTaskType }) => {
style={{
borderRadius: 4,
marginBottom: 0,
boxShadow: "0px 1px 1px rgba(0, 0, 0, 0.2)",
boxShadow: `0px 1px 1px ${colors.shadow}`,
}}
>
<Row style={{ width: "100%", padding: "10px" }}>
<Col
span={24}
style={{ display: "flex", flexDirection: "column" }}
<Grid container style={{ width: "100%", padding: "10px" }}>
<Grid item
xs={12}
style={{ display: "flex", flexDirection: "column", gap: 10}}
>
<Paragraph
ellipsis={{
rows: 2,
expandable: false,
}}
<Typography
variant="body1"
style={{
display: "-webkit-box",
WebkitBoxOrient: "vertical",
WebkitLineClamp: 2,
overflow: "hidden",
textOverflow: "ellipsis",
fontSize: 14,
fontWeight: "bold",
color: colors.blackTertiary
}}
>
{title || reviewTask.content.href}
</Paragraph>
<Text>{reviewTask.personalityName}</Text>
</Col>
<Col
span={24}
</Typography>
<Typography style={{color: colors.blackTertiary,fontSize: 14}}>{reviewTask.personalityName}</Typography>
</Grid>
<Grid item
xs={12}
style={{
display: "flex",
justifyContent: "space-between",
}}
>
{isImage ? (
<PhotoOutlinedIcon color="primary" />
<PhotoOutlined color="primary" />
) : (
<ArticleOutlinedIcon color="primary" />
<ArticleOutlined color="primary" />
)}
<Avatar.Group>
<AvatarGroup>
{reviewTask.usersName &&
reviewTask.usersName.map((user, index) => {
return <UserTag user={user} key={index} />;
})}
</Avatar.Group>
</Col>
</Row>
})}
</AvatarGroup>
</Grid>
</Grid>
</CardBase>
</a>
);
Expand Down
23 changes: 12 additions & 11 deletions src/components/Login/LoginView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
UpdateLoginFlowBody,
UpdateLoginFlowWithPasswordMethod as ValuesType,
} from "@ory/client";
import { Col, message, Row } from "antd";
import Grid from "@mui/material/Grid";
import global from "../Messages";
import { AxiosError } from "axios";
import { useTranslation } from "next-i18next";
import { useRouter } from "next/router";
Expand Down Expand Up @@ -73,7 +74,7 @@ const LoginView = ({ isSignUp = false, shouldGoBack = false }) => {
if (err.response?.status === 400) {
// Yup, it is!
setFlow(err.response?.data);
return message.error(t("profile:totpIncorectCodeMessage"));
return global.showMessage("error", `${t("profile:totpIncorectCodeMessage")}`);
}

return Promise.reject(err);
Expand Down Expand Up @@ -142,19 +143,19 @@ const LoginView = ({ isSignUp = false, shouldGoBack = false }) => {

const onFinishFailed = (errorInfo) => {
if (typeof errorInfo === "string") {
message.error(errorInfo);
global.showMessage("error", errorInfo)
} else {
message.error(t("login:loginFailedMessage"));
global.showMessage("error", `${t("login:loginFailedMessage")}`);
}
setIsLoading(false);
};

return (
<Row
justify="center"
<Grid container
justifyContent="center"
style={{ marginTop: 45, height: "100%", padding: "24px" }}
>
<Col xs={22} sm={12}>
<Grid item xs={11} sm={6}>
{isSignUp ? (
<SignUpForm
onFinish={onFinish}
Expand All @@ -170,14 +171,14 @@ const LoginView = ({ isSignUp = false, shouldGoBack = false }) => {
isLoading={isLoading}
onFinishTotp={onFinishTotp}
/>
<Row className="typo-grey typo-center">
<Grid container className="typo-grey typo-center">
<h2>{t("login:signUpHeader")}</h2>
</Row>
</Grid>
<CTAButton type={ButtonType.blue} />
</>
)}
</Col>
</Row>
</Grid>
</Grid>
);
};

Expand Down
23 changes: 12 additions & 11 deletions src/components/Profile/Totp.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint-disable @next/next/no-img-element */
/* eslint-disable jsx-a11y/anchor-has-content */
import { UpdateSettingsFlowWithTotpMethod as ValuesType } from "@ory/client";
import { Form, message, Row, Typography } from "antd";
import { Form } from "antd";
import global from "../Messages";
import { Grid, Typography } from "@mui/material"
import { Trans, useTranslation } from "next-i18next";
import React, { useEffect, useState } from "react";
import { orySubmitTotp } from "../../api/ory";
Expand All @@ -14,7 +16,6 @@ import userApi from "../../api/userApi";

export const Totp = ({ flow, setFlow }) => {
const [imgSource, setImgSource] = useState("");
const { Title } = Typography;
const [textSource, setTextSource] = useState("");
const [showForm, setShowForm] = useState(true);
const [isLoading, setIsLoading] = useState(false);
Expand Down Expand Up @@ -67,7 +68,7 @@ export const Totp = ({ flow, setFlow }) => {
})
.then(() => setIsLoading(false))
.catch(() => {
message.error(t("profile:totpIncorectCodeMessage"));
global.showMessage("error", `${t("profile:totpIncorectCodeMessage")}`);
setIsLoading(false);
});
};
Expand All @@ -83,7 +84,7 @@ export const Totp = ({ flow, setFlow }) => {
})
.then(() => setIsLoading(false))
.catch(() => {
message.error(t("prifile:totpUnLinkErrorMessage"));
global.showMessage("error", `${t("profile:totpUnLinkErrorMessage")}`);
setIsLoading(false);
});
};
Expand Down Expand Up @@ -112,11 +113,11 @@ export const Totp = ({ flow, setFlow }) => {

return (
<>
<Row>
<Typography.Title level={4}>
<Grid container>
<Typography variant="h4" fontSize={20} fontWeight={600}>
{t("profile:totpSectionTittle")}
</Typography.Title>
</Row>
</Typography>
</Grid>
{showForm && (
<Form onFinish={onFinish} style={{ marginBottom: "20px" }}>
<Form.Item>
Expand Down Expand Up @@ -216,8 +217,8 @@ export const Totp = ({ flow, setFlow }) => {
}}
type={ButtonType.blue}
>
<Title
level={4}
<Typography
variant="h4"
style={{
fontSize: 14,
color: colors.white,
Expand All @@ -226,7 +227,7 @@ export const Totp = ({ flow, setFlow }) => {
}}
>
{t("profile:totpUnLinkSubmit")}
</Title>
</Typography>
</AletheiaButton>
</Form>
)}
Expand Down
8 changes: 4 additions & 4 deletions src/lib/orysdk/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { message } from "antd";
import global from "../../components/Messages";
import { AxiosError } from "axios";
import { TFunction } from "i18next";
import { NextRouter } from "next/router";
Expand Down Expand Up @@ -29,15 +29,15 @@ export function handleGetFlowError<S>(
await router.push("/");
return;
case "self_service_flow_return_to_forbidden":
message.error(t("oryErrors:returnAddressForbidden"));
global.showMessage("error", t("oryErrors:returnAddressForbidden"));
await requestNewFlow();
return;
case "self_service_flow_expired":
message.error(t("oryErrors:flowExpired"));
global.showMessage("error", t("oryErrors:flowExpired"));
await requestNewFlow();
return;
case "security_csrf_violation":
message.error(t("oryErrors:csrfViolation"));
global.showMessage("error", t("oryErrors:csrfViolation"));
await requestNewFlow();

return;
Expand Down

0 comments on commit 2100c2c

Please sign in to comment.