Skip to content

Commit

Permalink
Merge pull request #246 from aldabil21/#241-defaultprops
Browse files Browse the repository at this point in the history
Remove defaultProps and fix types
  • Loading branch information
aldabil21 authored Aug 22, 2023
2 parents 2a9b8da + 6e354c7 commit 0024c51
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 37 deletions.
18 changes: 10 additions & 8 deletions src/lib/components/common/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CSSProperties, ReactChild } from "react";
import { CSSProperties } from "react";
import PropTypes from "prop-types";
import { Tabs, Tab } from "@mui/material";
import { styled } from "@mui/material/styles";
Expand All @@ -7,7 +7,7 @@ import { Theme } from "@mui/system";
interface TabPanelProps {
value: string | number;
index: string | number;
children: ReactChild;
children: React.ReactNode;
}
function TabPanel(props: TabPanelProps) {
const { children, value, index } = props;
Expand Down Expand Up @@ -82,7 +82,14 @@ interface ButtonTabsProps {
style?: CSSProperties;
}

const ButtonTabs = ({ tabs, variant, tab, setTab, indicator, style }: ButtonTabsProps) => {
const ButtonTabs = ({
tabs,
variant = "scrollable",
tab,
setTab,
indicator = "primary",
style,
}: ButtonTabsProps) => {
return (
<StyledTaps style={style}>
<Tabs
Expand Down Expand Up @@ -116,9 +123,4 @@ const ButtonTabs = ({ tabs, variant, tab, setTab, indicator, style }: ButtonTabs
);
};

ButtonTabs.defaultProps = {
variant: "scrollable",
indicator: "primary",
};

export { ButtonTabs };
7 changes: 2 additions & 5 deletions src/lib/components/common/WithResources.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ReactChild, useMemo } from "react";
import { useMemo } from "react";
import { DefaultRecourse } from "../../types";
import { ResourceHeader } from "./ResourceHeader";
import { ButtonTabProps, ButtonTabs } from "./Tabs";
import useStore from "../../hooks/useStore";

interface WithResourcesProps {
renderChildren(resource: DefaultRecourse): ReactChild;
renderChildren(resource: DefaultRecourse): React.ReactNode;
}
const WithResources = ({ renderChildren }: WithResourcesProps) => {
const { resourceViewMode } = useStore();
Expand Down Expand Up @@ -65,8 +65,5 @@ const ResourcesTabTables = ({ renderChildren }: WithResourcesProps) => {
<ButtonTabs tabs={tabs} tab={currentTabSafeId} setTab={setTab} style={{ display: "grid" }} />
);
};
WithResources.defaultProps = {
span: 1,
};

export { WithResources };
9 changes: 2 additions & 7 deletions src/lib/components/events/EventItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import useDragAttributes from "../../hooks/useDragAttributes";

interface EventItemProps {
event: ProcessedEvent;
multiday: boolean;
multiday?: boolean;
hasPrev?: boolean;
hasNext?: boolean;
showdate?: boolean;
}

const EventItem = ({ event, multiday, hasPrev, hasNext, showdate }: EventItemProps) => {
const EventItem = ({ event, multiday, hasPrev, hasNext, showdate = true }: EventItemProps) => {
const {
triggerDialog,
onDelete,
Expand Down Expand Up @@ -298,9 +298,4 @@ const EventItem = ({ event, multiday, hasPrev, hasNext, showdate }: EventItemPro
);
};

EventItem.defaultProps = {
multiday: false,
showdate: true,
};

export default EventItem;
10 changes: 3 additions & 7 deletions src/lib/components/inputs/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DateTimePicker } from "@mui/x-date-pickers/DateTimePicker";
import useStore from "../../hooks/useStore";

interface EditorDatePickerProps {
type: "date" | "datetime";
type?: "date" | "datetime";
label?: string;
variant?: "standard" | "filled" | "outlined";
value: Date | string;
Expand All @@ -18,12 +18,12 @@ interface EditorDatePickerProps {
}

const EditorDatePicker = ({
type,
type = "datetime",
value,
label,
name,
onChange,
variant,
variant = "outlined",
error,
errMsg,
touched,
Expand Down Expand Up @@ -90,8 +90,4 @@ const EditorDatePicker = ({
);
};

EditorDatePicker.defaultProps = {
type: "datetime",
variant: "outlined",
};
export { EditorDatePicker };
5 changes: 1 addition & 4 deletions src/lib/components/inputs/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface EditorInputProps {
}

const EditorInput = ({
variant,
variant = "outlined",
label,
placeholder,
value,
Expand Down Expand Up @@ -107,7 +107,4 @@ const EditorInput = ({
);
};

EditorInput.defaultProps = {
variant: "outlined",
};
export { EditorInput };
6 changes: 1 addition & 5 deletions src/lib/components/inputs/SelectInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const EditorSelect = ({
label,
disabled,
touched,
variant,
variant = "outlined",
loading,
multiple,
placeholder,
Expand Down Expand Up @@ -159,8 +159,4 @@ const EditorSelect = ({
);
};

EditorSelect.defaultProps = {
variant: "outlined",
};

export { EditorSelect };
2 changes: 1 addition & 1 deletion src/lib/views/Day.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ const Day = () => {
);
};

return resources.length ? <WithResources span={2} renderChildren={renderTable} /> : renderTable();
return resources.length ? <WithResources renderChildren={renderTable} /> : renderTable();
};

export { Day };

0 comments on commit 0024c51

Please sign in to comment.