From 8be8acfa19ba62fe7e262d432a5b3deb935f28a3 Mon Sep 17 00:00:00 2001 From: JoshDagat Date: Sat, 30 Sep 2023 12:27:25 +0800 Subject: [PATCH] bt-884: * Admin UI fix + message parsing --- .../components/profile/profile.tsx | 209 +++++++++++------- .../components/profile/styles.module.scss | 83 ++++++- .../src/helpers/parse-messages.helper.tsx | 7 +- 3 files changed, 207 insertions(+), 92 deletions(-) diff --git a/frontend/src/bundles/admin-panel/components/profile/profile.tsx b/frontend/src/bundles/admin-panel/components/profile/profile.tsx index f2fabb2d1..96db4678c 100644 --- a/frontend/src/bundles/admin-panel/components/profile/profile.tsx +++ b/frontend/src/bundles/admin-panel/components/profile/profile.tsx @@ -7,6 +7,7 @@ import { Grid, Typography, } from '~/bundles/common/components/components.js'; +import { getValidClassNames } from '~/bundles/common/helpers/helpers.js'; import { mapBsaBadges } from '~/bundles/lms/helpers/map-bsa-badges.js'; import { type UserDetailsFullResponseDto } from '../../types/types.js'; @@ -166,101 +167,147 @@ const Profile: React.FC = ({ userDetails, selectedRole }) => { ) : ( - - + + - - - - Employer position - - + - {userDetails.employerPosition} - - + + Employer position + + + {userDetails.employerPosition} + + - - - Company name - - - {userDetails.companyName} - - + + Company name + + + {userDetails.companyName} + + - - - Company website - - - Website link - - + + Company website + + + Website link + + - - - Location - - - {userDetails.location} - - - - - - Description - - - {userDetails.description} - - + + Location + + + {userDetails.location} + + - - - Linkedin Link - - + Linkedin Link + + + Linkedin link + + + - Linkedin link - + + Description + + + {userDetails.description} + + diff --git a/frontend/src/bundles/admin-panel/components/profile/styles.module.scss b/frontend/src/bundles/admin-panel/components/profile/styles.module.scss index 7d7cb4889..e9f375e3b 100644 --- a/frontend/src/bundles/admin-panel/components/profile/styles.module.scss +++ b/frontend/src/bundles/admin-panel/components/profile/styles.module.scss @@ -11,6 +11,84 @@ max-width: 300px; } +.layoutEmployer { + display: flex; + flex-direction: column; +} + +.companyLogo { + width: 130px; + height: 130px; +} + +.layoutEmployer .companyLogo { + margin-right: auto; + margin-bottom: 20px; + margin-left: auto; +} + +.employerDetails { + display: flex; + flex-direction: column; + justify-content: center; + gap: 10px; + max-width: 80%; + margin-right: auto; + margin-left: auto; +} + +@media screen and (width >= 1250px) { + .layoutEmployer { + width: 100%; + } + + .employerCard { + display: flex; + flex-grow: 1; + width: 100%; + } + + .employerCard .companyLogo { + margin-right: 50px; + } + + .employerDetails { + display: grid; + grid-template-columns: 1fr 1fr; + grid-template-areas: + "company position" + "website location" + "linkin ." + "description description"; + grid-auto-rows: 40px; + flex: 1; + + & .position { + grid-area: position; + } + + & .companyName { + grid-area: company; + } + + & .website { + grid-area: website; + } + + & .location { + grid-area: location; + } + + & .description { + grid-area: description; + } + + & .employerLinkedIn { + grid-area: linkin; + } + } +} + .row { flex-direction: row; gap: 20px; @@ -64,11 +142,6 @@ width: 100%; } -.companyLogo { - width: 130px; - height: 130px; -} - @media screen and (width <=1100px) { .row { & .name { diff --git a/frontend/src/helpers/parse-messages.helper.tsx b/frontend/src/helpers/parse-messages.helper.tsx index 6bbb1c86d..1e6fe72bb 100644 --- a/frontend/src/helpers/parse-messages.helper.tsx +++ b/frontend/src/helpers/parse-messages.helper.tsx @@ -1,9 +1,6 @@ const URL_REGEX = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/|www\.|localhost:)?(localhost|[\da-z]+([.-][\da-z]+)*\.[a-z]{2,5}(:\d{1,5})?(\/.*)?)$/gm; -// TODO: LOCALHOST SHOULD BE REMOVED FOR PROD -const LOCALHOST_URL_REGEX = /^https?:\/\/\w+(\.\w+)*(:\d+)?(\/.*)?$/gm; - const parseMessage = (message: string): JSX.Element => { const words = message.split(' '); @@ -11,9 +8,7 @@ const parseMessage = (message: string): JSX.Element => { {words.map((word) => { const [link, specialPrefix] = word.split('_&_').reverse(); - const isLink = - URL_REGEX.test(link) || LOCALHOST_URL_REGEX.test(link); - + const isLink = URL_REGEX.test(link); const isCVLink = isLink && specialPrefix === 'CV'; const isProfileLink = isLink && specialPrefix === 'Profile';