-
Notifications
You must be signed in to change notification settings - Fork 1
Footers for tenants #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Footers for tenants #201
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
72a10e0
Make footer unique to each tenant
rchlfryn efd6b60
Add seed data
rchlfryn 0a7309f
Add social media icons
rchlfryn e172a4f
Update footer to include name and phone
rchlfryn 639811c
Update styling and add validation phone number and for newly added ha…
rchlfryn 053e7c2
Add copyright, terms and conditions and privacy policy to footer
rchlfryn c7fb8f2
Move footer seed data
rchlfryn 7c806cd
Update form PR review
rchlfryn c9292eb
Change name of footer logo
rchlfryn 37cfc74
Rmeove contentHash: null seeding
rchlfryn 38b6c3e
Remove footer as type
rchlfryn 4741723
Update seed data
rchlfryn 8b2e237
Update to correct regex
rchlfryn 1d7344f
Update copyright to be current year
rchlfryn 6aeb208
Remove unnecessary null check
rchlfryn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,154 @@ | ||
import { accessByTenant } from '@/access/byTenant' | ||
import { filterByTenant } from '@/access/filterByTenant' | ||
import { contentHashField } from '@/fields/contentHashField' | ||
import { tenantField } from '@/fields/tenantField' | ||
import { generatePreviewPath } from '@/utilities/generatePreviewPath' | ||
import type { CollectionConfig, TextFieldValidation } from 'payload' | ||
|
||
const validateHashtag: TextFieldValidation = (value: string | null | undefined): string | true => { | ||
return value | ||
? /^#[A-Za-z0-9_](?:[A-Za-z0-9_]|(?:\.(?!\.))){0,28}[A-Za-z0-9_]$/.test(value) || | ||
`${value} is not a valid hashtag` | ||
: true | ||
} | ||
|
||
const validateTelephone: TextFieldValidation = ( | ||
value: string | null | undefined, | ||
): string | true => { | ||
return value | ||
? /^(\+1\s?|1\s?)?(\(\d{3}\)|\d{3})[\s.-]?\d{3}[\s.-]?\d{4}$/.test(value) || | ||
`${value} is not a valid phone number` | ||
: true | ||
} | ||
|
||
export const Footer: CollectionConfig = { | ||
slug: 'footer', | ||
access: accessByTenant('footer'), | ||
admin: { | ||
// the GlobalViewRedirect will never allow a user to visit the list view of this collection but including this list filter as a precaution | ||
baseListFilter: filterByTenant, | ||
group: 'Globals', | ||
livePreview: { | ||
url: async ({ data, req, payload }) => { | ||
let tenant = data.tenant | ||
|
||
if (typeof tenant === 'number') { | ||
tenant = await payload.findByID({ | ||
collection: 'tenants', | ||
id: tenant, | ||
depth: 2, | ||
}) | ||
} | ||
|
||
const path = generatePreviewPath({ | ||
slug: '', | ||
collection: 'pages', | ||
tenant, | ||
req, | ||
}) | ||
|
||
return path | ||
}, | ||
}, | ||
}, | ||
fields: [ | ||
tenantField({ unique: true }), | ||
{ | ||
name: 'footerLogo', | ||
type: 'upload', | ||
relationTo: 'media', | ||
filterOptions: { | ||
mimeType: { contains: 'image' }, | ||
}, | ||
}, | ||
{ | ||
name: 'name', | ||
stevekuznetsov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
type: 'text', | ||
required: true, | ||
}, | ||
{ | ||
name: 'address', | ||
type: 'textarea', | ||
}, | ||
{ | ||
name: 'phone', | ||
type: 'text', | ||
validate: validateTelephone, | ||
}, | ||
{ | ||
name: 'email', | ||
type: 'email', | ||
}, | ||
{ | ||
name: 'socialMedia', | ||
type: 'group', | ||
fields: [ | ||
{ | ||
type: 'row', | ||
fields: [ | ||
{ | ||
name: 'instagram', | ||
type: 'text', | ||
admin: { | ||
width: '33%', | ||
}, | ||
}, | ||
{ | ||
name: 'facebook', | ||
type: 'text', | ||
admin: { | ||
width: '33%', | ||
}, | ||
}, | ||
{ | ||
name: 'twitter', | ||
type: 'text', | ||
admin: { | ||
width: '33%', | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
type: 'row', | ||
fields: [ | ||
{ | ||
name: 'linkedin', | ||
type: 'text', | ||
admin: { | ||
width: '33%', | ||
}, | ||
}, | ||
{ | ||
name: 'youtube', | ||
type: 'text', | ||
admin: { | ||
width: '33%', | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
admin: { | ||
description: | ||
'Add link to social media page to have the icon appear in the footer. Leave the field blank if you do not want the icon to show.', | ||
}, | ||
}, | ||
{ | ||
name: 'hashtag', | ||
type: 'text', | ||
validate: validateHashtag, | ||
}, | ||
{ | ||
name: 'terms', | ||
type: 'relationship', | ||
relationTo: 'pages', | ||
}, | ||
{ | ||
name: 'privacy', | ||
type: 'relationship', | ||
relationTo: 'pages', | ||
}, | ||
contentHashField(), | ||
], | ||
} |
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.