Skip to content

Commit

Permalink
Merge pull request #2460 from the-canonizer/ITR8-Frontend
Browse files Browse the repository at this point in the history
Itr8 frontend
  • Loading branch information
ashish76 authored Jan 10, 2025
2 parents a7d2871 + cca998c commit d6e63d0
Show file tree
Hide file tree
Showing 15 changed files with 341 additions and 170 deletions.
78 changes: 47 additions & 31 deletions src/components/ComponentPages/Form/ProfileInfoForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -743,22 +743,28 @@ function ProfileInfoForm({
<Form.Item
id="form_for_address1"
rules={[
{
validator: (_, value) => {
if (!value) return Promise.resolve();
// {
// validator: (_, value) => {
// if (!value) return Promise.resolve();

// Regular expressions to check for letters and digits
const letterOrDigitRegex = /[a-zA-Z0-9]/; // Checks if there's at least one letter or digit
// // Regular expressions to check for letters and digits
// const letterOrDigitRegex = /[a-zA-Z0-9]/; // Checks if there's at least one letter or digit

if (!letterOrDigitRegex.test(value)) {
return Promise.reject(
"Address must contain at least one letter or number."
);
}
// if (!letterOrDigitRegex.test(value)) {
// return Promise.reject(
// "Address must contain at least one letter or number."
// );
// }

return Promise.resolve();
},
},
// return Promise.resolve();
// },
// },
{
required: true,
type: 'string',
pattern: new RegExp(/^[a-zA-Z0-9\s\.\-\']*$/), // Allow characters, numbers, spaces, periods, hyphens, and apostrophes
message: 'Invalid address format.',
}
]}
name="address_1"
label={messages.labels.addressLine1}
Expand Down Expand Up @@ -840,22 +846,28 @@ function ProfileInfoForm({
<Form.Item
id="form_for_address_2"
rules={[
{
validator: (_, value) => {
if (!value) return Promise.resolve();
// {
// validator: (_, value) => {
// if (!value) return Promise.resolve();

// Regular expressions to check for letters and digits
const letterOrDigitRegex = /[a-zA-Z0-9]/; // Checks if there's at least one letter or digit
// // Regular expressions to check for letters and digits
// const letterOrDigitRegex = /[a-zA-Z0-9]/; // Checks if there's at least one letter or digit

if (!letterOrDigitRegex.test(value)) {
return Promise.reject(
"Address must contain at least one letter or number."
);
}
// if (!letterOrDigitRegex.test(value)) {
// return Promise.reject(
// "Address must contain at least one letter or number."
// );
// }

return Promise.resolve();
},
},
// return Promise.resolve();
// },
// },
{
required: true,
type: 'string',
pattern: new RegExp(/^[a-zA-Z0-9\s\.\-\']*$/), // Allow characters, numbers, spaces, periods, hyphens, and apostrophes
message: 'Invalid address format.',
}
]}
name="address_2"
label={messages.labels.addressLine2}
Expand Down Expand Up @@ -907,11 +919,11 @@ function ProfileInfoForm({
if (!value) return Promise.resolve();

// Check if the value contains only digits
if (!/^\d+$/.test(value)) {
return Promise.reject(
"Zip code must contain only numbers."
);
}
// if (!/^\d+$/.test(value)) {
// return Promise.reject(
// "Zip code must contain only numbers."
// );
// }

// Check if the value consists only of zeros
if (/^0+$/.test(value)) {
Expand All @@ -921,6 +933,10 @@ function ProfileInfoForm({
return Promise.resolve();
},
},
{
pattern: new RegExp('^[0-9-]+$'),
message: 'Zip Code can only contain numbers and hyphens.',
}
]}
name="postal_code"
label={messages.labels.zipCode}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import moment from "moment";
import Link from "next/link";
import styles from "../campHistory.module.scss";
import { useRouter } from "next/router";
import { capitalizeFirstLetter } from "src/utils/generalUtility";
import {
capitalizeFirstLetter,
commaSeparated,
} from "src/utils/generalUtility";

const { Title } = Typography;
const { Panel } = Collapse;
Expand Down Expand Up @@ -211,6 +214,19 @@ const HistoryComparison = ({
<p>
Go Live Time: <span>{covertToTime(campStatement?.go_live_time)}</span>
</p>
<p>
Topic Tags{"(s)"}:
<span>
{campStatement?.tags?.map((tag, index) => {
let lastIndex = index + 1 === campStatement?.topic_tags?.length;
return commaSeparated(tag?.title, lastIndex);
})}
</span>
</p>
<p>
Hide Rank:{" "}
<span>{campStatement?.is_rank_hidden === 1 ? "Yes" : "No"}</span>
</p>
{historyOf === "statement" && (
<Collapse
expandIconPosition="end"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import moment from "moment";
import Link from "next/link";
import { commaSeparated } from "src/utils/generalUtility";

const TopicHistory = ({ campStatement, topicNamespaceId }: any) => {
const covertToTime = (unixTime) => {
Expand Down Expand Up @@ -74,6 +75,19 @@ const TopicHistory = ({ campStatement, topicNamespaceId }: any) => {
: "Going live on"}{" "}
:<span>{covertToTime(campStatement?.go_live_time)}</span>
</p>
<p>
Topic Tag{"(s)"}:
<span>
{campStatement?.tags?.map((tag, index) => {
let lastIndex = index + 1 === campStatement?.topic_tags?.length;
return commaSeparated(tag?.title, lastIndex);
})}
</span>
</p>
<p>
Hide Rank:{" "}
<span>{campStatement?.is_rank_hidden === 1 ? "Yes" : "No"}</span>
</p>
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/ComponentPages/Home/HotTopics/topicCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const SingleTopicCard = ({
avatars,
scoreTag = null,
onTopicLinkClick = null,
tag_key = "topicTags",
tag_key = "tags",
maxCount = 5,
cardClassName = "",
copyLink = null,
Expand Down
Loading

0 comments on commit d6e63d0

Please sign in to comment.