@@ -42,12 +42,8 @@ export async function saveSettings(data: FormData) {
42
42
const theme = data . get ( 'theme' ) as TTheme
43
43
const font = data . get ( 'font' ) as TFontSize
44
44
45
- let newOrganization = data . get ( 'newOrganization' ) as string | undefined
46
- const oldOrganization = data . get ( 'oldOrganization' ) as string
47
- const personal = ( data . get ( 'personal' ) as string ) === 'on'
48
- if ( newOrganization === 'undefined' ) {
49
- newOrganization = undefined
50
- }
45
+ const newOrganization = data . get ( 'newOid' ) as TOrganizationID | undefined
46
+ const oldOrganization = data . get ( 'oldOid' ) as TOrganizationID | undefined
51
47
52
48
let location : TLocation | undefined | string = data . get (
53
49
'newLocation' ,
@@ -74,17 +70,12 @@ export async function saveSettings(data: FormData) {
74
70
if ( isEmptyOrSpaces ( title ) )
75
71
errors [ 'name' ] = getFormFeedbackForError ( 'board/tiles-name-missing' )
76
72
77
- if ( ! personal && ! newOrganization )
78
- errors [ 'organization' ] = getFormFeedbackForError (
79
- 'create/organization-missing' ,
80
- )
81
-
82
73
if ( Object . keys ( errors ) . length !== 0 ) {
83
74
return errors
84
75
}
85
76
86
77
await saveTitle ( bid , title )
87
- await moveBoard ( bid , personal , newOrganization , oldOrganization )
78
+ await moveBoard ( bid , newOrganization , oldOrganization )
88
79
await saveLocation ( board , location )
89
80
await saveFont ( bid , font )
90
81
await setTheme ( bid , theme )
@@ -260,8 +251,7 @@ async function getTilesWithDistance(board: TBoard, location?: TLocation) {
260
251
261
252
async function moveBoard (
262
253
bid : TBoardID ,
263
- personal : boolean ,
264
- toOrganization : TOrganizationID | undefined ,
254
+ toOrganization ?: TOrganizationID ,
265
255
fromOrganization ?: TOrganizationID ,
266
256
) {
267
257
const user = await getUserFromSessionCookie ( )
@@ -291,7 +281,7 @@ async function moveBoard(
291
281
. doc ( user . uid )
292
282
. update ( { owner : firestore . FieldValue . arrayRemove ( bid ) } )
293
283
294
- if ( toOrganization && ! personal )
284
+ if ( toOrganization )
295
285
await firestore ( )
296
286
. collection ( 'organizations' )
297
287
. doc ( toOrganization )
0 commit comments