|
14 | 14 | <MudItem xs="12" md="6">
|
15 | 15 | <MudPaper Class="pa-4">
|
16 | 16 | <MudText Typo="Typo.h5">Post Preview</MudText>
|
17 |
| - @if (postType == PostType.BlogPost) |
18 |
| - { |
19 |
| - <MudText Typo="Typo.h6" Class="mt-2">Title: @title</MudText> |
20 |
| - <MudMarkdown MarkupContent="@textContent" /> |
21 |
| - } |
22 |
| - else if (postType == PostType.SocialPost) |
23 |
| - { |
24 |
| - <MudMarkdown MarkupContent="@textContent" /> |
25 |
| - @if (mediaFilesPreviews.Any()) |
26 |
| - { |
27 |
| - <MudText Typo="Typo.h6" Class="mt-4">Uploaded Files</MudText> |
28 |
| - <MudGrid> |
29 |
| - @foreach (var filePreview in mediaFilesPreviews) |
30 |
| - { |
31 |
| - <MudItem xs="12" sm="6"> |
32 |
| - <MudCard> |
33 |
| - @if (filePreview.IsImage) |
34 |
| - { |
35 |
| - <MudCardMedia Image="@filePreview.Url" Title="Media Preview" AspectRatio="16:9" /> |
36 |
| - } |
37 |
| - else if (filePreview.IsVideo) |
38 |
| - { |
39 |
| - <MudCardMedia AspectRatio="16:9"> |
40 |
| - <video width="100%" controls> |
41 |
| - <source src="@filePreview.Url" type="@filePreview.ContentType"> |
42 |
| - Your browser does not support the video tag. |
43 |
| - </video> |
44 |
| - </MudCardMedia> |
45 |
| - } |
46 |
| - else if (filePreview.IsPdf) |
47 |
| - { |
48 |
| - <MudCardContent> |
49 |
| - <MudButton Variant="Variant.Outlined" Color="Color.Secondary" StartIcon="@Icons.Material.Filled.PictureAsPdf" OnClick="@(async () => await JSRuntime.InvokeVoidAsync("window.open", filePreview.Url, "_blank"))"> |
50 |
| - View PDF |
51 |
| - </MudButton> |
52 |
| - </MudCardContent> |
53 |
| - } |
54 |
| - </MudCard> |
55 |
| - </MudItem> |
56 |
| - } |
57 |
| - </MudGrid> |
58 |
| - } |
59 |
| - } |
| 17 | + <PostPreview |
| 18 | + PostType="@postType" |
| 19 | + Title="@title" |
| 20 | + TextContent="@textContent" |
| 21 | + MediaFiles="@mediaFilesPreviews" |
| 22 | + UserId="@IdentityService.GetCurrentUserId()" /> |
60 | 23 | </MudPaper>
|
61 | 24 | </MudItem>
|
62 | 25 |
|
|
76 | 39 | {
|
77 | 40 | <MudText Typo="Typo.subtitle1" Class="mt-4">Blog Post Details</MudText>
|
78 | 41 | <MudTextField @bind-Value="title" Label="Post Title" FullWidth Immediate="true" Required="true" />
|
79 |
| - |
80 |
| - <!-- Custom MarkdownEditor for Blog Post Content --> |
81 | 42 | <MarkdownEditor @bind-MarkdownText="textContent" />
|
82 | 43 |
|
83 | 44 | <MudSelect T="PostContext" @bind-Value="postContext" Label="Post Context" Required="true" FullWidth Class="mt-4">
|
|
100 | 61 |
|
101 | 62 | <!-- Post State and Visibility -->
|
102 | 63 | <MudSelect T="string" @bind-Value="state" Label="State" Required="true" FullWidth Class="mt-4">
|
103 |
| - <MudSelectItem T="string" Value="@("InDraft")">Draft</MudSelectItem> |
104 |
| - <MudSelectItem T="string" Value="@("Published")">Published</MudSelectItem> |
| 64 | + <MudSelectItem T="string" Value=@("InDraft")>Draft</MudSelectItem> |
| 65 | + <MudSelectItem T="string" Value=@("Published")>Published</MudSelectItem> |
105 | 66 | </MudSelect>
|
106 | 67 |
|
107 | 68 | <MudSelect T="string" @bind-Value="visibility" Label="Visibility" Required="true" FullWidth Class="mt-4">
|
108 |
| - <MudSelectItem T="string" Value="@("Visible")">Visible</MudSelectItem> |
109 |
| - <MudSelectItem T="string" Value="@("Invisible")">Invisible</MudSelectItem> |
| 69 | + <MudSelectItem T="string" Value=@("Visible")>Visible</MudSelectItem> |
| 70 | + <MudSelectItem T="string" Value=@("Invisible")>Invisible</MudSelectItem> |
110 | 71 | </MudSelect>
|
111 | 72 |
|
112 | 73 | <MudDatePicker @bind-Date="publishDate" Label="Publish Date" Class="mt-4" />
|
|
125 | 86 | private MudForm form;
|
126 | 87 | private string textContent = "## Markdown Content\n";
|
127 | 88 | private string title;
|
128 |
| - private List<FilePreview> mediaFilesPreviews = new(); |
| 89 | + public List<FilePreview> mediaFilesPreviews = new(); |
129 | 90 | private List<string> uploadedMediaUrls = new List<string>();
|
130 | 91 | private string state = "InDraft";
|
131 | 92 | private string visibility = "Visible";
|
132 | 93 | private DateTime? publishDate = DateTime.Now;
|
133 | 94 | private bool isUploading = false;
|
134 |
| - private PostType postType = PostType.SocialPost; // Default to Social Post |
135 |
| - private PostContext postContext = PostContext.UserPage; // Default context |
| 95 | + private PostType postType = PostType.SocialPost; |
| 96 | + private PostContext postContext = PostContext.UserPage; |
136 | 97 |
|
137 | 98 | private async Task UploadMediaFilesClick()
|
138 | 99 | {
|
|
205 | 166 | State = state,
|
206 | 167 | Visibility = visibility,
|
207 | 168 | PublishDate = publishDate,
|
208 |
| - Context = postContext // The context now reflects UserPage, OrganizationPage, or EventPage |
| 169 | + Context = postContext |
209 | 170 | };
|
210 | 171 |
|
211 | 172 | var response = await PostsService.CreatePostAsync(command);
|
|
226 | 187 | NavigationManager.NavigateTo("/posts/my");
|
227 | 188 | }
|
228 | 189 |
|
229 |
| - private class FilePreview |
230 |
| - { |
231 |
| - public string Url { get; set; } |
232 |
| - public string ContentType { get; set; } |
233 |
| - public bool IsImage { get; set; } |
234 |
| - public bool IsVideo { get; set; } |
235 |
| - public bool IsPdf { get; set; } |
236 |
| - } |
237 | 190 | }
|
0 commit comments