diff --git a/web/components/custom-attributes/attribute-display/date-time.tsx b/web/components/custom-attributes/attribute-display/date-time.tsx index 8ed9c44f1..f47527a7d 100644 --- a/web/components/custom-attributes/attribute-display/date-time.tsx +++ b/web/components/custom-attributes/attribute-display/date-time.tsx @@ -1,44 +1,41 @@ -import { useState } from "react"; - +// react-datepicker +import ReactDatePicker from "react-datepicker"; // types import { Props } from "./types"; -import { renderDateFormat } from "helpers/date-time.helper"; + +const DATE_FORMATS: { [key: string]: string } = { + "MM-DD-YYYY": "MM-dd-yyyy", + "DD-MM-YYYY": "dd-MM-yyyy", + "YYYY-MM-DD": "yyyy-MM-dd", +}; + +const TIME_FORMATS: { [key: string]: string } = { + "12": "hh:mm aa", + "24": "HH:mm", +}; export const CustomDateTimeAttribute: React.FC = ({ + attributeDetails, onChange, value, -}) => { - const [isEditing, setIsEditing] = useState(false); - - const handleUpdateDateTime = (val: string) => { - setIsEditing(false); - - onChange(new Date(val)); - }; - - return ( -
- {!isEditing && - (value ? ( -
setIsEditing(true)} - > - {renderDateFormat(value)} -
- ) : ( -
setIsEditing(true)}> - Empty -
- ))} - {isEditing && ( - handleUpdateDateTime(e.target.value)} - /> - )} -
- ); -}; +}) => ( +
+ +
+); diff --git a/web/components/custom-attributes/attribute-display/email.tsx b/web/components/custom-attributes/attribute-display/email.tsx index 354638ae2..44e8605db 100644 --- a/web/components/custom-attributes/attribute-display/email.tsx +++ b/web/components/custom-attributes/attribute-display/email.tsx @@ -45,11 +45,8 @@ export const CustomEmailAttribute: React.FC {!isEditing && ( -
setIsEditing(true)} - > - {value && value !== "" ? value : `Enter ${attributeDetails.display_name}`} +
setIsEditing(true)}> + {value && value !== "" ? value : "Empty"}
)} {isEditing && ( diff --git a/web/components/custom-attributes/attribute-display/file.tsx b/web/components/custom-attributes/attribute-display/file.tsx index 807f4a0ed..04a736748 100644 --- a/web/components/custom-attributes/attribute-display/file.tsx +++ b/web/components/custom-attributes/attribute-display/file.tsx @@ -107,21 +107,19 @@ export const CustomFileAttribute: React.FC - - - {isDragActive ? ( -

Drop here...

- ) : fileError ? ( -

{fileError}

- ) : isUploading ? ( -

Uploading...

- ) : ( -

Upload {value && value !== "" ? "new " : ""}file

- )} + + + {isDragActive + ? "Drop here..." + : fileError + ? fileError + : isUploading + ? "Uploading..." + : `Upload ${value && value !== "" ? "new " : ""}file`}
diff --git a/web/components/custom-attributes/attribute-display/number.tsx b/web/components/custom-attributes/attribute-display/number.tsx index 006a75ae7..25d87ab3e 100644 --- a/web/components/custom-attributes/attribute-display/number.tsx +++ b/web/components/custom-attributes/attribute-display/number.tsx @@ -49,7 +49,7 @@ export const CustomNumberAttribute: React.FC {!isEditing && ( -
setIsEditing(true)}> +
setIsEditing(true)}> {value ? ( <> {extraSettings?.representation === "bar" ? ( @@ -79,12 +79,12 @@ export const CustomNumberAttribute: React.FC
) : ( - {value} + {value} )} ) : (
setIsEditing(true)} > {value ?? `Enter ${attributeDetails.display_name}`} diff --git a/web/components/custom-attributes/attribute-display/text.tsx b/web/components/custom-attributes/attribute-display/text.tsx index da4999f93..78a7605fe 100644 --- a/web/components/custom-attributes/attribute-display/text.tsx +++ b/web/components/custom-attributes/attribute-display/text.tsx @@ -45,10 +45,7 @@ export const CustomTextAttribute: React.FC {!isEditing && ( -
setIsEditing(true)} - > +
setIsEditing(true)}> {value && value !== "" ? value : `Enter ${attributeDetails.display_name}`}
)} diff --git a/web/components/custom-attributes/attribute-display/url.tsx b/web/components/custom-attributes/attribute-display/url.tsx index 6e34fe7d4..381fa2da8 100644 --- a/web/components/custom-attributes/attribute-display/url.tsx +++ b/web/components/custom-attributes/attribute-display/url.tsx @@ -43,10 +43,7 @@ export const CustomUrlAttribute: React.FC return (
{!isEditing && ( -
setIsEditing(true)} - > +
setIsEditing(true)}> {value && value !== "" ? value : `Enter ${attributeDetails.display_name}`}
)} diff --git a/web/components/custom-attributes/attributes-list/sidebar-custom-attributes-list.tsx b/web/components/custom-attributes/attributes-list/sidebar-custom-attributes-list.tsx index daf7877ec..1d2e8b714 100644 --- a/web/components/custom-attributes/attributes-list/sidebar-custom-attributes-list.tsx +++ b/web/components/custom-attributes/attributes-list/sidebar-custom-attributes-list.tsx @@ -120,7 +120,7 @@ export const SidebarCustomAttributesList: React.FC = observer(({ issue }) handleAttributeUpdate(attribute.id, [val])} + onChange={(val: Date) => handleAttributeUpdate(attribute.id, [val.toISOString()])} projectId={issue.project} value={attributeValue ? new Date(attributeValue?.[0]?.value ?? "") : undefined} /> diff --git a/web/constants/custom-attributes.ts b/web/constants/custom-attributes.ts index 12a7d56dc..dee79752e 100644 --- a/web/constants/custom-attributes.ts +++ b/web/constants/custom-attributes.ts @@ -46,6 +46,8 @@ export const CUSTOM_ATTRIBUTES_LIST: { display_name: "", extra_settings: { date_format: "DD-MM-YYYY", + hide_date: false, + hide_time: false, time_format: "12", }, is_required: false, diff --git a/web/styles/react-datepicker.css b/web/styles/react-datepicker.css index 60341f2bf..00f230144 100644 --- a/web/styles/react-datepicker.css +++ b/web/styles/react-datepicker.css @@ -29,7 +29,8 @@ .react-datepicker { font-family: "Inter" !important; background-color: rgba(var(--color-background-100)) !important; - border: 1px solid rgba(var(--color-background-80)) !important; + border: 1px solid rgba(var(--color-border-200)) !important; + box-shadow: var(--color-shadow-xs); } .react-datepicker__month-container {