Skip to content

Commit

Permalink
Merge branch 'develop' into SDP-765_dashboard-tenent-aware
Browse files Browse the repository at this point in the history
  • Loading branch information
ceciliaromao committed Oct 31, 2023
2 parents bf8b707 + 332c04e commit f225120
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
19 changes: 12 additions & 7 deletions src/components/SettingsEnablePaymentCancellation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const SettingsEnablePaymentCancellation = () => {
const { organization } = useRedux("organization");

const [paymentCancellationPeriodDays, setPaymentCancellationPeriodDays] =
useState(0);
useState<number | null>(null);
const [isEditMode, setIsEditMode] = useState(false);

const dispatch: AppDispatch = useDispatch();
Expand Down Expand Up @@ -51,7 +51,10 @@ export const SettingsEnablePaymentCancellation = () => {
event: React.FormEvent<HTMLFormElement>,
) => {
event.preventDefault();
mutateAsync(paymentCancellationPeriodDays);

if (paymentCancellationPeriodDays) {
mutateAsync(paymentCancellationPeriodDays);
}
};

const handlePaymentCancellationReset = (
Expand Down Expand Up @@ -108,13 +111,15 @@ export const SettingsEnablePaymentCancellation = () => {
id="payment-cancellation-period"
label="Payments Cancellation Period (days)"
type="number"
value={paymentCancellationPeriodDays}
onChange={(e) =>
setPaymentCancellationPeriodDays(Number(e.target.value))
}
value={paymentCancellationPeriodDays ?? ""}
onChange={(e) => {
e.target.value !== ""
? setPaymentCancellationPeriodDays(Number(e.target.value))
: setPaymentCancellationPeriodDays(null);
}}
disabled={!isEditMode}
error={
paymentCancellationPeriodDays === 0
paymentCancellationPeriodDays == 0
? "Cancellation period cannot be 0"
: ""
}
Expand Down
17 changes: 12 additions & 5 deletions src/components/SettingsEnableSmsRetry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { getOrgInfoAction } from "store/ducks/organization";
export const SettingsEnableSmsRetry = () => {
const { organization } = useRedux("organization");

const [smsRetryInterval, setSmsRetryInterval] = useState(0);
const [smsRetryInterval, setSmsRetryInterval] = useState<number | null>(null);
const [isEditMode, setIsEditMode] = useState(false);

const dispatch: AppDispatch = useDispatch();
Expand All @@ -46,7 +46,10 @@ export const SettingsEnableSmsRetry = () => {

const handleSmsRetrySubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
mutateAsync(smsRetryInterval);

if (smsRetryInterval) {
mutateAsync(smsRetryInterval);
}
};

const handleSmsRetryReset = (event: React.FormEvent<HTMLFormElement>) => {
Expand Down Expand Up @@ -94,11 +97,15 @@ export const SettingsEnableSmsRetry = () => {
id="sms-retry-interval"
label="SMS retry interval (days)"
type="number"
value={smsRetryInterval}
onChange={(e) => setSmsRetryInterval(Number(e.target.value))}
value={smsRetryInterval ?? ""}
onChange={(e) => {
e.target.value !== ""
? setSmsRetryInterval(Number(e.target.value))
: setSmsRetryInterval(null);
}}
disabled={!isEditMode}
error={
smsRetryInterval === 0 ? "Retry interval cannot be 0" : ""
smsRetryInterval == 0 ? "Retry interval cannot be 0" : ""
}
/>
{!isEditMode ? (
Expand Down

0 comments on commit f225120

Please sign in to comment.