fixing the size on reset
This commit is contained in:
@@ -10,8 +10,9 @@ const QRForm: React.FC = () => {
|
|||||||
const { state, dispatch } = useQrStore();
|
const { state, dispatch } = useQrStore();
|
||||||
const { text, size, loading } = state;
|
const { text, size, loading } = state;
|
||||||
|
|
||||||
const callingApi = async (overrideText?: string) => {
|
const callingApi = async (overrideText?: string, overrideSize?: number) => {
|
||||||
const currentText = overrideText ?? text;
|
const currentText = overrideText ?? text;
|
||||||
|
const currentSize = overrideSize ?? size;
|
||||||
dispatch({ type: 'setError', payload: null });
|
dispatch({ type: 'setError', payload: null });
|
||||||
dispatch({ type: 'setImageUrl', payload: null });
|
dispatch({ type: 'setImageUrl', payload: null });
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@ const QRForm: React.FC = () => {
|
|||||||
|
|
||||||
dispatch({ type: 'setLoading', payload: true });
|
dispatch({ type: 'setLoading', payload: true });
|
||||||
try {
|
try {
|
||||||
const payload = { text: currentText, size };
|
const payload = { text: currentText, size: currentSize };
|
||||||
const res: GenerateResult = await generateQr(payload);
|
const res: GenerateResult = await generateQr(payload);
|
||||||
const blobType = { type: res.mime };
|
const blobType = { type: res.mime };
|
||||||
const blob = new Blob([res.data], blobType);
|
const blob = new Blob([res.data], blobType);
|
||||||
@@ -56,7 +57,7 @@ const QRForm: React.FC = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (callApiOnReset) {
|
if (callApiOnReset) {
|
||||||
callingApi(initialState.text);
|
callingApi(initialState.text, initialState.size);
|
||||||
setCallApiOnReset(false);
|
setCallApiOnReset(false);
|
||||||
}
|
}
|
||||||
}, [callApiOnReset, callingApi]);
|
}, [callApiOnReset, callingApi]);
|
||||||
|
|||||||
Reference in New Issue
Block a user