Skip to content

Commit 0bc977d

Browse files
committed
fix: invalidCity issue
1 parent 7f7a099 commit 0bc977d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

frontend/src/pages/Chat/components/CitySelectField.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ interface Props {
3030

3131
export default function CitySelectField({ setMessages }: Props) {
3232
const [city, setCity] = useState<string | null>(null);
33-
let invalidCity: boolean = false;
33+
let [invalidCity, setInvalidCity] = useState<boolean>(false);
3434
const { initChat } = useMessages();
3535

3636
const handleCityChange = async (key: string | null) => {
3737
setCity(key);
3838
const selectedCity = CitySelectOptions[key as keyof typeof CitySelectOptions];
3939
if (selectedCity && selectedCity.state) {
40-
invalidCity = false; // Reset invalid city state
40+
setInvalidCity(false);
4141

4242
try {
4343
await initChat({ city: selectedCity.city, state: selectedCity.state });
@@ -54,10 +54,10 @@ export default function CitySelectField({ setMessages }: Props) {
5454
]);
5555
} catch (error) {
5656
console.error("Error initializing session:", error);
57-
invalidCity = true;
57+
setInvalidCity(true);
5858
}
5959
} else {
60-
invalidCity = true;
60+
setInvalidCity(true);
6161
}
6262
};
6363

0 commit comments

Comments
 (0)