mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
running dev environment
This commit is contained in:
parent
ab4cfc626e
commit
9b1ba34932
@ -13,8 +13,12 @@
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"paths": {
|
||||
"utopia-ui": ["../lib/src"],
|
||||
"utopia-ui/types": ["../lib/src/types"],
|
||||
"utopia-ui/types/*": ["../lib/src/types/*"]
|
||||
"#components/*": ["../lib/src/Components/*"],
|
||||
"#utils/*": ["../lib/src/Utils/*"],
|
||||
"#types/*": ["../lib/src/types/*"],
|
||||
"#assets/*": ["../lib/src/assets/*"],
|
||||
"#src/*": ["../lib/src/*"],
|
||||
"#root/*": ["../lib/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src"],
|
||||
|
||||
@ -25,7 +25,12 @@ export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
'utopia-ui': path.resolve(__dirname, '../lib/src'),
|
||||
|
||||
'#components': path.resolve(__dirname, '../lib/src/Components'),
|
||||
'#utils': path.resolve(__dirname, '../lib/src/Utils'),
|
||||
'#types': path.resolve(__dirname, '../lib/src/types'),
|
||||
'#assets': path.resolve(__dirname, '../lib/src/assets'),
|
||||
'#src': path.resolve(__dirname, '../lib/src'),
|
||||
'#root': path.resolve(__dirname, '../lib'),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -3,3 +3,5 @@ export { LoginPage } from './LoginPage'
|
||||
export { SignupPage } from './SignupPage'
|
||||
export { RequestPasswordPage } from './RequestPasswordPage'
|
||||
export { SetNewPasswordPage } from './SetNewPasswordPage'
|
||||
export type { UserItem } from '#types/UserItem'
|
||||
export type { UserApi } from '#types/UserApi'
|
||||
|
||||
@ -76,7 +76,9 @@ export const GalleryForm = ({ state, setState }: Props) => {
|
||||
|
||||
const images = state.gallery
|
||||
.map((image) => ({
|
||||
src: appState.assetsApi.url + `${image.directus_files_id.id}.jpg`,
|
||||
src:
|
||||
typeof image.directus_files_id !== 'string' &&
|
||||
appState.assetsApi.url + `${image.directus_files_id.id}.jpg`,
|
||||
state: 'uploaded',
|
||||
}))
|
||||
.concat(
|
||||
|
||||
@ -23,12 +23,21 @@ export const GalleryView = ({ item }: { item: Item }) => {
|
||||
const [index, setIndex] = useState(-1)
|
||||
const appState = useAppState()
|
||||
const images =
|
||||
item.gallery?.map(({ directus_files_id: { id, type, width, height } }, index) => ({
|
||||
src: `${appState.assetsApi.url}${id}${getExtension(type)}`,
|
||||
width,
|
||||
height,
|
||||
index,
|
||||
})) ?? []
|
||||
item.gallery?.flatMap((g, index) => {
|
||||
const file = g.directus_files_id
|
||||
// if it's just a string, skip it
|
||||
if (typeof file === 'string') return []
|
||||
// otherwise it's the object you want
|
||||
const { id, type, width, height } = file
|
||||
return [
|
||||
{
|
||||
src: `${appState.assetsApi.url}${id}${getExtension(type)}`,
|
||||
width,
|
||||
height,
|
||||
index,
|
||||
},
|
||||
]
|
||||
}) ?? []
|
||||
|
||||
if (images.length > 0)
|
||||
return (
|
||||
|
||||
@ -200,7 +200,7 @@ export const onUpdateItem = async (
|
||||
...(state.needs.length > 0 && { needs: needsUpdates }),
|
||||
...(state.openCollectiveSlug && { openCollectiveSlug: state.openCollectiveSlug }),
|
||||
gallery: state.gallery.map((i) => ({
|
||||
directus_files_id: i.directus_files_id.id,
|
||||
directus_files_id: typeof i.directus_files_id !== 'string' && i.directus_files_id.id,
|
||||
})),
|
||||
}
|
||||
|
||||
|
||||
14
lib/src/types/Item.d.ts
vendored
14
lib/src/types/Item.d.ts
vendored
@ -8,12 +8,14 @@ import type { Point } from 'geojson'
|
||||
type TagIds = { tags_id: string }[]
|
||||
|
||||
interface GalleryItem {
|
||||
directus_files_id: {
|
||||
id: string
|
||||
width: number
|
||||
height: number
|
||||
type: string
|
||||
}
|
||||
directus_files_id:
|
||||
| {
|
||||
id: string
|
||||
width: number
|
||||
height: number
|
||||
type: string
|
||||
}
|
||||
| string
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user