refactor: remove unnecessary props

This commit is contained in:
Aaryan Khandelwal 2023-09-21 18:32:45 +05:30
parent c4143a1a64
commit 3ae292a2da
13 changed files with 0 additions and 66 deletions

View File

@ -5,8 +5,6 @@ import { ICustomAttribute } from "types";
type Props = { type Props = {
attributeDetails: ICustomAttribute; attributeDetails: ICustomAttribute;
issueId: string;
projectId: string;
value: boolean; value: boolean;
onChange: (val: boolean) => void; onChange: (val: boolean) => void;
}; };

View File

@ -6,8 +6,6 @@ import { ICustomAttribute } from "types";
type Props = { type Props = {
attributeDetails: ICustomAttribute; attributeDetails: ICustomAttribute;
className?: string; className?: string;
issueId: string;
projectId: string;
value: Date | undefined; value: Date | undefined;
onChange: (val: Date | null) => void; onChange: (val: Date | null) => void;
}; };

View File

@ -7,8 +7,6 @@ import { ICustomAttribute } from "types";
type Props = { type Props = {
attributeDetails: ICustomAttribute; attributeDetails: ICustomAttribute;
issueId: string;
projectId: string;
value: string | undefined; value: string | undefined;
onChange: (val: string) => void; onChange: (val: string) => void;
}; };

View File

@ -22,8 +22,6 @@ import { MAX_FILE_SIZE } from "constants/workspace";
type Props = { type Props = {
attributeDetails: ICustomAttribute; attributeDetails: ICustomAttribute;
className?: string; className?: string;
issueId: string;
projectId: string;
value: string | undefined; value: string | undefined;
onChange: (val: string | undefined) => void; onChange: (val: string | undefined) => void;
}; };

View File

@ -9,8 +9,6 @@ import { ICustomAttribute } from "types";
type Props = { type Props = {
attributeDetails: ICustomAttribute; attributeDetails: ICustomAttribute;
issueId: string;
projectId: string;
value: number | undefined; value: number | undefined;
onChange: (val: number | undefined) => void; onChange: (val: number | undefined) => void;
}; };

View File

@ -24,7 +24,6 @@ import { CYCLES_LIST, MODULE_LIST } from "constants/fetch-keys";
type Props = { type Props = {
attributeDetails: ICustomAttribute; attributeDetails: ICustomAttribute;
className?: string; className?: string;
issueId: string;
projectId: string; projectId: string;
value: string | undefined; value: string | undefined;
onChange: (val: string | undefined) => void; onChange: (val: string | undefined) => void;

View File

@ -12,9 +12,7 @@ import { ICustomAttribute } from "types";
type Props = { type Props = {
attributeDetails: ICustomAttribute; attributeDetails: ICustomAttribute;
className?: string; className?: string;
issueId: string;
onChange: (val: string | string[] | undefined) => void; onChange: (val: string | string[] | undefined) => void;
projectId: string;
} & ( } & (
| { | {
multiple?: false; multiple?: false;

View File

@ -7,8 +7,6 @@ import { ICustomAttribute } from "types";
type Props = { type Props = {
attributeDetails: ICustomAttribute; attributeDetails: ICustomAttribute;
issueId: string;
projectId: string;
value: string | undefined; value: string | undefined;
onChange: (val: string) => void; onChange: (val: string) => void;
}; };

View File

@ -7,8 +7,6 @@ import { ICustomAttribute } from "types";
type Props = { type Props = {
attributeDetails: ICustomAttribute; attributeDetails: ICustomAttribute;
issueId: string;
projectId: string;
value: string | undefined; value: string | undefined;
onChange: (val: string) => void; onChange: (val: string) => void;
}; };

View File

@ -33,9 +33,7 @@ export const CustomAttributesCheckboxes: React.FC<Props> = observer((props) => {
<div className="w-3/5 flex-shrink-0"> <div className="w-3/5 flex-shrink-0">
<CustomCheckboxAttribute <CustomCheckboxAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issueId}
onChange={(val) => onChange(attribute.id, [`${val}`])} onChange={(val) => onChange(attribute.id, [`${val}`])}
projectId={projectId}
value={values[attribute.id]?.[0] === "true" ? true : false} value={values[attribute.id]?.[0] === "true" ? true : false}
/> />
</div> </div>

View File

@ -47,9 +47,7 @@ export const CustomAttributesSelectFields: React.FC<Props> = observer((props) =>
<CustomDateTimeAttribute <CustomDateTimeAttribute
attributeDetails={attribute} attributeDetails={attribute}
className="bg-transparent border border-custom-border-200 py-1 shadow-custom-shadow-2xs" className="bg-transparent border border-custom-border-200 py-1 shadow-custom-shadow-2xs"
issueId={issueId}
onChange={(val) => onChange(attribute.id, val ? [val.toISOString()] : undefined)} onChange={(val) => onChange(attribute.id, val ? [val.toISOString()] : undefined)}
projectId={projectId}
value={values[attribute.id]?.[0] ? new Date(values[attribute.id]?.[0]) : undefined} value={values[attribute.id]?.[0] ? new Date(values[attribute.id]?.[0]) : undefined}
/> />
)} )}
@ -57,9 +55,7 @@ export const CustomAttributesSelectFields: React.FC<Props> = observer((props) =>
<CustomFileAttribute <CustomFileAttribute
attributeDetails={attribute} attributeDetails={attribute}
className="bg-transparent border border-custom-border-200 py-1 shadow-custom-shadow-2xs" className="bg-transparent border border-custom-border-200 py-1 shadow-custom-shadow-2xs"
issueId={issueId}
onChange={(val) => onChange(attribute.id, val)} onChange={(val) => onChange(attribute.id, val)}
projectId={projectId}
value={values[attribute.id]?.[0]} value={values[attribute.id]?.[0]}
/> />
)} )}
@ -67,9 +63,7 @@ export const CustomAttributesSelectFields: React.FC<Props> = observer((props) =>
<CustomSelectAttribute <CustomSelectAttribute
attributeDetails={attribute} attributeDetails={attribute}
className="bg-transparent border border-custom-border-200 py-1 shadow-custom-shadow-2xs" className="bg-transparent border border-custom-border-200 py-1 shadow-custom-shadow-2xs"
issueId={issueId}
onChange={(val) => onChange(attribute.id, val)} onChange={(val) => onChange(attribute.id, val)}
projectId={projectId}
value={values[attribute.id] ?? []} value={values[attribute.id] ?? []}
multiple multiple
/> />
@ -78,7 +72,6 @@ export const CustomAttributesSelectFields: React.FC<Props> = observer((props) =>
<CustomRelationAttribute <CustomRelationAttribute
attributeDetails={attribute} attributeDetails={attribute}
className="bg-transparent border border-custom-border-200 py-1 shadow-custom-shadow-2xs" className="bg-transparent border border-custom-border-200 py-1 shadow-custom-shadow-2xs"
issueId={issueId}
onChange={(val) => onChange(attribute.id, val)} onChange={(val) => onChange(attribute.id, val)}
projectId={projectId} projectId={projectId}
value={values[attribute.id]?.[0]} value={values[attribute.id]?.[0]}
@ -88,9 +81,7 @@ export const CustomAttributesSelectFields: React.FC<Props> = observer((props) =>
<CustomSelectAttribute <CustomSelectAttribute
attributeDetails={attribute} attributeDetails={attribute}
className="bg-transparent border border-custom-border-200 py-1 shadow-custom-shadow-2xs" className="bg-transparent border border-custom-border-200 py-1 shadow-custom-shadow-2xs"
issueId={issueId}
onChange={(val) => onChange(attribute.id, val)} onChange={(val) => onChange(attribute.id, val)}
projectId={projectId}
value={values[attribute.id]?.[0]} value={values[attribute.id]?.[0]}
multiple={false} multiple={false}
/> />

View File

@ -125,9 +125,7 @@ export const PeekOverviewCustomAttributesList: React.FC<Props> = observer(
{attribute.type === "checkbox" && ( {attribute.type === "checkbox" && (
<CustomCheckboxAttribute <CustomCheckboxAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => handleAttributeUpdate(attribute.id, [`${val}`])} onChange={(val) => handleAttributeUpdate(attribute.id, [`${val}`])}
projectId={issue.project}
value={ value={
attributeValue attributeValue
? attributeValue?.[0]?.value === "true" ? attributeValue?.[0]?.value === "true"
@ -140,40 +138,32 @@ export const PeekOverviewCustomAttributesList: React.FC<Props> = observer(
{attribute.type === "datetime" && ( {attribute.type === "datetime" && (
<CustomDateTimeAttribute <CustomDateTimeAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => { onChange={(val) => {
handleAttributeUpdate(attribute.id, val ? [val.toISOString()] : undefined); handleAttributeUpdate(attribute.id, val ? [val.toISOString()] : undefined);
}} }}
projectId={issue.project}
value={attributeValue ? new Date(attributeValue?.[0]?.value ?? "") : undefined} value={attributeValue ? new Date(attributeValue?.[0]?.value ?? "") : undefined}
/> />
)} )}
{attribute.type === "email" && ( {attribute.type === "email" && (
<CustomEmailAttribute <CustomEmailAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => { onChange={(val) => {
handleAttributeUpdate(attribute.id, val && val !== "" ? [val] : undefined); handleAttributeUpdate(attribute.id, val && val !== "" ? [val] : undefined);
}} }}
projectId={issue.project}
value={attributeValue ? attributeValue?.[0]?.value : undefined} value={attributeValue ? attributeValue?.[0]?.value : undefined}
/> />
)} )}
{attribute.type === "file" && ( {attribute.type === "file" && (
<CustomFileAttribute <CustomFileAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => handleAttributeUpdate(attribute.id, val)} onChange={(val) => handleAttributeUpdate(attribute.id, val)}
projectId={issue.project}
value={attributeValue ? attributeValue?.[0]?.value : undefined} value={attributeValue ? attributeValue?.[0]?.value : undefined}
/> />
)} )}
{attribute.type === "multi_select" && ( {attribute.type === "multi_select" && (
<CustomSelectAttribute <CustomSelectAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => handleAttributeUpdate(attribute.id, val)} onChange={(val) => handleAttributeUpdate(attribute.id, val)}
projectId={issue.project}
value={Array.isArray(attributeValue) ? attributeValue.map((v) => v.value) : []} value={Array.isArray(attributeValue) ? attributeValue.map((v) => v.value) : []}
multiple multiple
/> />
@ -181,11 +171,9 @@ export const PeekOverviewCustomAttributesList: React.FC<Props> = observer(
{attribute.type === "number" && ( {attribute.type === "number" && (
<CustomNumberAttribute <CustomNumberAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => { onChange={(val) => {
handleAttributeUpdate(attribute.id, val ? [val.toString()] : undefined); handleAttributeUpdate(attribute.id, val ? [val.toString()] : undefined);
}} }}
projectId={issue.project}
value={ value={
attributeValue ? parseInt(attributeValue?.[0]?.value ?? "0", 10) : undefined attributeValue ? parseInt(attributeValue?.[0]?.value ?? "0", 10) : undefined
} }
@ -194,7 +182,6 @@ export const PeekOverviewCustomAttributesList: React.FC<Props> = observer(
{attribute.type === "relation" && ( {attribute.type === "relation" && (
<CustomRelationAttribute <CustomRelationAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => handleAttributeUpdate(attribute.id, val)} onChange={(val) => handleAttributeUpdate(attribute.id, val)}
projectId={issue.project} projectId={issue.project}
value={attributeValue ? attributeValue?.[0]?.value : undefined} value={attributeValue ? attributeValue?.[0]?.value : undefined}
@ -203,9 +190,7 @@ export const PeekOverviewCustomAttributesList: React.FC<Props> = observer(
{attribute.type === "select" && ( {attribute.type === "select" && (
<CustomSelectAttribute <CustomSelectAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => handleAttributeUpdate(attribute.id, val)} onChange={(val) => handleAttributeUpdate(attribute.id, val)}
projectId={issue.project}
value={attributeValue ? attributeValue?.[0]?.value : undefined} value={attributeValue ? attributeValue?.[0]?.value : undefined}
multiple={false} multiple={false}
/> />
@ -213,22 +198,18 @@ export const PeekOverviewCustomAttributesList: React.FC<Props> = observer(
{attribute.type === "text" && ( {attribute.type === "text" && (
<CustomTextAttribute <CustomTextAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => onChange={(val) =>
handleAttributeUpdate(attribute.id, val && val !== "" ? [val] : undefined) handleAttributeUpdate(attribute.id, val && val !== "" ? [val] : undefined)
} }
projectId={issue.project}
value={attributeValue ? attributeValue?.[0].value : undefined} value={attributeValue ? attributeValue?.[0].value : undefined}
/> />
)} )}
{attribute.type === "url" && ( {attribute.type === "url" && (
<CustomUrlAttribute <CustomUrlAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => onChange={(val) =>
handleAttributeUpdate(attribute.id, val && val !== "" ? [val] : undefined) handleAttributeUpdate(attribute.id, val && val !== "" ? [val] : undefined)
} }
projectId={issue.project}
value={attributeValue ? attributeValue?.[0]?.value : undefined} value={attributeValue ? attributeValue?.[0]?.value : undefined}
/> />
)} )}

View File

@ -124,9 +124,7 @@ export const SidebarCustomAttributesList: React.FC<Props> = observer(({ issue, p
{attribute.type === "checkbox" && ( {attribute.type === "checkbox" && (
<CustomCheckboxAttribute <CustomCheckboxAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => handleAttributeUpdate(attribute.id, [`${val}`])} onChange={(val) => handleAttributeUpdate(attribute.id, [`${val}`])}
projectId={issue.project}
value={ value={
attributeValue ? (attributeValue?.[0]?.value === "true" ? true : false) : false attributeValue ? (attributeValue?.[0]?.value === "true" ? true : false) : false
} }
@ -135,40 +133,32 @@ export const SidebarCustomAttributesList: React.FC<Props> = observer(({ issue, p
{attribute.type === "datetime" && ( {attribute.type === "datetime" && (
<CustomDateTimeAttribute <CustomDateTimeAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => { onChange={(val) => {
handleAttributeUpdate(attribute.id, val ? [val.toISOString()] : undefined); handleAttributeUpdate(attribute.id, val ? [val.toISOString()] : undefined);
}} }}
projectId={issue.project}
value={attributeValue ? new Date(attributeValue?.[0]?.value ?? "") : undefined} value={attributeValue ? new Date(attributeValue?.[0]?.value ?? "") : undefined}
/> />
)} )}
{attribute.type === "email" && ( {attribute.type === "email" && (
<CustomEmailAttribute <CustomEmailAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => { onChange={(val) => {
handleAttributeUpdate(attribute.id, val && val !== "" ? [val] : undefined); handleAttributeUpdate(attribute.id, val && val !== "" ? [val] : undefined);
}} }}
projectId={issue.project}
value={attributeValue ? attributeValue?.[0]?.value : undefined} value={attributeValue ? attributeValue?.[0]?.value : undefined}
/> />
)} )}
{attribute.type === "file" && ( {attribute.type === "file" && (
<CustomFileAttribute <CustomFileAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => handleAttributeUpdate(attribute.id, val)} onChange={(val) => handleAttributeUpdate(attribute.id, val)}
projectId={issue.project}
value={attributeValue ? attributeValue?.[0]?.value : undefined} value={attributeValue ? attributeValue?.[0]?.value : undefined}
/> />
)} )}
{attribute.type === "multi_select" && ( {attribute.type === "multi_select" && (
<CustomSelectAttribute <CustomSelectAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => handleAttributeUpdate(attribute.id, val)} onChange={(val) => handleAttributeUpdate(attribute.id, val)}
projectId={issue.project}
value={Array.isArray(attributeValue) ? attributeValue.map((v) => v.value) : []} value={Array.isArray(attributeValue) ? attributeValue.map((v) => v.value) : []}
multiple multiple
/> />
@ -176,11 +166,9 @@ export const SidebarCustomAttributesList: React.FC<Props> = observer(({ issue, p
{attribute.type === "number" && ( {attribute.type === "number" && (
<CustomNumberAttribute <CustomNumberAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => { onChange={(val) => {
handleAttributeUpdate(attribute.id, val ? [val.toString()] : undefined); handleAttributeUpdate(attribute.id, val ? [val.toString()] : undefined);
}} }}
projectId={issue.project}
value={ value={
attributeValue ? parseInt(attributeValue?.[0]?.value ?? "0", 10) : undefined attributeValue ? parseInt(attributeValue?.[0]?.value ?? "0", 10) : undefined
} }
@ -189,7 +177,6 @@ export const SidebarCustomAttributesList: React.FC<Props> = observer(({ issue, p
{attribute.type === "relation" && ( {attribute.type === "relation" && (
<CustomRelationAttribute <CustomRelationAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => handleAttributeUpdate(attribute.id, val)} onChange={(val) => handleAttributeUpdate(attribute.id, val)}
projectId={issue.project} projectId={issue.project}
value={attributeValue ? attributeValue?.[0]?.value : undefined} value={attributeValue ? attributeValue?.[0]?.value : undefined}
@ -198,9 +185,7 @@ export const SidebarCustomAttributesList: React.FC<Props> = observer(({ issue, p
{attribute.type === "select" && ( {attribute.type === "select" && (
<CustomSelectAttribute <CustomSelectAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => handleAttributeUpdate(attribute.id, val)} onChange={(val) => handleAttributeUpdate(attribute.id, val)}
projectId={issue.project}
value={attributeValue ? attributeValue?.[0]?.value : undefined} value={attributeValue ? attributeValue?.[0]?.value : undefined}
multiple={false} multiple={false}
/> />
@ -208,22 +193,18 @@ export const SidebarCustomAttributesList: React.FC<Props> = observer(({ issue, p
{attribute.type === "text" && ( {attribute.type === "text" && (
<CustomTextAttribute <CustomTextAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => onChange={(val) =>
handleAttributeUpdate(attribute.id, val && val !== "" ? [val] : undefined) handleAttributeUpdate(attribute.id, val && val !== "" ? [val] : undefined)
} }
projectId={issue.project}
value={attributeValue ? attributeValue?.[0].value : undefined} value={attributeValue ? attributeValue?.[0].value : undefined}
/> />
)} )}
{attribute.type === "url" && ( {attribute.type === "url" && (
<CustomUrlAttribute <CustomUrlAttribute
attributeDetails={attribute} attributeDetails={attribute}
issueId={issue.id}
onChange={(val) => onChange={(val) =>
handleAttributeUpdate(attribute.id, val && val !== "" ? [val] : undefined) handleAttributeUpdate(attribute.id, val && val !== "" ? [val] : undefined)
} }
projectId={issue.project}
value={attributeValue ? attributeValue?.[0]?.value : undefined} value={attributeValue ? attributeValue?.[0]?.value : undefined}
/> />
)} )}