-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Target date on create & edit, sort by target, update how name &…
… target is shown
- Loading branch information
Showing
9 changed files
with
218 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
apps/homepage/src/components/DatePicker/datePickerReactSelect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { useCallback } from "react"; | ||
import ReactCalendar from "react-calendar"; | ||
import { | ||
GroupBase, | ||
MenuListProps, | ||
Options, | ||
Props, | ||
SelectComponentsConfig, | ||
StylesConfig, | ||
} from "react-select"; | ||
|
||
const MenuList = (props: MenuListProps<any, any>) => { | ||
const onChange = useCallback( | ||
(val: Date) => { | ||
if (props.selectProps.onChange) { | ||
props.selectProps?.onChange(val, { | ||
// This doesn't do anything but the function wants it | ||
action: "select-option", | ||
option: { value: val, label: "" }, | ||
name: "", | ||
}); | ||
if (props.selectProps.onMenuClose) { | ||
props.selectProps.onMenuClose(); | ||
} | ||
} | ||
}, | ||
[props.selectProps], | ||
); | ||
|
||
return ( | ||
<ReactCalendar | ||
value={props.selectProps.value?.value} | ||
onChange={(val) => onChange(val as Date)} | ||
/> | ||
); | ||
}; | ||
|
||
export const ReactSelectDateComponents: SelectComponentsConfig< | ||
Options<any>, | ||
true, | ||
any | ||
> = { MenuList }; | ||
|
||
export const ReactSelectDateStyle: Partial< | ||
StylesConfig<any, any, GroupBase<any>> | ||
> = { | ||
container: (provided) => ({ ...provided, width: "100%" }), | ||
menu: (provided) => ({ ...provided, width: 350, right: 0 }), | ||
}; | ||
|
||
export const ReactSelectDateProps: Props<any, any> = { | ||
styles: ReactSelectDateStyle, | ||
components: ReactSelectDateComponents, | ||
menuPosition: "fixed", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.