Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
feat(user-detail-editor): only lookup postal codes with length 4
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianAndersen committed Jul 7, 2024
1 parent 5def370 commit adf6546
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/components/user/user-detail-editor/UserDetailEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
IconButton,
InputAdornment,
ListItem,
Skeleton,
Stack,
Tooltip,
} from "@mui/material";
Expand Down Expand Up @@ -72,7 +71,6 @@ const UserDetailEditor = ({
const [postalCity, setPostalCity] = useState<string | null>(
userDetails?.postCity ?? null,
);
const [waitingForPostalCity, setWaitingForPostalCity] = useState(false);
const router = useRouter();
const searchParams = useSearchParams();

Expand Down Expand Up @@ -155,10 +153,9 @@ const UserDetailEditor = ({

async function onPostalCodeChange(event: { target: { value: string } }) {
setPostalCity(null);
if (event.target.value.length === 0) {
if (event.target.value.length !== 4) {
return;
}
setWaitingForPostalCity(true);
const response = await BlFetcher.post<
[
{
Expand All @@ -169,7 +166,6 @@ const UserDetailEditor = ({
`${BL_CONFIG.collection.delivery}/${BL_CONFIG.delivery.postalCodeLookup.operation}`,
{ postalCode: event.target.value },
);
setWaitingForPostalCity(false);

if (!response[0].postalCity) {
setPostalCity(null);
Expand Down Expand Up @@ -393,13 +389,6 @@ const UserDetailEditor = ({
color="gray"
data-testid="postal-city-preview"
>
{waitingForPostalCity && (
<Skeleton
variant="rectangular"
width={50}
height="1rem"
/>
)}
{postalCity}
</Typography>
</Box>
Expand Down

0 comments on commit adf6546

Please sign in to comment.