-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(storefront): ♻️ updated account settings
- Loading branch information
Showing
10 changed files
with
316 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 34 additions & 18 deletions
52
apps/storefront/src/components/pages/account/DangerZone.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,41 @@ | ||
import type { StackProps } from "@chakra-ui/react"; | ||
import { Button, Stack, Text } from "@chakra-ui/react"; | ||
import { Button, Stack, Text, useToast } from "@chakra-ui/react"; | ||
|
||
import Card from "./Card"; | ||
import HeadingGroup from "./HeadingGroup"; | ||
|
||
const DangerZone = (props: StackProps) => ( | ||
<Stack as="section" spacing="6" {...props}> | ||
<HeadingGroup | ||
title="Danger zone" | ||
description="Irreversible and destructive actions" | ||
/> | ||
<Card> | ||
<Text fontWeight="bold">Delete account and data</Text> | ||
<Text fontSize="sm" mt="1" mb="3"> | ||
Once you delete your user, there is no going back. Please be certain. | ||
</Text> | ||
<Button size="sm" colorScheme="red"> | ||
Delete account | ||
</Button> | ||
</Card> | ||
</Stack> | ||
); | ||
const DangerZone = (props: StackProps) => { | ||
const toast = useToast(); | ||
|
||
return ( | ||
<Stack as="section" spacing="6" {...props}> | ||
<HeadingGroup | ||
title="Danger zone" | ||
description="Irreversible and destructive actions" | ||
/> | ||
<Card> | ||
<Text fontWeight="bold">Delete account and data</Text> | ||
<Text fontSize="sm" mt="1" mb="3"> | ||
Once you delete your user, there is no going back. Please be certain. | ||
</Text> | ||
<Button | ||
size="sm" | ||
colorScheme="red" | ||
onClick={() => { | ||
toast({ | ||
title: "Feature Comming Soon", | ||
description: "It will be very available soon.", | ||
status: "info", | ||
duration: 5000, | ||
isClosable: true, | ||
}); | ||
}} | ||
> | ||
Delete account | ||
</Button> | ||
</Card> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default DangerZone; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 66 additions & 22 deletions
88
apps/storefront/src/components/pages/account/SocialAccountSettings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,74 @@ | ||
import type { StackProps } from "@chakra-ui/react"; | ||
import { Stack } from "@chakra-ui/react"; | ||
import { FaFacebook } from "react-icons/fa"; | ||
|
||
import { Spinner, Stack } from "@chakra-ui/react"; | ||
import { FcGoogle } from "react-icons/fc"; | ||
import { useMeWithAccountQuery } from "@/generated/graphql"; | ||
import Result from "@/components/shared/Result"; | ||
import { capitalize, parseJwt } from "@/utils/helpers"; | ||
import { getGoogleOAuthUrl } from "@/components/auth/AuthProvider"; | ||
import Card from "./Card"; | ||
import HeadingGroup from "./HeadingGroup"; | ||
import SocialAccount from "./SocialAccount"; | ||
|
||
const SocialAccountSettings = (props: StackProps) => ( | ||
<Stack as="section" spacing="6" {...props}> | ||
<HeadingGroup | ||
title="Connected accounts" | ||
description="Connect your Hamropasal account to one or more provides" | ||
/> | ||
<Card> | ||
<Stack spacing="5"> | ||
<SocialAccount provider="Google" icon={FcGoogle} username="Rohit Sah" /> | ||
<SocialAccount | ||
provider="Facebook" | ||
icon={FaFacebook} | ||
// username="sahrohit9586" | ||
iconColor="blue.500" | ||
/> | ||
</Stack> | ||
</Card> | ||
</Stack> | ||
); | ||
const providers = [ | ||
{ | ||
provider: "google", | ||
icon: FcGoogle, | ||
onConnect: () => { | ||
window.location.href = getGoogleOAuthUrl(); | ||
}, | ||
}, | ||
]; | ||
|
||
const SocialAccountSettings = (props: StackProps) => { | ||
const { data, loading, error } = useMeWithAccountQuery(); | ||
|
||
if (loading) { | ||
return <Spinner />; | ||
} | ||
|
||
if (error) | ||
return ( | ||
<Result | ||
heading={error.name} | ||
text={error.message} | ||
type="error" | ||
dump={error.stack} | ||
/> | ||
); | ||
|
||
return ( | ||
<Stack as="section" spacing="6" {...props}> | ||
<HeadingGroup | ||
title="Connected accounts" | ||
description="Connect your Hamropasal account to one or more provides" | ||
/> | ||
<Card> | ||
<Stack spacing="5"> | ||
{providers?.map((provider) => { | ||
let profile; | ||
|
||
if (provider.provider === "google") { | ||
profile = parseJwt( | ||
data?.meWithAccount?.accounts?.find( | ||
(account) => account.provider === "google" | ||
)?.id_token ?? "" | ||
); | ||
} | ||
|
||
return ( | ||
<SocialAccount | ||
key={provider.provider} | ||
provider={capitalize(provider.provider)} | ||
icon={provider.icon} | ||
imageUrl={profile?.picture} | ||
username={profile?.name} | ||
/> | ||
); | ||
})} | ||
</Stack> | ||
</Card> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default SocialAccountSettings; |
Oops, something went wrong.
b44c842
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ecommerce-storefront-client – ./apps/storefront
ecommerce-storefront-client-sahrohit.vercel.app
hamropasal.vercel.app
www.rudejellyfish.live
rudejellyfish.live
ecommerce-storefront-client-git-main-sahrohit.vercel.app
b44c842
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ecommerce-admin-client – ./apps/admin
ecommerce-admin-client.vercel.app
ecommerce-admin-client-git-main-sahrohit.vercel.app
ecommerce-admin-client-sahrohit.vercel.app