Fixed build issues

This commit is contained in:
2023-12-22 09:38:05 -05:00
parent bd6d5e03d3
commit 4441d99f25
9 changed files with 41 additions and 40 deletions

View File

@@ -44,8 +44,8 @@ export default function AirportTablePanel({ setAirport }: { setAirport: (airport
<Table.Td>{airport.iso_country}</Table.Td>
<Table.Td>{airport.iso_region}</Table.Td>
<Table.Td>{airport.municipality}</Table.Td>
<Table.Td>{airport.iata_code}</Table.Td>
<Table.Td>{airport.local_code}</Table.Td>
<Table.Td>{airport.iata}</Table.Td>
<Table.Td>{airport.local}</Table.Td>
</Table.Tr>
))

View File

@@ -13,10 +13,14 @@ export default function CreateAirportPanel() {
iso_country: '',
iso_region: '',
municipality: '',
iata_code: '',
local_code: '',
iata: '',
local: '',
latitude: 0,
longitude: 0,
has_tower: false,
has_beacon: false,
runways: [],
frequencies: [],
}
});
@@ -86,12 +90,12 @@ export default function CreateAirportPanel() {
<TextInput
label='IATA Code'
placeholder='MNZ'
{...form.getInputProps('iata_code')}
{...form.getInputProps('iata')}
/>
<TextInput
label='Local Code'
placeholder='HEF'
{...form.getInputProps('local_code')}
{...form.getInputProps('local')}
/>
</Group>
<Group>

View File

@@ -14,10 +14,14 @@ export default function UpdateAirportModal({ airport, setAirport }: { airport: A
iso_country: airport?.iso_country || '',
iso_region: airport?.iso_region || '',
municipality: airport?.municipality || '',
iata_code: airport?.iata_code || '',
local_code: airport?.local_code || '',
iata: airport?.iata || '',
local: airport?.local || '',
latitude: airport?.latitude || 0,
longitude: airport?.longitude || 0,
has_tower: airport?.has_tower || false,
has_beacon: airport?.has_beacon || false,
runways: airport?.runways || [],
frequencies: airport?.frequencies || [],
}
});
@@ -97,13 +101,13 @@ export default function UpdateAirportModal({ airport, setAirport }: { airport: A
required
label='IATA Code'
placeholder='HEF'
{...form.getInputProps('iata_code')}
{...form.getInputProps('iata')}
/>
<TextInput
required
label='Local Code'
placeholder='HEF'
{...form.getInputProps('local_code')}
{...form.getInputProps('local')}
/>
</Group>
<Group>

View File

@@ -9,6 +9,7 @@ import { getFavorites, getPicture } from "@/api/users";
import Cookies from "js-cookie";
import { favoritesState, profilePictureState } from "@/state/user";
import { notifications } from "@mantine/notifications";
import { usePathname, useRouter } from "next/navigation";
export default function Loader({ children }: { children: any }) {
const [loading, setLoading] = useState(true);
@@ -16,6 +17,8 @@ export default function Loader({ children }: { children: any }) {
const [refreshId, setRefreshId] = useRecoilState(refreshIdState);
const [_, setFavorites] = useRecoilState(favoritesState);
const [profilePicture, setProfilePicture] = useRecoilState(profilePictureState);
const path = usePathname();
const router = useRouter();
useEffect(() => {
setLoading(true);
@@ -25,6 +28,19 @@ export default function Loader({ children }: { children: any }) {
setLoading(false);
}, [user]);
useEffect(() => {
const p = path.split('/');
console.log(p[1], user);
if (p.length > 1) {
if (p[1] == 'admin' && user?.role != 'admin') {
router.push('/');
} else if (p[1] == 'profile' && !user) {
router.push('/');
}
}
}, [path]);
function refreshUser() {
refresh().then((response) => {
if (response) {