Skip to content

Commit 5daa65f

Browse files
committed
fix: charter build
1 parent a03ee8e commit 5daa65f

37 files changed

+335
-3638
lines changed

platforms/group-charter-manager/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
"@radix-ui/react-dropdown-menu": "^2.1.7",
2222
"@radix-ui/react-label": "^2.1.3",
2323
"@radix-ui/react-popover": "^1.1.7",
24+
"@radix-ui/react-separator": "^1.1.0",
2425
"@radix-ui/react-slot": "^1.2.0",
2526
"@radix-ui/react-switch": "^1.1.4",
2627
"@radix-ui/react-toast": "^1.2.14",
28+
"@radix-ui/react-toggle": "^1.1.0",
29+
"@radix-ui/react-tooltip": "^1.1.0",
2730
"@tailwindcss/typography": "^0.5.16",
2831
"@tiptap/extension-placeholder": "^2.24.0",
2932
"@tiptap/react": "^2.24.0",
@@ -49,7 +52,8 @@
4952
"tailwind-merge": "^3.3.1",
5053
"tailwindcss-animate": "^1.0.7",
5154
"turndown": "^7.2.0",
52-
"zod": "^3.24.2"
55+
"zod": "^3.24.2",
56+
"zustand": "^5.0.2"
5357
},
5458
"devDependencies": {
5559
"@eslint/eslintrc": "^3",
@@ -64,4 +68,4 @@
6468
"tailwindcss": "^4.1.11",
6569
"typescript": "^5"
6670
}
67-
}
71+
}

platforms/group-charter-manager/src/app/charter/[id]/edit/page.tsx

Lines changed: 69 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,48 @@ const insertCharterSchema = z.object({
4545
});
4646

4747
const editCharterSchema = insertCharterSchema.extend({
48+
name: z.string().optional(),
49+
description: z.string().optional(),
50+
groupId: z.string().optional(),
51+
isActive: z.boolean().optional(),
52+
autoApprove: z.boolean().optional(),
53+
allowPosts: z.boolean().optional(),
4854
guidelines: z
4955
.array(z.string())
5056
.min(1, "At least one guideline is required"),
5157
});
5258

5359
type EditCharterForm = z.infer<typeof editCharterSchema>;
5460

61+
interface Charter {
62+
id: string;
63+
name: string;
64+
description?: string;
65+
guidelines: string[];
66+
groupId?: string;
67+
isActive: boolean;
68+
autoApprove: boolean;
69+
allowPosts: boolean;
70+
createdAt: Date;
71+
updatedAt: Date;
72+
group?: {
73+
id: string;
74+
name: string;
75+
platform: string;
76+
imageUrl?: string;
77+
memberCount?: number;
78+
};
79+
}
80+
81+
interface Group {
82+
id: string;
83+
name: string;
84+
description?: string;
85+
platform?: string;
86+
imageUrl?: string;
87+
memberCount?: number;
88+
}
89+
5590
export default function EditCharter({
5691
params,
5792
}: {
@@ -62,15 +97,11 @@ export default function EditCharter({
6297
const [guidelines, setGuidelines] = useState<string[]>([]);
6398
const { user } = useAuth();
6499

65-
const { data: charter, isLoading: charterLoading } = {
66-
data: null,
67-
isLoading: false,
68-
}; // Replace with actual data fetching logic
100+
const charter: Charter | null = null; // Replace with actual data fetching logic
101+
const charterLoading = false;
69102

70-
const { data: groups, isLoading: groupsLoading } = {
71-
data: [],
72-
isLoading: false,
73-
}; // Replace with actual groups fetching logic
103+
const groups: Group[] = []; // Replace with actual groups fetching logic
104+
const groupsLoading = false;
74105

75106
const form = useForm<EditCharterForm>({
76107
resolver: zodResolver(editCharterSchema),
@@ -87,33 +118,34 @@ export default function EditCharter({
87118

88119
// Populate form when charter data is loaded
89120
useEffect(() => {
90-
if (charter && charter.name) {
91-
const guidelines = charter.guidelines || [];
121+
if (charter) {
122+
const charterData = charter as Charter;
123+
const guidelines = charterData.guidelines || [];
92124

93-
console.log("Charter data loaded:", charter);
94-
console.log("Charter name:", charter.name);
95-
console.log("Charter description:", charter.description);
125+
console.log("Charter data loaded:", charterData);
126+
console.log("Charter name:", charterData.name);
127+
console.log("Charter description:", charterData.description);
96128
console.log("Charter guidelines:", guidelines);
97-
console.log("Charter groupId:", charter.groupId);
129+
console.log("Charter groupId:", charterData.groupId);
98130

99131
// Set guidelines state first
100132
setGuidelines(guidelines.length > 0 ? guidelines : [""]);
101133

102134
// Reset form with current charter data
103135
const formValues = {
104-
name: charter.name || "",
105-
description: charter.description || "",
136+
name: charterData.name || "",
137+
description: charterData.description || "",
106138
guidelines: guidelines,
107-
groupId: charter.groupId || undefined,
139+
groupId: charterData.groupId || undefined,
108140
isActive:
109-
charter.isActive !== undefined ? charter.isActive : true,
141+
charterData.isActive !== undefined ? charterData.isActive : true,
110142
autoApprove:
111-
charter.autoApprove !== undefined
112-
? charter.autoApprove
143+
charterData.autoApprove !== undefined
144+
? charterData.autoApprove
113145
: false,
114146
allowPosts:
115-
charter.allowPosts !== undefined
116-
? charter.allowPosts
147+
charterData.allowPosts !== undefined
148+
? charterData.allowPosts
117149
: true,
118150
};
119151

@@ -124,23 +156,23 @@ export default function EditCharter({
124156

125157
// Also manually set values to ensure they stick
126158
setTimeout(() => {
127-
form.setValue("name", charter.name || "");
128-
form.setValue("description", charter.description || "");
159+
form.setValue("name", charterData.name || "");
160+
form.setValue("description", charterData.description || "");
129161
form.setValue("guidelines", guidelines);
130-
form.setValue("groupId", charter.groupId || undefined);
162+
form.setValue("groupId", charterData.groupId || undefined);
131163
form.setValue(
132164
"isActive",
133-
charter.isActive !== undefined ? charter.isActive : true
165+
charterData.isActive !== undefined ? charterData.isActive : true
134166
);
135167
form.setValue(
136168
"autoApprove",
137-
charter.autoApprove !== undefined
138-
? charter.autoApprove
169+
charterData.autoApprove !== undefined
170+
? charterData.autoApprove
139171
: false
140172
);
141173
form.setValue(
142174
"allowPosts",
143-
charter.allowPosts !== undefined ? charter.allowPosts : true
175+
charterData.allowPosts !== undefined ? charterData.allowPosts : true
144176
);
145177
}, 100);
146178
}
@@ -286,15 +318,15 @@ export default function EditCharter({
286318
className={cn(
287319
"w-full justify-between rounded-2xl border border-gray-200 bg-white/80 backdrop-blur-xs px-4 py-3 h-auto",
288320
!field.value &&
289-
"text-muted-foreground"
321+
"text-muted-foreground"
290322
)}
291323
>
292324
{field.value
293325
? groups?.find(
294-
(group) =>
295-
group.id ===
296-
field.value
297-
)?.name
326+
(group) =>
327+
group.id ===
328+
field.value
329+
)?.name
298330
: "Select a group..."}
299331
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
300332
</Button>
@@ -345,7 +377,7 @@ export default function EditCharter({
345377
</span>
346378
<PlatformBadge
347379
platform={
348-
group.platform
380+
group.platform || "unknown"
349381
}
350382
/>
351383
</div>
@@ -412,9 +444,8 @@ export default function EditCharter({
412444
className="flex items-center space-x-3"
413445
>
414446
<Input
415-
placeholder={`Guideline ${
416-
index + 1
417-
}`}
447+
placeholder={`Guideline ${index + 1
448+
}`}
418449
className="flex-1 px-4 py-3 rounded-2xl border border-gray-200 focus:border-amber-500 focus:ring-2 focus:ring-amber-200 transition-all duration-200 bg-white/80 backdrop-blur-xs"
419450
value={guideline}
420451
onChange={(e) =>

0 commit comments

Comments
 (0)