Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for time in dateinput component #8504

Merged
merged 28 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
909d821
Added support for time in dateinput
shivankacker Sep 8, 2024
d8d89f1
made responsive
shivankacker Sep 8, 2024
e62e655
fixed responsiveness and updated tests
shivankacker Sep 12, 2024
e9ee7c3
Merge branch 'develop' of https://github.com/ohcnetwork/care_fe into …
shivankacker Sep 12, 2024
248afe9
Fixed scroll behaviour
shivankacker Sep 12, 2024
435484d
minor test fix
shivankacker Sep 12, 2024
060b271
Updated placeholder, changed layout of time picker on mobile, and mad…
shivankacker Sep 13, 2024
3f52db1
Made fool proof
shivankacker Sep 13, 2024
e54004e
Merge branch 'develop' of https://github.com/ohcnetwork/care_fe into …
shivankacker Sep 17, 2024
e88adba
fix merge conflicts
shivankacker Sep 19, 2024
b46694d
stashing
shivankacker Sep 20, 2024
1f0d1f7
fix merge conflicts
shivankacker Oct 4, 2024
86663d8
fix merge conflicts
shivankacker Oct 9, 2024
16aa346
updated UI to not have the user add slashes
shivankacker Oct 10, 2024
c3162fb
updated tests
shivankacker Oct 11, 2024
e5480f3
Merge branch 'develop' of https://github.com/ohcnetwork/care_fe into …
shivankacker Oct 11, 2024
79cdb31
fixed tests
shivankacker Oct 12, 2024
1bd3e32
Merge branch 'develop' of https://github.com/ohcnetwork/care_fe into …
shivankacker Oct 14, 2024
149e6b6
fix responsiveness
shivankacker Oct 14, 2024
4b7adcc
fix merge conflicts
shivankacker Oct 17, 2024
5e69cf0
fixed bugs
shivankacker Oct 17, 2024
fe68ada
fixed merge conflicts and updated tests
shivankacker Oct 22, 2024
e5950f5
little mistake
shivankacker Oct 22, 2024
ceaf273
autoclose on first date input
shivankacker Oct 23, 2024
f47f372
fix merge conflicts
shivankacker Oct 24, 2024
2f9bd97
fix merge conflicts
shivankacker Oct 24, 2024
d5f0683
cleanup
shivankacker Oct 25, 2024
c3c1727
fixed merge conflicts
shivankacker Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated placeholder, changed layout of time picker on mobile, and mad…
…e some fixes for very edge cases
  • Loading branch information
shivankacker committed Sep 13, 2024
commit 060b27111f46e29e01431c983cdd3878dd4dc288
18 changes: 14 additions & 4 deletions src/Components/Common/DateInputV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export type DatePickerPosition =
| "LEFT"
| "RIGHT"
| "CENTER"
| "LEFT-CENTER"
| "RIGHT-CENTER"
| "TOP-LEFT"
| "TOP-RIGHT"
| "TOP-CENTER";
Expand All @@ -32,6 +34,7 @@ interface Props {
isOpen?: boolean;
setIsOpen?: (isOpen: boolean) => void;
time?: boolean;
popOverClassName?: string;
}

const DAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
Expand All @@ -52,6 +55,7 @@ const DateInputV2: React.FC<Props> = ({
setIsOpen,
time,
isOpen,
popOverClassName,
}) => {
const [dayCount, setDayCount] = useState<Array<number>>([]);
const [blankDays, setBlankDays] = useState<Array<number>>([]);
Expand Down Expand Up @@ -290,6 +294,7 @@ const DateInputV2: React.FC<Props> = ({
}, [isOpen]);

const dateFormat = `DD/MM/YYYY${time ? " hh:mm a" : ""}`;
const placeHolder = dateFormat.replace("a", "am/pm");

const getDisplayValue = (date: Date) => {
return dayjs(date).format(dateFormat);
Expand All @@ -299,7 +304,11 @@ const DateInputV2: React.FC<Props> = ({
switch (position) {
case "LEFT":
return "left-0";
case "LEFT-CENTER":
return "right-0 transform md:translate-x-1/2";
case "RIGHT":
return "right-0";
case "RIGHT-CENTER":
return "right-0 transform md:translate-x-1/2";
case "CENTER":
return "transform -translate-x-1/2";
Expand Down Expand Up @@ -351,8 +360,9 @@ const DateInputV2: React.FC<Props> = ({
<PopoverPanel
static
className={classNames(
`cui-dropdown-base absolute my-0.5 ${time ? "w-full md:w-[400px]" : "w-72"} divide-y-0 rounded p-4`,
`cui-dropdown-base absolute my-0.5 ${time ? "max-h-[80vh] w-full md:h-auto md:w-[400px]" : "w-72"} divide-y-0 rounded p-4`,
getPosition(),
popOverClassName,
)}
>
<div
Expand All @@ -374,7 +384,7 @@ const DateInputV2: React.FC<Props> = ({
: ""
}
autoFocus
placeholder={dateFormat}
placeholder={placeHolder}
onChange={(e) => {
const nvalue = dayjs(
e.target.value,
Expand All @@ -390,8 +400,8 @@ const DateInputV2: React.FC<Props> = ({
}}
onBlur={() => setEditingText(null)}
/>
<div className="flex flex-row items-stretch gap-4">
<div className="flex w-full flex-col items-center justify-between">
<div className="flex flex-col items-center gap-4 px-4 md:flex-row md:px-0">
<div className="flex flex-1 flex-col items-center justify-between">
<div className="flex">
<button
type="button"
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Common/DateRangeInputV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const DateRangeInputV2 = ({ value, onChange, ...props }: Props) => {
}}
min={props.min}
max={end || props.max}
position="RIGHT"
position="RIGHT-CENTER"
placeholder="Start date"
disabled={props.disabled}
time={props.time}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Facility/AssetCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ const AssetCreate = (props: AssetProps) => {
label={t("last_serviced_on")}
name="last_serviced_on"
className="mt-2"
position="RIGHT"
position="TOP-RIGHT"
disableFuture
value={last_serviced_on && new Date(last_serviced_on)}
onChange={(date) => {
Expand Down
1 change: 1 addition & 0 deletions src/Components/Facility/Consultations/Beds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ const Beds = (props: BedsProps) => {
max={new Date()}
error=""
errorClassName="hidden"
position="TOP-RIGHT"
time
/>
<div>
Expand Down
2 changes: 2 additions & 0 deletions src/Components/Facility/DischargeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ const DischargeModal = ({
value={
dischargeOrDeathTime ? new Date(dischargeOrDeathTime) : new Date()
}
position="TOP-RIGHT"
popOverClassName="max-h-[50vh]"
onChange={(e) => {
const updates: Record<string, string | undefined> = {
discharge_date: undefined,
Expand Down
2 changes: 2 additions & 0 deletions src/Components/Form/FormFields/DateFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Props = FormFieldBaseProps<Date> & {
disableFuture?: boolean;
disablePast?: boolean;
time?: boolean;
popOverClassName?: string;
};

/**
Expand Down Expand Up @@ -50,6 +51,7 @@ const DateFormField = (props: Props) => {
position={props.position ?? "RIGHT"}
placeholder={props.placeholder}
time={props.time}
popOverClassName={props.popOverClassName}
/>
</FormField>
);
Expand Down
1 change: 1 addition & 0 deletions src/Components/Medicine/AdministerMedicine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export default function AdministerMedicine({ prescription, ...props }: Props) {
min={new Date(prescription.created_date)}
max={new Date()}
errorClassName="hidden"
position="TOP-RIGHT"
time
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/Components/Medicine/MedicineAdministration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export default function MedicineAdministration(props: Props) {
disabled={!shouldAdminister[index] || !isCustomTime[index]}
min={new Date(obj.created_date)}
max={new Date()}
position="TOP-RIGHT"
errorClassName="hidden"
time
/>
Expand Down
2 changes: 1 addition & 1 deletion src/Locale/en/Common.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,5 @@
"delete_item": "Delete {{name}}",
"unsupported_browser": "Unsupported Browser",
"unsupported_browser_description": "Your browser ({{name}} version {{version}}) is not supported. Please update your browser to the latest version or switch to a supported browser for the best experience."

}
Loading