Skip to content

Commit

Permalink
fix(allineamento): updates 20240130
Browse files Browse the repository at this point in the history
  • Loading branch information
a-buono committed Jan 30, 2024
1 parent 21d00c3 commit 736ac80
Show file tree
Hide file tree
Showing 55 changed files with 1,600 additions and 1,577 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import clsx from 'clsx';
import { CardText, CardTitle, Col, Icon } from 'design-react-kit';
import React, { memo } from 'react';
import Heart from '/public/assets/img/hollow-grey-heart.png';
import './cardForum.scss';
import './cardCommunity.scss';
import { useNavigate } from 'react-router-dom';
import PublishingAuthority from '../CardDocument/PublishingAuthority';
import { formatDate } from '../../utils/datesHelper';
import { ForumCardsI } from '../CardShowcase/cardShowcase';

const CardForum: React.FC<ForumCardsI> = (props) => {
const CardCommunity: React.FC<ForumCardsI> = (props) => {
const {
id,
title,
Expand All @@ -23,14 +23,14 @@ const CardForum: React.FC<ForumCardsI> = (props) => {
const navigate = useNavigate();

const navigateTo = () => {
navigate(`/forum/${id}`);
navigate(`/community/${id}`);
};

return (
<div
role='button'
className={clsx(
'card-forum',
'card-community',
'bg-white',
'px-4',
'pb-3',
Expand All @@ -56,7 +56,7 @@ const CardForum: React.FC<ForumCardsI> = (props) => {
>
<Col className='text-left'>
{category_label ? (
<div className='mb-2 card-forum__pre-title'>
<div className='mb-2 card-community__pre-title'>
<span className='font-weight-bold'>
{category_label}
{/* &nbsp;—&nbsp; */}
Expand All @@ -66,13 +66,13 @@ const CardForum: React.FC<ForumCardsI> = (props) => {
{title ? (
<CardTitle
tag='p'
className='card-forum__title font-weight-bold mb-3'
className='card-community__title font-weight-bold mb-3'
>
{title}
</CardTitle>
) : null}
{description ? (
<CardText className='card-forum__text mb-3 text-serif'>
<CardText className='card-community__text mb-3 text-serif'>
{description}
</CardText>
) : null}
Expand All @@ -87,7 +87,7 @@ const CardForum: React.FC<ForumCardsI> = (props) => {
'align-items-center'
)}
>
<span className='card-forum__date'>
<span className='card-community__date'>
{date && formatDate(date, 'shortDate')}
</span>
<div className='d-flex'>
Expand All @@ -106,7 +106,7 @@ const CardForum: React.FC<ForumCardsI> = (props) => {
aria-label='Likes'
aria-hidden
/>
<span className='card-forum__span-icons pl-1'>{likes}</span>
<span className='card-community__span-icons pl-1'>{likes}</span>
</div>
<div
className={clsx(
Expand All @@ -123,7 +123,9 @@ const CardForum: React.FC<ForumCardsI> = (props) => {
aria-label='Comments'
aria-hidden
/>
<span className='card-forum__span-icons pl-1'>{comment_count}</span>
<span className='card-community__span-icons pl-1'>
{comment_count}
</span>
</div>
<div className={clsx('d-flex', 'align-items-center', 'category-top')}>
<Icon
Expand All @@ -133,12 +135,12 @@ const CardForum: React.FC<ForumCardsI> = (props) => {
aria-label='Views'
aria-hidden
/>
<span className='card-forum__span-icons pl-1'>{views}</span>
<span className='card-community__span-icons pl-1'>{views}</span>
</div>
</div>
</div>
</div>
);
};

export default memo(CardForum);
export default memo(CardCommunity);
18 changes: 9 additions & 9 deletions fe-piattaforma/src/components/Comments/comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface CommentI {
isAnswer?: boolean;
thread?: boolean;
noBorder?: boolean;
section: 'board' | 'forum' | 'documents';
section: 'board' | 'community' | 'documents';
onDeleteComment?: () => void;
onEditComment?: () => void;
reported: 0 | 1;
Expand Down Expand Up @@ -134,7 +134,7 @@ const Comment: React.FC<CommentI> = (props) => {
hasUserPermission([
section === 'board'
? 'del.news'
: section === 'forum'
: section === 'community'
? 'del.topic'
: section === 'documents'
? 'del.doc'
Expand All @@ -148,7 +148,7 @@ const Comment: React.FC<CommentI> = (props) => {
hasUserPermission([
section === 'board'
? 'upd.news'
: section === 'forum'
: section === 'community'
? 'upd.topic'
: section === 'documents'
? 'upd.doc'
Expand All @@ -162,7 +162,7 @@ const Comment: React.FC<CommentI> = (props) => {
hasUserPermission([
section === 'board'
? 'rprt.news'
: section === 'forum'
: section === 'community'
? 'rprt.topic'
: section === 'documents'
? 'rprt.doc'
Expand Down Expand Up @@ -327,20 +327,20 @@ const Comment: React.FC<CommentI> = (props) => {
replies={
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
section === 'forum' && replies !== '[]'
section === 'community' && replies !== '[]'
? replies?.length
: undefined
}
views={section === 'forum' ? views : undefined}
views={section === 'community' ? views : undefined}
onShowReplies={
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
section === 'forum' && replies !== '[]' && replies?.length
section === 'community' && replies !== '[]' && replies?.length
? () => setShowReplies((prev) => !prev)
: undefined
}
isReply={isReply}
showReplies={section === 'forum' ? showReplies : undefined}
showReplies={section === 'community' ? showReplies : undefined}
likes={likes}
user_like={user_like}
onLike={async () => {
Expand All @@ -355,7 +355,7 @@ const Comment: React.FC<CommentI> = (props) => {
}
}}
onComment={
section === 'forum'
section === 'community'
? () =>
dispatch(
openModal({
Expand Down
2 changes: 1 addition & 1 deletion fe-piattaforma/src/components/Comments/commentSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SectionTitle from '../SectionTitle/sectionTitle';
import Comment from './comment';

interface commentSectionI {
section: 'board' | 'forum' | 'documents';
section: 'board' | 'community' | 'documents';
}

const CommentSection: React.FC<commentSectionI> = ({ section }) => {
Expand Down
20 changes: 10 additions & 10 deletions fe-piattaforma/src/components/DocumentDetail/sectionDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface CardDocumentDetailI {
user_like?: boolean;
likes?: number;
views?: number;
section?: 'forum' | 'documents';
section?: 'community' | 'documents';
isDocument?: boolean | undefined;
onDeleteClick?: () => void;
onEditClick?: () => void;
Expand Down Expand Up @@ -138,15 +138,15 @@ const SectionDetail: React.FC<CardDocumentDetailI> = (props) => {
hasUserPermission([
section === 'documents' || isDocument
? 'del.doc'
: section === 'forum'
: section === 'community'
? 'del.topic'
: 'hidden',
]) ||
(author?.toString() === userId?.toString() &&
hasUserPermission([
section === 'documents' || isDocument
? 'new.doc'
: section === 'forum'
: section === 'community'
? 'new.topic'
: 'hidden',
]))
Expand All @@ -157,15 +157,15 @@ const SectionDetail: React.FC<CardDocumentDetailI> = (props) => {
hasUserPermission([
section === 'documents' || isDocument
? 'upd.doc'
: section === 'forum'
: section === 'community'
? 'upd.topic'
: 'hidden',
]) ||
(author?.toString() === userId?.toString() &&
hasUserPermission([
section === 'documents' || isDocument
? 'new.doc'
: section === 'forum'
: section === 'community'
? 'new.topic'
: 'hidden',
]))
Expand All @@ -176,7 +176,7 @@ const SectionDetail: React.FC<CardDocumentDetailI> = (props) => {
hasUserPermission([
section === 'documents' || isDocument
? 'rprt.doc'
: section === 'forum'
: section === 'community'
? 'rprt.topic'
: 'hidden',
])
Expand Down Expand Up @@ -392,7 +392,7 @@ const SectionDetail: React.FC<CardDocumentDetailI> = (props) => {
</div>
) : null}
<DetailCard
isForum={section === 'forum'}
isForum={section === 'community'}
entity={entity}
entity_type={entity_type}
intervention={intervention}
Expand All @@ -406,7 +406,7 @@ const SectionDetail: React.FC<CardDocumentDetailI> = (props) => {
downloads={downloads}
user_like={user_like}
onLike={
section === 'forum'
section === 'community'
? async () => {
if (id) {
if (user_like as boolean) {
Expand All @@ -422,7 +422,7 @@ const SectionDetail: React.FC<CardDocumentDetailI> = (props) => {
})
);
}
userId && dispatch(GetItemDetail(id, userId, 'forum'));
userId && dispatch(GetItemDetail(id, userId, 'community'));
}
}
: undefined
Expand All @@ -434,7 +434,7 @@ const SectionDetail: React.FC<CardDocumentDetailI> = (props) => {
payload: {
title: 'Aggiungi commento',
action: 'comment',
entity: section === 'forum' ? 'forum' : 'document',
entity: section === 'community' ? 'community' : 'document',
category: category_label || category,
textLabel: 'Digita qui sotto il testo',
},
Expand Down
2 changes: 1 addition & 1 deletion fe-piattaforma/src/components/MocksWave3/Mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const DocumentCardMock = {
comment: 12,
};

export const ForumPropsMock = [
export const CommunityPropsMock = [
{
title: 'La Digital Skills and Jobs Platform: un anno da festeggiare',
description:
Expand Down
8 changes: 4 additions & 4 deletions fe-piattaforma/src/components/ReportCard/ReportCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface ReportCardI {
comment_post_date?: string;
item_id: string;
item_title?: string;
item_type: 'board_item' | 'forum_item' | 'document_item';
item_type: 'board_item' | 'community_item' | 'document_item';
reason: string;
date: string;
}
Expand Down Expand Up @@ -91,7 +91,7 @@ const ReportCard: React.FC<ReportCardI> = ({
switch (item_type) {
case 'board_item':
return short ? 'news' : 'la news';
case 'forum_item':
case 'community_item':
return short ? 'topic' : 'il topic';
case 'document_item':
return short ? 'documento' : 'il documento';
Expand Down Expand Up @@ -264,8 +264,8 @@ const ReportCard: React.FC<ReportCardI> = ({
case 'board_item':
navigate(`/bacheca/${item_id}`);
break;
case 'forum_item':
navigate(`/forum/${item_id}`);
case 'community_item':
navigate(`/community/${item_id}`);
break;
case 'document_item':
navigate(`/documenti/${item_id}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import Input from '../Form/input';
import { setCitizenSearchResults } from '../../redux/features/citizensArea/citizensAreaSlice';
import { SearchValue } from '../../pages/forms/models/searchValue.model';
import { Buffer } from 'buffer';
import { mappaMesi } from '../../consts/monthsMapForFiscalCode';
import { emitNotify } from '../../redux/features/notification/notificationSlice';
import moment from 'moment';
import { Parser, Validator } from '@marketto/codice-fiscale-utils';

interface SearchBarOptionsI {
setCurrentStep: (value: string) => void;
Expand Down Expand Up @@ -45,20 +46,7 @@ const SearchBarOptionsCitizen: React.FC<SearchBarOptionsI> = ({
const [mustValidateCf, setMustValidateCf] = useState<boolean>(true);

const isMaggiorenne = useCallback((cf: string): boolean => {
const today: Date = new Date();
const rangeCentury: number = parseInt(
today.getFullYear().toString().substring(2)
);
const isFemale: boolean = cf.charAt(9) >= '4';
const dayOfBirth: number =
parseInt(cf.substring(9, 11)) - (isFemale ? 40 : 0);
const century: number = parseInt(cf.substring(6, 8));
const yearOfBirth: number =
century <= rangeCentury ? 2000 + century : 1900 + century;
const month: number = mappaMesi.get(cf.charAt(8).toUpperCase()) as number;
const dateOfBirth: Date = new Date(yearOfBirth, month, dayOfBirth);
const age: number = today.getFullYear() - dateOfBirth.getFullYear();
return age > 18;
return moment().diff(Parser.cfToBirthDate(cf), 'years', false) >= 18;
}, []);

const dispatchNotify = useCallback(
Expand All @@ -72,9 +60,20 @@ const SearchBarOptionsCitizen: React.FC<SearchBarOptionsI> = ({

const isValidFiscalCode = useCallback(
(query: string) => {
const isValid: boolean =
/^[A-Z]{6}[0-9]{2}[A-Z][0-9]{2}[A-Z][0-9]{3}[A-Z]$/i.test(query);
if (isValid) {
const fiscalCodeValid = Validator.codiceFiscale(query).valid;
const fiscalCodeLengthCorrect = query.length === 16;

if (!fiscalCodeValid && fiscalCodeLengthCorrect) {
dispatchNotify(
1,
'ERRORE',
'error',
'Il codice fiscale inserito non è valido',
'medium'
);
return false;
}
if (fiscalCodeValid) {
const isAdult = isMaggiorenne(query);
if (!isAdult) {
dispatchNotify(
Expand All @@ -87,9 +86,10 @@ const SearchBarOptionsCitizen: React.FC<SearchBarOptionsI> = ({
}
return isAdult;
}
return isValid;

return false;
},
[dispatch, isMaggiorenne]
[dispatchNotify, isMaggiorenne]
);

const onRadioChange = useCallback(
Expand Down
2 changes: 2 additions & 0 deletions fe-piattaforma/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Accordion from './Accordion/accordion';
import Card from './Card/card';
import CardCommunity from './CardCommunity/cardCommunity';
import CardCounter from './CardCounter/cardCounter';
import CardProfile from './CardProfile/cardProfile';
import CardStatusAction from './CardStatusAction/cardStatusAction';
Expand Down Expand Up @@ -47,6 +48,7 @@ export {
Breadcrumb,
ButtonsBar,
Card,
CardCommunity,
CardCounter,
CardProfile,
CardStatusAction,
Expand Down
Loading

0 comments on commit 736ac80

Please sign in to comment.