Skip to content

Commit

Permalink
Update things
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsoniv committed Dec 18, 2023
1 parent a6b4e8a commit 404b5d5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 25 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
VITE_APP_CONFIG_BASE=/buyer-application
VITE_APP_ORDERCLOUD_BASE_API_URL=https://sandboxapi.ordercloud.io
VITE_APP_ORDERCLOUD_CLIENT_ID=40252024-3CC9-4430-ACC5-03F8E9E4ABD7
VITE_APP_ORDERCLOUD_SCOPE=Shopper,MeAdmin,MeAddressAdmin,MeCreditCardAdmin,MeSubscriptionAdmin,OrderReader
Expand Down
4 changes: 3 additions & 1 deletion src/App.router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import App from "./App";
import Profile from "./features/domains/ordercloud/components/Profile";
import Orders from "./features/domains/ordercloud/components/Orders";

const basename = import.meta.env.VITE_APP_CONFIG_BASE;

const router = createBrowserRouter([
{
path: "/",
Expand All @@ -19,7 +21,7 @@ const router = createBrowserRouter([
}
],
},
], {basename: '/basic-application'});
], {basename});

const AppRouter: FC = () => {
return <RouterProvider router={router} />;
Expand Down
4 changes: 0 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ function App() {
<Text fontWeight="normal" fontSize="sm">© Sitcore Inc. 2024</Text>
</GridItem>
</Grid>
{/* <TopNav />
<Profile />
<AuthToggle />
<Orders direction="Incoming" /> */}
<GlobalLoadingIndicator/>
</OrderCloudProvider>
);
Expand Down
32 changes: 14 additions & 18 deletions src/features/domains/ordercloud/components/Profile.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
import { FC, useMemo } from "react";
import { FC } from "react";
import { useCurrentUser, useMutateCurrentUser } from "../hooks/currentUser";
import { Button, Container, Heading } from "@chakra-ui/react";
import { Box, Button, Center, Container, Heading, Skeleton } from "@chakra-ui/react";
import useOrderCloudContext from "../hooks/useOrderCloudContext";
import { WarningIcon } from "@chakra-ui/icons";

const Profile: FC = () => {
const {isLoggedIn} = useOrderCloudContext();
const { data: user, status, error } = useCurrentUser();
const { data: user, isError, isPending:isLoading } = useCurrentUser();
const {mutate, isPending} = useMutateCurrentUser();

const content = useMemo(() => {
switch (status) {
case "pending":
return "PENDING";
case "error":
return <pre>{JSON.stringify(error, null, 2)}</pre>;
case "success":
return isLoggedIn ? (

return <Container maxW="full" pt={6} px={8}>
<Skeleton isLoaded={!isLoading}>
{isError ? (
<Box as={Center}><Heading><WarningIcon/></Heading></Box>
) : isLoggedIn ? (
<>
<Heading size="md" mb={5}>{`Welcome ${user.FirstName} ${user.LastName}!`}</Heading>
<Heading size="md" mb={5}>{`Welcome ${user?.FirstName} ${user?.LastName}!`}</Heading>
<Button isDisabled={isPending} onClick={() => mutate({FirstName: "Buyer", LastName: "User"})}>Change Name</Button>
</>
) : (
<>
<Heading size="md">Welcome to the app!</Heading>
</>
);
}
}, [error, isLoggedIn, isPending, mutate, status, user])

return <Container maxW="full" pt={6} px={8}>{content}</Container>
)}
</Skeleton>
</Container>
};

export default Profile;
1 change: 0 additions & 1 deletion src/features/domains/ordercloud/hooks/useOrders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const useOrders = (
direction: OrderDirection,
listOptions?: OrderListOptions
) => {
console.log('hit');
return useAuthQuery({
queryKey: ["orders", direction, listOptions],
queryFn: async () => {
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
base: `/basic-application/`,
base: process.env.VITE_APP_CONFIG_BASE?.length > 1 ? `${process.env.VITE_APP_CONFIG_BASE}/` : undefined,
plugins: [react()],
})

0 comments on commit 404b5d5

Please sign in to comment.