Skip to content

Commit

Permalink
Add link to categories page when no categories are present
Browse files Browse the repository at this point in the history
  • Loading branch information
DinerIsmail committed Nov 26, 2023
1 parent 6af565e commit 61d0712
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
14 changes: 13 additions & 1 deletion components/admin/listing-form/ListingForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Formik, Form, Field, FieldProps, useFormikContext } from 'formik'
import ReactSelect from 'react-select'
import type { Options } from 'react-select'
import { Category } from '@prisma/client'
import NextLink from 'next/link'
import {
chakra,
Box,
Expand Down Expand Up @@ -249,7 +250,18 @@ const ListingForm = ({ categories, listing, handleSubmit }: Props) => {
))}
</Select>
<FormHelperText>
Categories can be easily changed later
{categories.length === 0 ? (
<Text>
Looks like you haven't created categories yet. You
can add some{' '}
<NextLink href="/admin/categories">
on this page
</NextLink>
.
</Text>
) : (
'Categories can be easily changed later'
)}
</FormHelperText>
<FormErrorMessage>
Please select a category
Expand Down
4 changes: 4 additions & 0 deletions components/layout/Layout.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
color: rgb(0 0 0 / 70%);
}

h2, h3 {
margin-top: 1rem;
}

h2 {
font-size: 1.75rem;
font-weight: 600;
Expand Down
2 changes: 1 addition & 1 deletion pages/api/categories/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const handler = async (
where: {
web: {
slug: {
contains: web || 'cambridge-city',
contains: web,
},
},
},
Expand Down
4 changes: 1 addition & 3 deletions store/StoreProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import { useMediaQuerySSR } from '@hooks/application'
import { AppContext } from '@store/AppContext'
import { useWebs } from '@hooks/webs'

const DEFAULT_SELECTED_WEB = 'cambridge-city'

const StoreProvider = ({ children }) => {
const isMobile = useMediaQuerySSR('(max-width: 760px)')
const [isAdminMode, setIsAdminMode] = useState(false)
const [selectedWebSlug, setSelectedWebSlug] = useLocalStorage(
'selected-web',
DEFAULT_SELECTED_WEB,
null,
)
const [subdomain, setSubdomain] = useState<string>()

Expand Down
11 changes: 10 additions & 1 deletion styles/styles.global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ body {

* {
margin: 0;
font-family: Poppins, sans-serif;
font-family: Poppins, sans-serif;
font-display: swap;
}

Expand Down Expand Up @@ -45,3 +45,12 @@ a {
text-decoration: none !important;
}
}

/* stylelint-disable-next-line no-descending-specificity */
p > a {
color: #3A8159 !important;

&:hover {
color: #09622f !important;
}
}

1 comment on commit 61d0712

@vercel
Copy link

@vercel vercel bot commented on 61d0712 Nov 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.