Skip to content

Commit

Permalink
🐛 Remove delete result cascade
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Sep 27, 2022
1 parent 30dff2d commit 3c803b1
Show file tree
Hide file tree
Showing 11 changed files with 386 additions and 170 deletions.
61 changes: 61 additions & 0 deletions apps/builder/assets/logos/StripeClimateLogo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Icon, IconProps } from '@chakra-ui/react'

export const StripeClimateLogo = (props: IconProps) => (
<Icon
width="24px"
height="24px"
viewBox="0 0 32 32"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<linearGradient
id="StripeClimate-gradient-a"
gradientUnits="userSpaceOnUse"
x1="16"
y1="20.6293"
x2="16"
y2="7.8394"
gradientTransform="matrix(1 0 0 -1 0 34)"
>
<stop offset="0" stop-color="#00d924" />
<stop offset="1" stop-color="#00cb1b" />
</linearGradient>
<path
d="M0 10.82h32c0 8.84-7.16 16-16 16s-16-7.16-16-16z"
fill="url(#StripeClimate-gradient-a)"
/>
<linearGradient
id="StripeClimate-gradient-b"
gradientUnits="userSpaceOnUse"
x1="24"
y1="28.6289"
x2="24"
y2="17.2443"
gradientTransform="matrix(1 0 0 -1 0 34)"
>
<stop offset=".1562" stop-color="#009c00" />
<stop offset="1" stop-color="#00be20" />
</linearGradient>
<path
d="M32 10.82c0 2.21-1.49 4.65-5.41 4.65-3.42 0-7.27-2.37-10.59-4.65 3.52-2.43 7.39-5.63 10.59-5.63C29.86 5.18 32 8.17 32 10.82z"
fill="url(#StripeClimate-gradient-b)"
/>
<linearGradient
id="StripeClimate-gradient-c"
gradientUnits="userSpaceOnUse"
x1="8"
y1="16.7494"
x2="8"
y2="29.1239"
gradientTransform="matrix(1 0 0 -1 0 34)"
>
<stop offset="0" stop-color="#ffe37d" />
<stop offset="1" stop-color="#ffc900" />
</linearGradient>
<path
d="M0 10.82c0 2.21 1.49 4.65 5.41 4.65 3.42 0 7.27-2.37 10.59-4.65-3.52-2.43-7.39-5.64-10.59-5.64C2.14 5.18 0 8.17 0 10.82z"
fill="url(#StripeClimate-gradient-c)"
/>
</Icon>
)
20 changes: 17 additions & 3 deletions apps/builder/components/shared/ChangePlanForm/ChangePlanForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Stack, HStack, Text } from '@chakra-ui/react'
import { StripeClimateLogo } from 'assets/logos/StripeClimateLogo'
import { NextChakraLink } from 'components/nextChakra/NextChakraLink'
import { useUser } from 'contexts/UserContext'
import { useWorkspace } from 'contexts/WorkspaceContext'
Expand Down Expand Up @@ -63,7 +64,21 @@ export const ChangePlanForm = () => {
}

return (
<Stack spacing={4}>
<Stack spacing={6}>
<HStack maxW="500px">
<StripeClimateLogo />
<Text fontSize="xs" color="gray.500">
Typebot is contributing 1% of your subscription to remove CO₂ from the
atmosphere.{' '}
<NextChakraLink
href="https://climate.stripe.com/5VCRAq"
isExternal
textDecor="underline"
>
More info.
</NextChakraLink>
</Text>
</HStack>
<HStack alignItems="stretch" spacing="4" w="full">
<StarterPlanContent
initialChatsLimitIndex={
Expand Down Expand Up @@ -94,9 +109,8 @@ export const ChangePlanForm = () => {
isExternal
textDecor="underline"
>
Let me know
Let's chat!
</NextChakraLink>
.
</Text>
</Stack>
)
Expand Down
4 changes: 4 additions & 0 deletions apps/builder/pages/api/typebots/[typebotId].ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const typebots = await prisma.typebot.deleteMany({
where: canWriteTypebot(typebotId, user),
})
await prisma.result.updateMany({
where: { typebot: canWriteTypebot(typebotId, user) },
data: { isArchived: true },
})
return res.send({ typebots })
}
if (req.method === 'PUT') {
Expand Down
11 changes: 11 additions & 0 deletions apps/builder/pages/api/workspaces/[workspaceId].ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
members: { some: { userId: user.id, role: WorkspaceRole.ADMIN } },
},
})
await prisma.result.updateMany({
where: {
typebot: {
workspace: {
id,
members: { some: { userId: user.id, role: WorkspaceRole.ADMIN } },
},
},
},
data: { isArchived: true },
})
return res.status(200).json({
message: 'success',
})
Expand Down
61 changes: 61 additions & 0 deletions apps/landing-page/assets/logos/StripeClimateLogo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Icon, IconProps } from '@chakra-ui/react'

export const StripeClimateLogo = (props: IconProps) => (
<Icon
width="24px"
height="24px"
viewBox="0 0 32 32"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<linearGradient
id="StripeClimate-gradient-a"
gradientUnits="userSpaceOnUse"
x1="16"
y1="20.6293"
x2="16"
y2="7.8394"
gradientTransform="matrix(1 0 0 -1 0 34)"
>
<stop offset="0" stop-color="#00d924" />
<stop offset="1" stop-color="#00cb1b" />
</linearGradient>
<path
d="M0 10.82h32c0 8.84-7.16 16-16 16s-16-7.16-16-16z"
fill="url(#StripeClimate-gradient-a)"
/>
<linearGradient
id="StripeClimate-gradient-b"
gradientUnits="userSpaceOnUse"
x1="24"
y1="28.6289"
x2="24"
y2="17.2443"
gradientTransform="matrix(1 0 0 -1 0 34)"
>
<stop offset=".1562" stop-color="#009c00" />
<stop offset="1" stop-color="#00be20" />
</linearGradient>
<path
d="M32 10.82c0 2.21-1.49 4.65-5.41 4.65-3.42 0-7.27-2.37-10.59-4.65 3.52-2.43 7.39-5.63 10.59-5.63C29.86 5.18 32 8.17 32 10.82z"
fill="url(#StripeClimate-gradient-b)"
/>
<linearGradient
id="StripeClimate-gradient-c"
gradientUnits="userSpaceOnUse"
x1="8"
y1="16.7494"
x2="8"
y2="29.1239"
gradientTransform="matrix(1 0 0 -1 0 34)"
>
<stop offset="0" stop-color="#ffe37d" />
<stop offset="1" stop-color="#ffc900" />
</linearGradient>
<path
d="M0 10.82c0 2.21 1.49 4.65 5.41 4.65 3.42 0 7.27-2.37 10.59-4.65-3.52-2.43-7.39-5.64-10.59-5.64C2.14 5.18 0 8.17 0 10.82z"
fill="url(#StripeClimate-gradient-c)"
/>
</Icon>
)
Loading

0 comments on commit 3c803b1

Please sign in to comment.