Skip to content

Commit 4042cc8

Browse files
committed
make hardware mobile responsive
1 parent 80871c9 commit 4042cc8

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

client/src/components/home/HomeContainer.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22
import { apiUrl, ErrorScreen, LoadingScreen, Service, useAuth } from "@hex-labs/core";
3-
import { Flex } from "@chakra-ui/react";
3+
import { Flex, Stack } from "@chakra-ui/react";
44
import { Navigate } from "react-router-dom";
55
import useAxios from "axios-hooks";
66

@@ -27,10 +27,10 @@ const HomeContainer: React.FC = props => {
2727
}
2828

2929
return (
30-
<Flex dir="row" gap={6} p="8" justify="space-around">
30+
<Stack direction={{ base: "column", sm: "row" }} gap={6} p="8" justify="space-around">
3131
<NewHardwareList />
3232
{user && <RequestedList requests={data} />}
33-
</Flex>
33+
</Stack>
3434
);
3535
};
3636

client/src/components/home/NewHardwareList.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ const NewHardwareList = () => {
5454
);
5555

5656
return (
57-
<Flex w="45%" flexDir="column">
57+
<Flex flexDir="column">
5858
<Heading mb={4}>Inventory</Heading>
59-
<Flex gap="10px" flexDir="column">
59+
<Flex gap="10px" flexDir={{ base: "column", sm: "row" }}>
6060
<Flex flexDir="row" gap={2}>
6161
{profile.roles.admin && (
6262
<Link to="/admin/categories/new">

client/src/components/home/RequestedList.tsx

+10-7
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ const RequestCard = ({ r, statuses, requestDeleteMutation }: any) => {
5555
};
5656

5757
const RequestedList = ({ requests }: RequestedListProps) => {
58-
const [{ data: requestData, loading, error}, requestRefetch] = useAxios(apiUrl(Service.HARDWARE, "/hardware-requests"));
59-
const [{ data: itemData, loading: itemLoading, error: itemError}, itemRefetch] = useAxios(apiUrl(Service.HARDWARE, "/items"));
58+
const [{ data: requestData, loading, error }, requestRefetch] = useAxios(
59+
apiUrl(Service.HARDWARE, "/hardware-requests")
60+
);
61+
const [{ data: itemData, loading: itemLoading, error: itemError }, itemRefetch] = useAxios(
62+
apiUrl(Service.HARDWARE, "/items")
63+
);
6064
const [userRequests, setUserRequests] = useState(requests);
6165
const toast = useToast();
6266
if (loading) {
@@ -77,11 +81,10 @@ const RequestedList = ({ requests }: RequestedListProps) => {
7781
});
7882
} catch (e: any) {
7983
handleAxiosError(e);
80-
}
81-
finally {
84+
} finally {
8285
requestRefetch();
8386
itemRefetch();
84-
setUserRequests(requestData!.data as Request[])
87+
setUserRequests(requestData!.data as Request[]);
8588
}
8689
};
8790
const statuses = (status: RequestStatus): JSX.Element => {
@@ -163,7 +166,7 @@ const RequestedList = ({ requests }: RequestedListProps) => {
163166
};
164167

165168
return (
166-
<Box w="45%">
169+
<Box>
167170
<Heading mb="4">My Requests</Heading>
168171
<Flex
169172
borderRadius="4px"
@@ -200,4 +203,4 @@ const RequestedList = ({ requests }: RequestedListProps) => {
200203
);
201204
};
202205

203-
export default RequestedList;
206+
export default RequestedList;

client/src/components/inventory/HardwareItem.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ const HardwareItem = ({ item, requestsEnabled, preview, outOfStock }: HardwareIt
151151
handleRequestAdd(newRequest);
152152
}}
153153
>
154-
{outOfStock ? "Out of stock" : `Request ${requestedNum} items`}
154+
{outOfStock ? "Out of stock" : `Request ${requestedNum}`}
155155
</Button>
156156
</Flex>
157157
</Flex>

0 commit comments

Comments
 (0)