Skip to content

Commit

Permalink
fix(portal): push activity log UI issues (#285)
Browse files Browse the repository at this point in the history
* fix(portal): Push activity log UI issues

* fix(portal): remove unused import
  • Loading branch information
KsiBart authored Dec 9, 2024
1 parent b0f45a8 commit 13c256f
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DatePicker, Flex, Form, Modal, Radio, Spin } from "antd";
import styles from "./index.module.scss";
import { useCallback } from "react";
import { useCallback, useMemo } from "react";
import { capitalize } from 'lodash';
import dayjs from 'dayjs';
import { useGetProductEnvActivitiesMutation } from '@/hooks/product';
Expand Down Expand Up @@ -30,7 +30,7 @@ const PushHistoryModal = ({
const [form] = Form.useForm();
const { currentProduct } = useAppStore();

const { data: responseData, mutateAsync: getProductEnvActivities, isPending, isSuccess } = useGetProductEnvActivitiesMutation();
const { data: responseData, mutateAsync: getProductEnvActivities, isPending } = useGetProductEnvActivitiesMutation();
const { mutateAsync: createPushActivityLog } = usePostPushActivityLog();

const handleOK = () => {
Expand Down Expand Up @@ -76,14 +76,22 @@ const PushHistoryModal = ({
[]
);

const isFormValid = useMemo(() => {
const { envId, requestTime } = form.getFieldsValue();
return !!(responseData && responseData.data.total > 0 && envId && requestTime)
}, [responseData, form])

return (
<Modal
open={isOpen}
onCancel={onClose}
onOk={handleOK}
title="Push log"
className={styles.modal}
okButtonProps={{ disabled: !isSuccess, "data-testid": "pushLog-btn" }}
okButtonProps={{
disabled: !isFormValid,
"data-testid": "pushLog-btn"
}}
>
<Form
form={form}
Expand All @@ -108,12 +116,12 @@ const PushHistoryModal = ({
required
className={styles.rangePicker}
>
<RangePicker placeholder={["Select time", "Select time"]} disabledDate={disabled7DaysDate} />
<RangePicker placeholder={["Select time", "Select time"]} disabledDate={disabled7DaysDate} maxDate={dayjs().endOf('day')} />
</Form.Item>

<Flex justify={isPending ? "center" : "start"}>
<Spin spinning={isPending}>
{responseData?.data?.total && <Flex vertical className={styles.numberContainer} gap={5}>
{responseData?.data && <Flex vertical className={styles.numberContainer} gap={5}>
<div>
Number of activity logs filtered
</div>
Expand All @@ -124,8 +132,6 @@ const PushHistoryModal = ({
}
</Spin>
</Flex>


</Form>
</Modal>
);
Expand Down

0 comments on commit 13c256f

Please sign in to comment.