Skip to content

Commit

Permalink
Profile changes (#41)
Browse files Browse the repository at this point in the history
* Routing issue resolved

* response key mapping changes

* Style issues fixed

* Sonar issues resolved

* coderabbitai comments resolved

* Sonar cloud issue resolved

* Sonar cloud issue resolved

* style issues fixed

* style changed

* Consent Dialogue added

* conflict resolved

* Sonar issue resolved

* Sonar issue resolved

* comments resolved

* layout issue fixed

* navigation issue fixed

* key added

* env changes

* style change

* mapping changes

* Fix-Filter

* Fix-FIlter Style change

* Added transform data

* Profile changes

* added type in userdata
  • Loading branch information
vidyaaKhandekar authored Nov 29, 2024
1 parent bc76b7a commit 53b4171
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 19 deletions.
35 changes: 20 additions & 15 deletions src/components/common/UserDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import React from "react";
import React, { useEffect } from "react";
import { Box, Text, HStack, VStack } from "@chakra-ui/react";
import { useTranslation } from "react-i18next";
import { formatDate } from "../../utils/jsHelper/helper";

// Define common styles for Text and Input components
const labelStyles = {
fontSize: "12px",
fontWeight: "500",
fontWeight: "600",
mb: 1,
color: "#06164B",
lineHeight: "16px",
};

const valueStyles = {
fontSize: "12px",
fontWeight: "500",
fontSize: "14px",
fontWeight: "400",
color: "#1F1B13",
lineHeight: "14px",
};

interface UserData {
Expand Down Expand Up @@ -74,6 +77,8 @@ const Field: React.FC<FieldProps> = ({ label, value, defaultValue = "__" }) => (
const UserDetails: React.FC<UserDetailsProps> = ({ userData }) => {
const { t } = useTranslation();

const formattedDate = formatDate(userData?.dob);

return (
<Box
borderRadius="5px"
Expand All @@ -83,7 +88,7 @@ const UserDetails: React.FC<UserDetailsProps> = ({ userData }) => {
borderWidth={1}
p={6}
>
<VStack spacing={6} align="stretch" mb={6}>
{/* <VStack spacing={6} align="stretch" mb={6}>
<Field
label={t("USER_DETAILS_FATHER_NAME")}
value={userData?.fatherName}
Expand All @@ -93,38 +98,38 @@ const UserDetails: React.FC<UserDetailsProps> = ({ userData }) => {
value={userData?.motherName}
/>
<Field label={t("USER_DETAILS_LAST_NAME")} value={userData?.lastName} />
</VStack>
</VStack> */}

<VStack spacing={6} align="stretch">
<HStack spacing={4}>
<Field label={t("USER_DETAILS_DOB")} value={userData?.dob} />{" "}
<Field
label={t("USER_DETAILS_DISABILITY")}
value={userData?.disabilityStatus}
/>
<Field label={t("USER_DETAILS_DOB")} value={formattedDate} />{" "}
</HStack>
<HStack spacing={4}>
<Field label={t("USER_DETAILS_GENDER")} value={userData?.gender} />
<Field label={t("USER_DETAILS_CASTE")} value={userData?.caste} />
</HStack>
<HStack spacing={4}>
<Field label={t("USER_DETAILS_CLASS")} value={userData?.class} />
<Field
label={t("USER_DETAILS_PREVIOUS_YEAR_MARKS")}
value={userData?.previousYearMarks}
label={t("USER_DETAILS_DISABILITY")}
value={userData?.disabilityStatus}
/>
<Field label={t("USER_DETAILS_CLASS")} value={userData?.class} />
</HStack>

<HStack spacing={4}>
<Field
label={t("USER_DETAILS_ANNUAL_INCOME")}
value={userData?.annualIncome}
value={userData?.annualIncome && `INR ${userData?.annualIncome}`}
/>
<Field
label={t("USER_DETAILS_DAY_SCHOLAR_HOSTLER")}
value={userData?.studentType}
/>
</HStack>
<Field
label={t("USER_DETAILS_PREVIOUS_YEAR_MARKS")}
value={userData?.previousYearMarks}
/>
</VStack>
</Box>
);
Expand Down
9 changes: 6 additions & 3 deletions src/screens/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const UserProfile: React.FC = () => {
<HStack m={5} mt={0} p={0} h={82}>
<Avatar
variant="solid"
name={`${userData?.firstName || ""} ${userData?.lastName || ""}`}
name={`${userData?.firstName || ""} ${userData?.lastName || ""}`}
mr={2}
/>
<VStack mt={8}>
Expand All @@ -70,7 +70,8 @@ const UserProfile: React.FC = () => {
color="#433E3F"
textAlign={"start"}
>
{userData?.firstName || ""} {userData?.lastName || ""}
{userData?.firstName || ""} {userData?.fatherName || ""}{" "}
{userData?.lastName || ""}
</Text>
<Text
fontSize="11px"
Expand All @@ -79,7 +80,9 @@ const UserProfile: React.FC = () => {
color="#433E3F"
alignSelf={"flex-start"}
>
+91 {userData?.phoneNumber || "Phone No"}
{userData?.phoneNumber
? ` +91 ${userData?.phoneNumber}`
: "Phone Number"}
</Text>
</VStack>
</HStack>
Expand Down
2 changes: 1 addition & 1 deletion src/utils/context/checkToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface UserData {
class?: string;
previousYearMarks?: string;
phoneNumber?: string;

fatherName?: string;
firstName?: string;
lastName?: string;
email?: string;
Expand Down
9 changes: 9 additions & 0 deletions src/utils/jsHelper/helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,12 @@ export const transformData = (userData) => {
mobile: userData.phoneNumber ?? "",
};
};

export const formatDate = (dateString) => {
const date = new Date(dateString);
const day = String(date.getUTCDate()).padStart(2, "0");
const month = String(date.getUTCMonth() + 1).padStart(2, "0");
const year = date.getUTCFullYear();

return `${day}/${month}/${year}`;
};

0 comments on commit 53b4171

Please sign in to comment.