Skip to content

Commit

Permalink
Issue feat: fix undefine null function for array to map
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshataKatwal16 committed Aug 2, 2024
1 parent 61b27c6 commit d65d7e1
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/components/DeleteUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const DeleteUserModal: React.FC<DeleteUserModalProps> = ({
>
<>
<Box padding={"0 1rem"}>
{reasons.map((option) => (
{reasons?.map((option) => (
<>
<Box
display={"flex"}
Expand Down
2 changes: 1 addition & 1 deletion src/components/DynamicForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const DynamicForm: React.FC<DynamicFormProps> = ({
function transformErrors(errors: any) {
console.log("errors", errors);
console.log("schema", schema);
return errors.map((error: any) => {
return errors?.map((error: any) => {
switch (error.name) {
case "required": {
error.message = t("FORM_ERROR_MESSAGES.THIS_IS_REQUIRED_FIELD");
Expand Down
2 changes: 1 addition & 1 deletion src/components/FormControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const MultipleSelectCheckmarks: React.FC<MultipleSelectCheckmarksProps> = ({
target: { value },
} = event;
const selectedNames = typeof value === "string" ? value.split(",") : value;
const selectedCodes = selectedNames.map(
const selectedCodes = selectedNames?.map(
(name) => codes[names.indexOf(name)],
);
onCategoryChange(selectedNames, selectedCodes);
Expand Down
14 changes: 7 additions & 7 deletions src/components/GeneratedSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const GenerateSchemaAndUiSchema = (
fieldSchema.checkbox = true;
fieldSchema.items = {
type: "string",
oneOf: options.map((opt: FieldOption) => ({
oneOf: options?.map((opt: FieldOption) => ({
const: opt.value,
title:
t(`FORM.${opt.label}`) === `FORM.${opt.label}`
Expand All @@ -94,7 +94,7 @@ export const GenerateSchemaAndUiSchema = (
break;
case "radio":
fieldSchema.type = "string";
fieldSchema.oneOf = options.map((opt: FieldOption) => ({
fieldSchema.oneOf = options?.map((opt: FieldOption) => ({
const: opt.value,
title:
t(`FORM.${opt.label}`) === `FORM.${opt.label}`
Expand Down Expand Up @@ -131,10 +131,10 @@ export const GenerateSchemaAndUiSchema = (
fieldSchema.type = "array";
fieldSchema.items = {
type: "string",
enum: options.map((opt: FieldOption) => opt.value),
enum: options?.map((opt: FieldOption) => opt.value),
};
fieldSchema.uniqueItems = true;
fieldSchema.enumNames = options.map((opt: FieldOption) =>
fieldSchema.enumNames = options?.map((opt: FieldOption) =>
t(`FORM.${opt.label}`) === `FORM.${opt.label}`
? opt.label
: t(`FORM.${opt.label}`)
Expand All @@ -151,7 +151,7 @@ export const GenerateSchemaAndUiSchema = (
if (isMultiSelect && maxSelections === 1 && type === "drop_down") {
fieldSchema.type = "string";
fieldSchema.isDropdown = true;
fieldSchema.oneOf = options.map((opt: FieldOption) => ({
fieldSchema.oneOf = options?.map((opt: FieldOption) => ({
const: opt.value,
title:
t(`FORM.${opt.label}`) === `FORM.${opt.label}`
Expand All @@ -163,7 +163,7 @@ export const GenerateSchemaAndUiSchema = (
if (!isMultiSelect && type === "drop_down") {
fieldSchema.type = "string";
fieldSchema.isDropdown = true;
fieldSchema.oneOf = options.map((opt: FieldOption) => ({
fieldSchema.oneOf = options?.map((opt: FieldOption) => ({
const: opt.value,
title:
t(`FORM.${opt.label}`) === `FORM.${opt.label}`
Expand All @@ -176,7 +176,7 @@ export const GenerateSchemaAndUiSchema = (
fieldSchema.type = "array";
fieldSchema.items = {
type: "string",
oneOf: options.map((opt: FieldOption) => ({
oneOf: options?.map((opt: FieldOption) => ({
const: opt.value,
title:
t(`FORM.${opt.label}`) === `FORM.${opt.label}`
Expand Down
2 changes: 1 addition & 1 deletion src/components/HeaderComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ const HeaderComponent = ({
}}
>
<MenuItem value="Sort">{t("COMMON.SORT")}</MenuItem>
{Sort.map((state, index) => (
{Sort?.map((state, index) => (
<MenuItem value={state} key={index}>
{state}
</MenuItem>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Steper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const CustomStepper = ({ completedSteps = 0 }) => {

return (
<Box sx={{ display: "flex", gap: "4px", alignItems: "center" }}>
{[...Array(totalSteps)].map((_, index) => (
{[...Array(totalSteps)]?.map((_, index) => (
<Box
key={index}
sx={{
Expand Down
2 changes: 1 addition & 1 deletion src/components/Stepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const CustomStepper = ({ completedSteps = 0 }) => {

return (
<Box sx={{ display: "flex", gap: "4px", alignItems: "center" }}>
{[...Array(totalSteps)].map((_, index) => (
{[...Array(totalSteps)]?.map((_, index) => (
<Box
key={index}
sx={{
Expand Down
4 changes: 2 additions & 2 deletions src/components/UserTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ const handleCloseAddTeamLeaderModal = () => {

setPageCount(Math.ceil(resp?.totalCount / pageLimit));
console.log(result);
const finalResult = result.map((user: any) => {
const finalResult = result?.map((user: any) => {
const ageField = user.customFields.find(
(field: any) => field.name === "age"
);
Expand Down Expand Up @@ -587,7 +587,7 @@ const handleCloseAddTeamLeaderModal = () => {
return;
}
const newData = await Promise.all(
data.map(async (user) => {
data?.map(async (user) => {
const response = await getCohortList(user.userId);
const cohortNames = response?.result?.cohortData?.map(
(cohort: Cohort) => cohort.name
Expand Down
2 changes: 1 addition & 1 deletion src/components/layouts/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const Sidebar = ({
{item.subOptions && (
<Collapse in={open === index} timeout="auto" unmountOnExit>
<List component="div" disablePadding>
{item.subOptions.map((subItem) => (
{item.subOptions?.map((subItem) => (
<Tooltip title={t(subItem.title)} placement="right-start">
<ListItem
button
Expand Down
2 changes: 1 addition & 1 deletion src/pages/course-planner/foundation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const Foundation = () => {
<Typography>{t("COURSE_PLANNER.COPY_LINK")}</Typography>
</Box>
{!selectedCardId ? (
cardData.map((card) => (
cardData?.map((card) => (
<Card
key={card.id}
sx={{
Expand Down
2 changes: 1 addition & 1 deletion src/pages/stateDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const StateDetails = () => {
</Box>
</Box>
<Box sx={{ marginTop: "16px" }}>
{card.boards.map((board: string, index: number) => (
{card.boards?.map((board: string, index: number) => (
<Card
key={index}
sx={{
Expand Down
2 changes: 1 addition & 1 deletion src/pages/subjectDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const SubjectDetails = () => {
</Typography>
</Box>
<Box sx={{ marginTop: "16px" }}>
{card.subjects.map((subject, index) => (
{card.subjects?.map((subject, index) => (
<MuiCard
key={index}
sx={{
Expand Down
2 changes: 1 addition & 1 deletion src/services/CreateUserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const getFormRead = async (
},
paramsSerializer: params => {
return Object.entries(params)
.map(([key, value]) => `${key}=${value}`)
?.map(([key, value]) => `${key}=${value}`)
.join('&');
},
headers: { tenantId:"ef99949b-7f3a-4a5f-806a-e67e683e38f3"}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const getUserName = async (userId: string) => {
export const getDeviceId = () => {
return new Promise((resolve) => {
FingerprintJS.get((components: any[]) => {
const values = components.map((component) => component.value);
const values = components?.map((component) => component.value);
const deviceId = FingerprintJS.x64hash128(values.join(""), 31);
resolve(deviceId);
});
Expand Down

0 comments on commit d65d7e1

Please sign in to comment.