Skip to content

Commit 3264540

Browse files
committed
territory branding ui/ux cleanup, general cleanup
1 parent a5a9c10 commit 3264540

File tree

4 files changed

+19
-44
lines changed

4 files changed

+19
-44
lines changed

api/acm/index.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
import AWS from 'aws-sdk'
2-
// TODO: boilerplate
32

43
AWS.config.update({
54
region: 'us-east-1'
65
})
76

8-
const config = {
9-
s3ForcePathStyle: process.env.NODE_ENV === 'development'
10-
}
7+
const config = {}
118

129
export async function requestCertificate (domain) {
13-
// for local development, we use the LOCALSTACK_ENDPOINT which
14-
// is reachable from the host machine
10+
// for local development, we use the LOCALSTACK_ENDPOINT
1511
if (process.env.NODE_ENV === 'development') {
1612
config.endpoint = process.env.LOCALSTACK_ENDPOINT
1713
}
1814

19-
// TODO: Research real values
2015
const acm = new AWS.ACM(config)
2116
const params = {
2217
DomainName: domain,
2318
ValidationMethod: 'DNS',
2419
Tags: [
2520
{
2621
Key: 'ManagedBy',
27-
Value: 'stackernews'
22+
Value: 'stacker.news'
2823
}
2924
]
3025
}
@@ -34,8 +29,6 @@ export async function requestCertificate (domain) {
3429
}
3530

3631
export async function describeCertificate (certificateArn) {
37-
// for local development, we use the LOCALSTACK_ENDPOINT which
38-
// is reachable from the host machine
3932
if (process.env.NODE_ENV === 'development') {
4033
config.endpoint = process.env.LOCALSTACK_ENDPOINT
4134
}

api/resolvers/branding.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ export default {
5454
throw new GqlInputError('invalid branding')
5555
}
5656

57-
// TODO: validation, even of logo and favicon.
58-
5957
return await models.customBranding.upsert({
6058
where: { subName },
6159
update: {

components/form.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import textAreaCaret from 'textarea-caret'
2323
import 'react-datepicker/dist/react-datepicker.css'
2424
import useDebounceCallback, { debounce } from './use-debounce-callback'
2525
import { FileUpload } from './file-upload'
26-
import { AWS_S3_URL_REGEXP } from '@/lib/constants'
26+
import { AWS_S3_URL_REGEXP, MEDIA_URL } from '@/lib/constants'
2727
import { whenRange } from '@/lib/time'
2828
import { useFeeButton } from './fee-button'
2929
import Thumb from '@/svgs/thumb-up-fill.svg'
@@ -1411,12 +1411,23 @@ export function ColorPicker ({ label, groupClassName, name, ...props }) {
14111411
}
14121412

14131413
export function BrandingUpload ({ label, groupClassName, name, ...props }) {
1414-
const [, , helpers] = useField({ ...props, name })
1414+
const [field, , helpers] = useField({ ...props, name })
1415+
const [tempId, setTempId] = useState(field.value)
1416+
1417+
const handleSuccess = useCallback((id) => {
1418+
setTempId(id)
1419+
helpers.setValue(id)
1420+
}, [helpers])
14151421

14161422
return (
14171423
<FormGroup label={label} className={groupClassName}>
1424+
<img
1425+
src={tempId ? `${MEDIA_URL}/${tempId}` : '/favicon.png'}
1426+
alt={name}
1427+
style={{ objectFit: 'contain', position: 'relative', width: '100%', height: '100%' }}
1428+
/>
14181429
<Avatar
1419-
onSuccess={(id) => helpers.setValue(id)}
1430+
onSuccess={handleSuccess}
14201431
/>
14211432
</FormGroup>
14221433
)

components/territory-branding-form.js

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { useToast } from './toast'
44
import { customBrandingSchema } from '@/lib/validate'
55
import { SET_CUSTOM_BRANDING } from '@/fragments/brandings'
66
import AccordianItem from './accordian-item'
7-
import SnIcon from '@/svgs/sn.svg'
87

98
export default function BrandingForm ({ sub }) {
109
const [setCustomBranding] = useMutation(SET_CUSTOM_BRANDING)
@@ -62,7 +61,7 @@ export default function BrandingForm ({ sub }) {
6261
<ColorPicker groupClassName='col-4' label='secondary color' name='secondary' />
6362
</div>
6463
<AccordianItem
65-
header={<div style={{ fontWeight: 'bold', fontSize: '92%' }}>more colors</div>}
64+
header={<div className='fw-bold text-muted'>more colors</div>}
6665
body={
6766
<div className='row'>
6867
<ColorPicker groupClassName='col-4' label='info color' name='info' />
@@ -72,44 +71,18 @@ export default function BrandingForm ({ sub }) {
7271
}
7372
/>
7473
<AccordianItem
75-
header={<div style={{ fontWeight: 'bold', fontSize: '92%' }}>logo and favicon</div>}
74+
header={<div className='fw-bold text-muted'>logo and favicon</div>}
7675
body={
7776
<div className='row'>
7877
<div className='col-2'>
7978
<label className='form-label'>logo</label>
8079
<div style={{ position: 'relative', width: '100px', height: '100px', border: '1px solid #dee2e6', borderRadius: '5px', overflow: 'hidden' }}>
81-
{sub?.customBranding?.logoId
82-
? (
83-
<img
84-
src={`${process.env.NEXT_PUBLIC_MEDIA_URL}/${sub.customBranding.logoId}`}
85-
alt='Logo'
86-
style={{ width: '100%', height: '100%', objectFit: 'contain' }}
87-
/>
88-
)
89-
: (
90-
<div style={{ width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
91-
<SnIcon style={{ fill: sub?.customBranding?.colors?.primary || '#FADA5E' }} width={36} height={36} />
92-
</div>
93-
)}
9480
<BrandingUpload name='logoId' />
9581
</div>
9682
</div>
9783
<div className='col-2'>
9884
<label className='form-label'>favicon</label>
9985
<div style={{ position: 'relative', width: '100px', height: '100px', border: '1px solid #dee2e6', borderRadius: '5px', overflow: 'hidden' }}>
100-
{sub?.customBranding?.faviconId
101-
? (
102-
<img
103-
src={`${process.env.NEXT_PUBLIC_MEDIA_URL}/${sub.customBranding.faviconId}`}
104-
alt='Favicon'
105-
style={{ width: '100%', height: '100%', objectFit: 'contain' }}
106-
/>
107-
)
108-
: (
109-
<div style={{ width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
110-
<img src='/favicon.png' alt='Favicon' style={{ width: '50%', height: '50%', objectFit: 'contain' }} />
111-
</div>
112-
)}
11386
<BrandingUpload name='faviconId' />
11487
</div>
11588
</div>

0 commit comments

Comments
 (0)