Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

fix: 1st bug hunt of october #100

Merged
merged 5 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/components/molecules/Common/ProjectCreationModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ const ProjectCreationModal: React.FC<Props> = ({
const [openAssets, setOpenAssets] = useState(false);
const formik = useFormik({
initialValues,
onSubmit: useCallback(
async (data: FormValues) => {
await onSubmit?.(data);
},
[onSubmit],
),
onSubmit: async (data: FormValues, { setStatus, resetForm }) => {
HideBa marked this conversation as resolved.
Show resolved Hide resolved
await onSubmit?.(data);
onClose?.();
resetForm({});
setStatus({ success: true });
},
});

const handleClose = useCallback(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ const WorkspaceCreationModal: React.FC<Props> = ({ open, onClose, onSubmit }) =>
const intl = useIntl();
const formik = useFormik({
initialValues,
onSubmit: useCallback(
async (data: FormValues) => {
await onSubmit?.(data);
onClose?.(true);
},
[onClose, onSubmit],
),
onSubmit: async (data: FormValues, { setStatus, resetForm }) => {
await onSubmit?.(data);
onClose?.(true);
resetForm({});
setStatus({ success: true });
},
});

const handleClose = useCallback(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default (
sheetName: string,
schemeId: string | null,
) => Promise<void>,
onClose?: () => void,
) => {
const [url, onUrlChange] = useState<string>();
const [csv, changeCsv] = useState<File>();
Expand Down Expand Up @@ -44,6 +45,14 @@ export default (
setDataType(type);
}, []);

const handleClose = useCallback(() => {
changeCsv(undefined);
changeSheet(undefined);
onUrlChange(undefined);
setDataType(undefined);
onClose?.();
}, [onClose]);

const onSheetSelect = useCallback(sheet => {
changeSheet(sheet);
}, []);
Expand All @@ -70,5 +79,6 @@ export default (
onReturn,
onSheetSelect,
handleImport,
handleClose,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const DatasetModal: React.FC<Props> = ({
onSheetSelect,
handleImport,
handleClick,
} = useHooks(handleDatasetAdd, handleGoogleSheetDatasetAdd);
handleClose,
} = useHooks(handleDatasetAdd, handleGoogleSheetDatasetAdd, onClose);

const primaryButtonText = useMemo(() => {
if (syncLoading) {
Expand All @@ -60,7 +61,7 @@ const DatasetModal: React.FC<Props> = ({
<Modal
title={intl.formatMessage({ defaultMessage: "Add dataset" })}
isVisible={isVisible}
onClose={onClose}
onClose={handleClose}
button1={
<Button
large
Expand All @@ -74,7 +75,7 @@ const DatasetModal: React.FC<Props> = ({
<Button
large
text={intl.formatMessage({ defaultMessage: "Cancel" })}
onClick={onClose}
onClick={handleClose}
buttonType="secondary"
/>
}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type MenuItem = {
};

export type Props = {
button: Button;
button?: Button;
menuItems?: MenuItem[];
location?: {
section?: "left" | "right" | "center";
Expand Down Expand Up @@ -81,6 +81,12 @@ export default function ({
resize: false,
},
},
{
name: "offset",
options: {
offset: [0, 2],
},
},
],
});

Expand Down Expand Up @@ -120,18 +126,17 @@ export default function ({
publishedTheme={publishedTheme}
tabIndex={0}
button={b}
KaWaite marked this conversation as resolved.
Show resolved Hide resolved
onClick={handleClick(b)}
onClick={b && handleClick(b)}
ref={referenceElement}>
{(b.buttonStyle === "icon" || b.buttonStyle === "texticon") && b.buttonIcon && (
<StyledIcon icon={b.buttonIcon} size={25} margin={!!b.buttonTitle} />
{(b?.buttonStyle === "icon" || b?.buttonStyle === "texticon") && b?.buttonIcon && (
<StyledIcon icon={b?.buttonIcon} size={25} margin={!!b?.buttonTitle} />
)}
{b.buttonStyle !== "icon" && b.buttonTitle}
{b?.buttonStyle !== "icon" && b?.buttonTitle}
</Button>
<div
ref={popperElement}
style={{
zIndex: theme.zIndexes.dropDown,
margin: "2.5px auto",
...styles.popper,
}}
{...attributes.popper}>
Expand Down
13 changes: 6 additions & 7 deletions src/components/molecules/Visualizer/Widget/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,24 @@ export type Props = WidgetProps<Property>;
export type Button = ButtonType;
export type MenuItem = MenuItemType;
export type Property = {
default: Button;
default?: Button;
menu?: MenuItem[];
};

const Menu = ({ widget, sceneProperty }: Props): JSX.Element | null => {
const { default: button, menu: menuItems } = (widget?.property as Property | undefined) ?? {};
const { default: button, menu: menuItems } = (widget.property as Property) ?? {};

return button ? (
return (
<Wrapper>
<MenuButton
sceneProperty={sceneProperty}
key={button?.id}
button={button}
location={widget?.layout?.location}
align={widget?.layout?.align}
location={widget.layout?.location}
align={widget.layout?.align}
menuItems={menuItems}
/>
</Wrapper>
) : null;
);
};

const Wrapper = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const Storytelling = ({
openMenu(false);
});

return stories?.length > 0 ? (
return (
<div>
<Menu
publishedTheme={publishedTheme}
Expand Down Expand Up @@ -122,7 +122,8 @@ const Storytelling = ({
size={isExtraSmallWindow ? "xs" : "m"}
weight="bold"
otherProperties={{ userSelect: "none" }}>
{typeof selected === "undefined" ? "-" : selected.index + 1} / {stories.length}
{typeof selected === "undefined" ? "-" : selected.index + 1} /{" "}
KaWaite marked this conversation as resolved.
Show resolved Hide resolved
{stories.length > 0 ? stories.length : "-"}
</Text>
</Current>
<ArrowButton
Expand All @@ -135,7 +136,7 @@ const Storytelling = ({
</ArrowButton>
</Widget>
</div>
) : null;
);
};

const Widget = styled.div<{
Expand Down
6 changes: 5 additions & 1 deletion src/components/organisms/Settings/Workspace/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export default (params: Params) => {
if (!teamId) return;
const result = await addMemberToTeamMutation({
variables: { userId, teamId, role: Role.Reader },
refetchQueries: ["teams"],
});
if (result.errors || !result.data?.addMemberToTeam) {
setNotification({
Expand Down Expand Up @@ -184,7 +185,10 @@ export default (params: Params) => {
const removeMemberFromTeam = useCallback(
async (userId: string) => {
if (!teamId) return;
const result = await removeMemberFromTeamMutation({ variables: { teamId, userId } });
const result = await removeMemberFromTeamMutation({
variables: { teamId, userId },
refetchQueries: ["teams"],
});
if (result.errors || !result.data?.removeMemberFromTeam) {
setNotification({
type: "error",
Expand Down